> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixpeek.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup Payment Method

> Initialize payment method setup flow.

Creates a Stripe SetupIntent for collecting payment method without charging.
The client_secret should be used with Stripe Elements on the frontend.

**Flow:**
1. Frontend calls this endpoint
2. Backend creates Stripe Customer (if needed) and SetupIntent
3. Frontend uses client_secret with Stripe Elements
4. User enters card details
5. Frontend calls confirm-payment-method endpoint

**Requirements:**
- Admin permission (only org admins can set up payment methods)

**Example:**
```python
response = await client.post("/v1/organizations/billing/setup-payment-method")
client_secret = response["client_secret"]
# Use client_secret with Stripe Elements
```



## OpenAPI

````yaml post /v1/organizations/billing/setup-payment-method
openapi: 3.1.0
info:
  title: Mixpeek API
  description: >-
    This is the Mixpeek API, providing access to various endpoints for data
    processing and retrieval.
  termsOfService: https://mixpeek.com/terms
  contact:
    name: Mixpeek Support
    url: https://mixpeek.com/contact
    email: info@mixpeek.com
  version: '0.82'
servers:
  - url: https://api.mixpeek.com
    description: Production
security: []
paths:
  /v1/organizations/billing/setup-payment-method:
    post:
      tags:
        - Organization Billing
      summary: Setup Payment Method
      description: >-
        Initialize payment method setup flow.


        Creates a Stripe SetupIntent for collecting payment method without
        charging.

        The client_secret should be used with Stripe Elements on the frontend.


        **Flow:**

        1. Frontend calls this endpoint

        2. Backend creates Stripe Customer (if needed) and SetupIntent

        3. Frontend uses client_secret with Stripe Elements

        4. User enters card details

        5. Frontend calls confirm-payment-method endpoint


        **Requirements:**

        - Admin permission (only org admins can set up payment methods)


        **Example:**

        ```python

        response = await
        client.post("/v1/organizations/billing/setup-payment-method")

        client_secret = response["client_secret"]

        # Use client_secret with Stripe Elements

        ```
      operationId: setup_payment_method_v1_organizations_billing_setup_payment_method_post
      parameters: []
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetupPaymentMethodResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SetupPaymentMethodResponse:
      properties:
        setup_intent_id:
          type: string
          title: Setup Intent Id
          description: Stripe SetupIntent ID
          examples:
            - seti_1ABC2DEF3GHI
        client_secret:
          type: string
          title: Client Secret
          description: Client secret for Stripe Elements
          examples:
            - seti_1ABC2DEF3GHI_secret_XYZ
        customer_id:
          type: string
          title: Customer Id
          description: Stripe Customer ID
          examples:
            - cus_ABC123DEF456
      type: object
      required:
        - setup_intent_id
        - client_secret
        - customer_id
      title: SetupPaymentMethodResponse
      description: Response after creating a SetupIntent.
    ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Always false for error responses
          default: false
        status:
          type: integer
          title: Status
          description: HTTP status code for this error
        error:
          $ref: '#/components/schemas/ErrorDetail'
          description: Error details payload
      type: object
      required:
        - status
        - error
      title: ErrorResponse
      description: Error response model.
      examples:
        - error:
            details:
              id: ns_123
              resource: namespace
            message: Namespace not found
            type: NotFoundError
          status: 404
          success: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Human-readable error message
        type:
          type: string
          title: Type
          description: Stable error type identifier (machine-readable)
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: >-
            Fine-grained error code for programmatic handling (e.g.,
            namespace_name_taken, feature_extractor_not_found). Present only
            when consumers may need to branch on a specific error condition.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: >-
            Optional structured details to help debugging (validation errors,
            IDs, etc.)
      type: object
      required:
        - message
        - type
      title: ErrorDetail
      description: Error detail model.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````