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

# Create a customer

> Create a new customer record. Customers can be associated with payments for tracking and recurring billing.



## OpenAPI

````yaml POST /v1/customers
openapi: 3.1.0
info:
  title: YuvexPay API
  description: >-
    The YuvexPay API allows you to accept payments, process withdrawals, manage
    products and customers programmatically. All API access is over HTTPS and
    uses JSON request/response bodies.
  version: 1.0.0
  contact:
    name: YuvexPay Support
    email: support@yuvexpay.com
    url: https://docs.yuvexpay.com
servers:
  - url: https://api.yuvexpay.com
    description: >-
      Same base URL serves both sandbox and production. Send a `ypk_test_*` key
      for sandbox or a `ypk_live_*` key for production.
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Inspect the API key in use
  - name: Payments
    description: Create and manage payments
  - name: Withdrawals
    description: Create and manage withdrawals
  - name: Products
    description: Manage product catalog
  - name: Customers
    description: Manage customer records
  - name: Documents
    description: Generate receipts and statements
  - name: Balance
    description: Inspect the current account balance
paths:
  /v1/customers:
    post:
      tags:
        - Customers
      summary: Create a customer
      description: >-
        Create a new customer record. Customers can be associated with payments
        for tracking and recurring billing.
      operationId: createCustomer
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCustomerRequest'
            example:
              name: Pedro Álvares Cabral
              email: user@example.com
              document: '12345678900'
              documentType: CPF
              phone: '+5511999999999'
              externalId: cust-001
              metadata:
                plan: premium
      responses:
        '201':
          description: Customer created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  customer:
                    $ref: '#/components/schemas/Customer'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
components:
  parameters:
    IdempotencyKey:
      name: X-Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        maxLength: 100
      description: >-
        A unique string to ensure the request is processed only once. Must be
        unique per request. Valid for 24 hours.
  schemas:
    CreateCustomerRequest:
      type: object
      properties:
        externalId:
          type: string
          maxLength: 100
          description: Your own customer ID.
        name:
          type: string
          minLength: 1
          maxLength: 200
        email:
          type: string
          format: email
          maxLength: 255
        document:
          type: string
          maxLength: 20
          description: CPF or CNPJ number.
        documentType:
          type: string
          enum:
            - CPF
            - CNPJ
        phone:
          type: string
          maxLength: 20
        metadata:
          type: object
          additionalProperties:
            type: string
    Customer:
      type: object
      properties:
        customerId:
          type: string
          description: >-
            Merchant-facing customer slug (e.g., `cus_ab12cd34ef`). Use this as
            the `{customerId}` path parameter in subsequent calls.
        name:
          type: string
        email:
          type: string
        document:
          type: string
        phone:
          type: string
        externalId:
          type: string
        isActive:
          type: boolean
        createdAt:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code.
            message:
              type: string
              description: Human-readable error message.
            details:
              type: object
              description: Additional error context.
  responses:
    ValidationError:
      description: Validation error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: VALIDATION_ERROR
              message: Invalid request body
              details:
                amount: Must be greater than 0.01
    Unauthorized:
      description: Missing or invalid authentication token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: INVALID_API_KEY
              message: Invalid or revoked API key
    IdempotencyConflict:
      description: Idempotency conflict. The key was already used with a different payload.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: IDEMPOTENCY_PAYLOAD_MISMATCH
              message: Idempotency key already used with a different request body
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        YuvexPay API key. Include as `Authorization: Bearer
        ypk_<env>_<kid>_<secret>` where `<env>` is `test` (sandbox) or `live`
        (production). Create and manage keys in the dashboard under **Settings >
        API Keys**.

````