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

# Create Payment Method

> Create a vaultable payment method. In production, clients should use a frontend tokenization flow (PCI scope reduction).



## OpenAPI

````yaml POST /payment_methods
openapi: 3.1.0
info:
  title: Xerobi Payment API
  version: '2026-01-01'
  description: >-
    A developer-first REST API for a modern payment gateway. Focused on
    predictable semantics, idempotency, clear errors, and observability. Use
    `Authorization: Bearer <sk_...>` for requests. All amounts are smallest
    currency unit (e.g. paisa for BDT).
  termsOfService: https://api.hixbe.com/terms
  contact:
    name: Xerobi Developer Support
    url: https://developer.hixbe.com
    email: support@xerobi.com
  license:
    name: Proprietary
    url: https://hixbe.com/license
servers:
  - url: https://sandbox.api.hixbe.com/payment
    description: Sandbox (test)
  - url: https://api.hixbe.com/payment
    description: Production
security:
  - bearerAuth: []
tags:
  - name: PaymentIntents
    description: Orchestrate payments (recommended pattern)
  - name: PaymentMethods
    description: Create and manage payment methods / tokens
  - name: Customers
    description: Customer objects and stored methods
  - name: Refunds
    description: Issue partial/full refunds
  - name: Webhooks
    description: Register webhook endpoints and view events
  - name: Observability
    description: Request debugging and headers
externalDocs:
  description: Developer guides & examples
  url: https://developer.hixbe.com/docs
paths:
  /payment_methods:
    post:
      tags:
        - PaymentMethods
      summary: Create a Payment Method (tokenize)
      description: >-
        Create a vaultable payment method. In production, clients should use a
        frontend tokenization flow (PCI scope reduction).
      operationId: createPaymentMethod
      parameters:
        - $ref: '#/components/parameters/Xerobi-Version'
        - $ref: '#/components/parameters/X-Request-Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - card
                      default: card
                    card:
                      type: object
                      properties:
                        number:
                          type: string
                          description: PAN - use tokenization from clients
                        exp_month:
                          type: integer
                        exp_year:
                          type: integer
                        cvc:
                          type: string
                      required:
                        - number
                        - exp_month
                        - exp_year
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - bank_transfer
                        - wallet
                    details:
                      type: object
                      description: method specific details
            example:
              type: card
              card:
                number: '4242424242424242'
                exp_month: 12
                exp_year: 2027
                cvc: '123'
      responses:
        '201':
          description: PaymentMethod created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethod'
        '400':
          $ref: '#/components/responses/GenericError'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  parameters:
    Xerobi-Version:
      name: Xerobi-Version
      in: header
      description: API version header. Use '2026-01-01' for the latest version.
      required: true
      schema:
        type: string
        default: '2026-01-01'
    X-Request-Id:
      name: X-Request-Id
      in: header
      description: Optional client-provided request id for tracing.
      required: false
      schema:
        type: string
  schemas:
    PaymentMethod:
      type: object
      properties:
        id:
          type: string
          example: pm_card_123
        type:
          type: string
          example: card
        card:
          type: object
          properties:
            brand:
              type: string
              example: visa
            last4:
              type: string
              example: '4242'
            exp_month:
              type: integer
              example: 12
            exp_year:
              type: integer
              example: 2027
        created_at:
          type: string
          format: date-time
        customer:
          type: string
          nullable: true
      required:
        - id
        - type
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              description: >-
                category (invalid_request, auth_error, processing_error,
                rate_limit, internal_error)
            code:
              type: string
              description: machine-friendly error code
            message:
              type: string
              description: human-friendly message
            param:
              type: string
              nullable: true
              description: request parameter related to the error, if any
            request_id:
              type: string
              description: gateway generated request id for debugging
          required:
            - type
            - code
            - message
  responses:
    GenericError:
      description: Standard error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Use your secret API key. Example: `Authorization: Bearer sk_test_xxx`'

````

## Related topics

- [Payment API FAQ](https://docs.xerobi.com/faq-guides/payment-api-faq.md)
- [Create Payment Intent](https://docs.xerobi.com/payment-api/endpoint/create-payment-intent.md)
- [Xerobi Payment API Introduction](https://docs.xerobi.com/payment-api/introduction.md)
- [Retrieve Payment Method](https://docs.xerobi.com/payment-api/endpoint/retrieve-payment-method.md)
- [Attach Payment Method to Payment Intent](https://docs.xerobi.com/payment-api/endpoint/attach-payment-method-to-intent.md)


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