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

# Create Setup Method

> Create a new setup method for storing payment methods



## OpenAPI

````yaml POST /setup-method/create
openapi: 3.0.1
info:
  title: xPay API Store
  description: ''
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.xpaycheckout.com
security:
  - basicAuth: []
paths:
  /setup-method/create:
    post:
      description: Create a new setup method for storing payment methods
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        description: Create Setup Method
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create-setup-method'
        required: true
      responses:
        '200':
          description: Setup Method created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/create-setup-method-response'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        maxLength: 255
        pattern: ^[a-zA-Z0-9\-_:\.]+$
      description: >-
        A unique key for making the request idempotent. Must match pattern:
        `^[a-zA-Z0-9\-_:\.]+$`. See [Idempotent
        Requests](/developer-resources/idempotency) for more details.
      example: KG5LxwFBepaKHyUD
  schemas:
    create-setup-method:
      required:
        - currency
        - callbackUrl
        - billingDetails
      type: object
      properties:
        currency:
          type: string
          description: >-
            Three letter abbreviation of the currency. Refer [supported
            currencies](/get-started/currencies-supported)
          example: USD
        paymentMethods:
          type: array
          items:
            type: string
          description: >-
            List of payment methods to be enabled for setup. [supported payment
            methods](/get-started/payment-methods-supported#payment-method-enums)


            💡 If a selected payment method is unavailable, the system will
            automatically fallback to card payments to ensure a smooth checkout
            experience.
          example:
            - CARD
            - GOOGLE_PAY
            - APPLE_PAY
        customerId:
          allOf:
            - $ref: '#/components/schemas/CustomerId'
          description: >-
            The unique identifier for the customer, generated via the
            [create-customer
            API](/developer-resources/endpoints/customer/create-customer).
        billingDetails:
          allOf:
            - $ref: '#/components/schemas/BillingDetails'
          description: Billing details for the customer.
        storeFrontId:
          type: string
          description: The unique identifier for your storefront
          example: sf_sK8d3Jq1tZxPjYVhRQW2rf
        callbackUrl:
          type: string
          description: The URL we will callback to once the setup is complete
          example: https://example.com/callback
        metadata:
          type: object
          description: >-
            A collection of key-value pairs that can be attached to an object
            for storing additional structured information
          additionalProperties:
            type: string
          example:
            orderId: '12345'
            customerNote: Setup for recurring payments
        phoneNumberRequired:
          type: boolean
          description: >-
            Flag to indicate whether phone number is required from the customer
            during checkout. By default, this is false.
          example: false
    create-setup-method-response:
      type: object
      properties:
        setupMethodId:
          type: string
          description: Unique identifier of the setup method
          example: sm_sK8d3Jq1tZxPjYVhRQW2rf
        fwdUrl:
          type: string
          description: The URL to redirect the customer to complete the setup
          example: >-
            https://pay.xpaycheckout.com/setup-method?id=sm_sK8d3Jq1tZxPjYVhRQW2rf&secret=4b5PyxKSOuunnnFruohoiF
    Error:
      required:
        - errorCode
        - errorDescription
      type: object
      properties:
        errorCode:
          type: string
          example: bad_request
        errorDescription:
          type: string
          example: Failed to read request
    CustomerId:
      type: string
      description: >-
        The unique identifier for the customer, generated via the
        [create-customer
        API](/developer-resources/endpoints/customer/create-customer). This can
        be used to associate the payment with a specific customer in your
        system.
      example: cus_Tfd3Jq1tZxPjYVhRQW2r3
    BillingDetails:
      type: object
      description: Billing details for the customer.
      required:
        - name
        - email
        - contactNumber
      properties:
        name:
          type: string
          description: Customer's name
          example: John Doe
        email:
          type: string
          description: Customer's email address
          example: john.doe@example.com
        contactNumber:
          type: string
          description: >-
            Customer's contact number ([E.164
            format](https://en.wikipedia.org/wiki/E.164)), including the country
            code (e.g., +1 for US, +44 for UK, +91 for India).
          example: '+919123456789'
        customerAddress:
          $ref: '#/components/schemas/CustomerAddress'
    CustomerAddress:
      type: object
      properties:
        addressLine1:
          type: string
          description: Line 1 of the customer's address
          example: 123 Main St
        addressLine2:
          type: string
          description: Line 2 of the customer's address
          example: Apt 1
        city:
          type: string
          description: City of the customer's address
          example: New York
        state:
          type: string
          description: State of the customer's address
          example: NY
        country:
          type: string
          description: >-
            Two-letter country code ([ISO 3166-1
            alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
          example: US
        postalCode:
          type: string
          description: Postal code
          example: '2424'
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````