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

# Attach Payment Method

> Attach a confirmed PaymentMethod to the customer and optionally set as default.

Called after Stripe Elements ``confirmSetup`` resolves on the frontend. We
attach synchronously (rather than waiting for the ``payment_method.attached``
webhook) so the UI can render the new card immediately after the modal closes.



## OpenAPI

````yaml /openapi.json post /api/v1/workspaces/{workspace_id}/billing/payment-methods
openapi: 3.1.0
info:
  description: Change Impact Engine for multi-repo systems
  title: Riftmap
  version: 1.12.3
servers: []
security: []
paths:
  /api/v1/workspaces/{workspace_id}/billing/payment-methods:
    post:
      tags:
        - billing
      summary: Attach Payment Method
      description: >-
        Attach a confirmed PaymentMethod to the customer and optionally set as
        default.


        Called after Stripe Elements ``confirmSetup`` resolves on the frontend.
        We

        attach synchronously (rather than waiting for the
        ``payment_method.attached``

        webhook) so the UI can render the new card immediately after the modal
        closes.
      operationId: >-
        attach_payment_method_api_v1_workspaces__workspace_id__billing_payment_methods_post
      parameters:
        - in: path
          name: workspace_id
          required: true
          schema:
            format: uuid
            title: Workspace Id
            type: string
        - in: header
          name: X-Workspace-Id
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Workspace-Id
        - in: cookie
          name: riftmap_access
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Riftmap Access
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AttachPaymentMethodRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttachPaymentMethodResponse'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - APIKeyHeader: []
        - HTTPBearer: []
components:
  schemas:
    AttachPaymentMethodRequest:
      properties:
        payment_method_id:
          title: Payment Method Id
          type: string
        set_as_default:
          default: true
          title: Set As Default
          type: boolean
      required:
        - payment_method_id
      title: AttachPaymentMethodRequest
      type: object
    AttachPaymentMethodResponse:
      properties:
        is_default:
          title: Is Default
          type: boolean
        payment_method:
          $ref: '#/components/schemas/PaymentMethodInfo'
      required:
        - payment_method
        - is_default
      title: AttachPaymentMethodResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    PaymentMethodInfo:
      properties:
        brand:
          title: Brand
          type: string
        exp_month:
          title: Exp Month
          type: integer
        exp_year:
          title: Exp Year
          type: integer
        last4:
          title: Last4
          type: string
      required:
        - brand
        - last4
        - exp_month
        - exp_year
      title: PaymentMethodInfo
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    APIKeyHeader:
      in: header
      name: X-API-Key
      type: apiKey
    HTTPBearer:
      description: API key as Bearer token (rfm_live_... prefix)
      scheme: bearer
      type: http

````