> ## 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 S2S Setup Method

> Create a new setup method for storing payment methods server to server

<Note>
  This endpoint is currently only available for card payments

  * Use this endpoint when you already gathered card details and consent within your PCI DSS compliant environment
  * You must obtain explicit approval from <a href="mailto:hello@xpaycheckout.com">[hello@xpaycheckout.com](mailto:hello@xpaycheckout.com)</a> before using this API
</Note>


## OpenAPI

````yaml POST /setup-method/s2s/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/s2s/create:
    post:
      description: Create a new setup method for storing payment methods server to server
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        description: Create S2S Setup Method
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create-s2s-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-s2s-setup-method:
      required:
        - currency
        - cardDetails
        - billingDetails
        - callbackUrl
      type: object
      properties:
        currency:
          type: string
          description: >-
            Three letter abbreviation of the currency. Refer [supported
            currencies](/get-started/currencies-supported)
          example: USD
        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).


            ⚠️ Please note: Provide either `customerReferenceId` or this field,
            not both, as they are mutually exclusive.
        customerReferenceId:
          allOf:
            - $ref: '#/components/schemas/CustomerReferenceId'
          description: >-
            Your unique identifier for the customer.


            ⚠️ Please note: Provide either `customerId` or this field, not both,
            as they are mutually exclusive.
        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
        phoneNumberRequired:
          type: boolean
          description: >-
            Flag to indicate whether phone number is required from the customer
            during checkout. By default, this is false.
          example: false
        cardDetails:
          $ref: '#/components/schemas/CardDetails'
        amount:
          type: integer
          format: int64
          description: >-
            The amount to charge immediately while setting up the payment method
            token. The amount in lowest count unit e.g.: For USD 1, amount is
            100 representing 100 cents. Should be greater than 0.
          example: 100
        receiptId:
          type: string
          description: >-
            Your identifier of the order. This will be persisted in the intent
            created while setting up the payment method token.
          example: order123
        metadata:
          type: object
          description: >-
            A collection of key-value pairs that can be attached to an object
            for storing additional structured information.


            Constraints:

            - Maximum of 50 key-value pairs allowed.

            - Each key must be no longer than 40 characters.

            - Each value must be a string and cannot exceed 500 characters.
          additionalProperties:
            type: string
          example:
            orderId: '12345'
            customerNote: Setup for recurring payments
    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
    CustomerReferenceId:
      type: string
      description: >-
        Your unique identifier for the customer. This can be used to associate
        the payment with a specific customer in your system.
      example: eTfd3Jq1tZxPjYVhRQW2r3
    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'
    CardDetails:
      description: Payment card information collected by you
      type: object
      properties:
        cardHolderName:
          type: string
          description: Name of the cardholder
          example: John Doe
        cardNumber:
          type: string
          description: Full Primary Account Number (PAN)
          example: '4000002500000003'
        expiryMonth:
          type: integer
          minimum: 1
          maximum: 12
          description: Card expiry month in MM format
          example: 1
        expiryYear:
          type: integer
          description: Card expiry year in YY format
          example: 28
        cvv:
          type: string
          description: Card security code (CVV/CSC).
          example: '123'
        country:
          type: string
          description: >-
            Two-letter country code ([ISO 3166-1
            alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)) of the
            country where the card is registered.
          example: US
        postalCode:
          type: string
          description: Postal code of the location where the card is registered.
          example: '2424'
      required:
        - cardNumber
        - expiryMonth
        - expiryYear
        - cvv
    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

````