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

# Add Customer Payment Method

> Add a payment method to the authenticated customer.



## OpenAPI

````yaml /openapi/2027-01.openapi.json post /v1/customer-portal/customers/me/payment-methods
openapi: 3.1.0
info:
  title: Polar API
  summary: Polar HTTP and Webhooks API
  description: >-
    Read the docs at https://polar.sh/docs/api-reference. See
    https://polar.sh/docs/api-reference/versioning for the API versioning and
    deprecation policy.
  version: 2027-01
servers:
  - url: https://api.polar.sh
    description: Production environment
    x-speakeasy-server-id: production
    x-polar-environment: production
  - url: https://sandbox-api.polar.sh
    description: Sandbox environment
    x-speakeasy-server-id: sandbox
    x-polar-environment: sandbox
security: []
tags:
  - name: public
    description: >-
      Endpoints shown and documented in the Polar API documentation and
      available in our SDKs.
  - name: private
    description: >-
      Endpoints that should appear in the schema only in development to generate
      our internal JS SDK.
  - name: mcp
    description: Endpoints supported by Polar's MCP server.
  - name: cli
    description: Endpoints exposed as commands by Polar's CLI.
externalDocs:
  description: API versioning and deprecation policy
  url: https://polar.sh/docs/api-reference/versioning
paths:
  /v1/customer-portal/customers/me/payment-methods:
    post:
      tags:
        - customer_portal
        - customers
        - public
      summary: Add Customer Payment Method
      description: Add a payment method to the authenticated customer.
      operationId: customer_portal:customers:add_payment_method
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerPaymentMethodCreate'
      responses:
        '201':
          description: Payment method created or setup initiated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerPaymentMethodCreateResponse'
                title: CustomerPaymentMethodCreateResponse
        '400':
          description: The card was declined while setting up the payment method.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethodSetupFailed'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - customer_session:
            - customer_portal:write
        - member_session:
            - customer_portal:write
      x-codeSamples:
        - lang: python
          source: |
            from polar.v2027_01 import Polar

            polar = Polar("polar_oat_xxx")

            response = polar.customer_portal.customers.add_payment_method(
                confirmation_token_id='string',
                set_default=True,
                return_url='string',
            )
            print(response)
        - lang: typescript
          source: >
            import { createPolar } from "@polar-sh/sdk/2027-01";


            const polar = createPolar({
              accessToken: "polar_oat_xxx",
            });


            const response = await
            polar.customerPortal.customers.addPaymentMethod(
              {
                "confirmation_token_id": "string",
                "set_default": true,
                "return_url": "string"
              },
            );

            console.log(response);
components:
  schemas:
    CustomerPaymentMethodCreate:
      properties:
        confirmation_token_id:
          type: string
          title: Confirmation Token Id
        set_default:
          type: boolean
          title: Set Default
        return_url:
          type: string
          title: Return Url
      type: object
      required:
        - confirmation_token_id
        - set_default
        - return_url
      title: CustomerPaymentMethodCreate
    CustomerPaymentMethodCreateResponse:
      oneOf:
        - $ref: '#/components/schemas/CustomerPaymentMethodCreateSucceededResponse'
        - $ref: >-
            #/components/schemas/CustomerPaymentMethodCreateRequiresActionResponse
      discriminator:
        propertyName: status
        mapping:
          requires_action: >-
            #/components/schemas/CustomerPaymentMethodCreateRequiresActionResponse
          succeeded: '#/components/schemas/CustomerPaymentMethodCreateSucceededResponse'
    PaymentMethodSetupFailed:
      properties:
        error:
          type: string
          const: PaymentMethodSetupFailed
          title: Error
          examples:
            - PaymentMethodSetupFailed
        detail:
          type: string
          title: Detail
      type: object
      required:
        - error
        - detail
      title: PaymentMethodSetupFailed
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CustomerPaymentMethodCreateSucceededResponse:
      properties:
        status:
          type: string
          const: succeeded
          title: Status
        payment_method:
          $ref: '#/components/schemas/CustomerPaymentMethod'
          title: CustomerPaymentMethod
      type: object
      required:
        - status
        - payment_method
      title: CustomerPaymentMethodCreateSucceededResponse
    CustomerPaymentMethodCreateRequiresActionResponse:
      properties:
        status:
          type: string
          const: requires_action
          title: Status
        client_secret:
          type: string
          title: Client Secret
      type: object
      required:
        - status
        - client_secret
      title: CustomerPaymentMethodCreateRequiresActionResponse
    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
    CustomerPaymentMethod:
      anyOf:
        - $ref: '#/components/schemas/PaymentMethodCard'
        - $ref: '#/components/schemas/PaymentMethodKrCard'
        - $ref: '#/components/schemas/PaymentMethodGeneric'
    PaymentMethodCard:
      properties:
        id:
          type: string
          format: uuid4
          title: Id
          description: The ID of the object.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Creation timestamp of the object.
          examples:
            - '2026-01-01T00:00:00.000000Z'
        modified_at:
          anyOf:
            - type: string
              format: date-time
              examples:
                - '2026-01-01T00:00:00.000000Z'
            - type: 'null'
          title: Modified At
          description: Last modification timestamp of the object.
        processor:
          $ref: '#/components/schemas/PaymentProcessor'
        customer_id:
          type: string
          format: uuid4
          title: Customer Id
        type:
          type: string
          const: card
          title: Type
        method_metadata:
          $ref: '#/components/schemas/PaymentMethodCardMetadata'
      type: object
      required:
        - id
        - created_at
        - modified_at
        - processor
        - customer_id
        - type
        - method_metadata
      title: PaymentMethodCard
    PaymentMethodKrCard:
      properties:
        id:
          type: string
          format: uuid4
          title: Id
          description: The ID of the object.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Creation timestamp of the object.
          examples:
            - '2026-01-01T00:00:00.000000Z'
        modified_at:
          anyOf:
            - type: string
              format: date-time
              examples:
                - '2026-01-01T00:00:00.000000Z'
            - type: 'null'
          title: Modified At
          description: Last modification timestamp of the object.
        processor:
          $ref: '#/components/schemas/PaymentProcessor'
        customer_id:
          type: string
          format: uuid4
          title: Customer Id
        type:
          type: string
          const: kr_card
          title: Type
        method_metadata:
          $ref: '#/components/schemas/PaymentMethodKrCardMetadata'
      type: object
      required:
        - id
        - created_at
        - modified_at
        - processor
        - customer_id
        - type
        - method_metadata
      title: PaymentMethodKrCard
    PaymentMethodGeneric:
      properties:
        id:
          type: string
          format: uuid4
          title: Id
          description: The ID of the object.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Creation timestamp of the object.
          examples:
            - '2026-01-01T00:00:00.000000Z'
        modified_at:
          anyOf:
            - type: string
              format: date-time
              examples:
                - '2026-01-01T00:00:00.000000Z'
            - type: 'null'
          title: Modified At
          description: Last modification timestamp of the object.
        processor:
          $ref: '#/components/schemas/PaymentProcessor'
        customer_id:
          type: string
          format: uuid4
          title: Customer Id
        type:
          type: string
          title: Type
      type: object
      required:
        - id
        - created_at
        - modified_at
        - processor
        - customer_id
        - type
      title: PaymentMethodGeneric
    PaymentProcessor:
      type: string
      enum:
        - stripe
      title: PaymentProcessor
    PaymentMethodCardMetadata:
      properties:
        brand:
          type: string
          title: Brand
        last4:
          type: string
          title: Last4
        exp_month:
          type: integer
          title: Exp Month
        exp_year:
          type: integer
          title: Exp Year
        wallet:
          anyOf:
            - type: string
            - type: 'null'
          title: Wallet
      type: object
      required:
        - brand
        - last4
        - exp_month
        - exp_year
      title: PaymentMethodCardMetadata
    PaymentMethodKrCardMetadata:
      properties:
        brand:
          anyOf:
            - type: string
            - type: 'null'
          title: Brand
        last4:
          anyOf:
            - type: string
            - type: 'null'
          title: Last4
      type: object
      required:
        - brand
        - last4
      title: PaymentMethodKrCardMetadata
  securitySchemes:
    customer_session:
      type: http
      description: >-
        Customer session tokens are specific tokens that are used to
        authenticate customers on your organization. You can create those
        sessions programmatically using the [Create Customer Session
        endpoint](/api-reference/customer-sessions/create-customer-session).
      scheme: bearer
    member_session:
      type: http
      description: >-
        Member session tokens are specific tokens that are used to authenticate
        members on your organization. You can create those sessions
        programmatically using the [Create Member Session
        endpoint](/api-reference/customer-sessions/create-customer-session).
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.