> ## 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 withdrawal

> Create a PIX withdrawal to transfer BRL funds from your YuvexPay balance. Requires an idempotency key.

The PIX key type (CPF, CNPJ, e-mail, phone, or random key) is detected automatically from `destination.pixKey` — you do not need to declare it. Invalid keys are rejected with `INVALID_PIX_KEY`.

The creditor document on the network is always derived server-side from your verified company tax id (CNPJ for business accounts, owner CPF for individual accounts).

Withdrawals may be blocked outside business hours or if your account has restrictions.



## OpenAPI

````yaml POST /v1/withdrawals
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/withdrawals:
    post:
      tags:
        - Withdrawals
      summary: Create a withdrawal
      description: >-
        Create a PIX withdrawal to transfer BRL funds from your YuvexPay
        balance. Requires an idempotency key.


        The PIX key type (CPF, CNPJ, e-mail, phone, or random key) is detected
        automatically from `destination.pixKey` — you do not need to declare it.
        Invalid keys are rejected with `INVALID_PIX_KEY`.


        The creditor document on the network is always derived server-side from
        your verified company tax id (CNPJ for business accounts, owner CPF for
        individual accounts).


        Withdrawals may be blocked outside business hours or if your account has
        restrictions.
      operationId: createWithdrawal
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWithdrawalRequest'
            examples:
              pix:
                summary: PIX withdrawal
                value:
                  amount: 500
                  method: PIX
                  currency: BRL
                  destination:
                    type: pix
                    pixKey: ana@example.com
                  description: Weekly payout
      responses:
        '201':
          description: Withdrawal created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  withdrawal:
                    $ref: '#/components/schemas/Withdrawal'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Withdrawals blocked for this account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
        '429':
          $ref: '#/components/responses/RateLimited'
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:
    CreateWithdrawalRequest:
      type: object
      required:
        - amount
        - destination
      properties:
        amount:
          type: number
          minimum: 10
          maximum: 1000000
          multipleOf: 0.01
          description: Withdrawal amount (minimum R$10.00).
        method:
          type: string
          enum:
            - PIX
          default: PIX
          description: Public withdrawals currently support PIX only.
        currency:
          type: string
          enum:
            - BRL
          default: BRL
        destination:
          description: Where to send the funds.
          type: object
          title: PIX destination
          required:
            - type
            - pixKey
          properties:
            type:
              type: string
              enum:
                - pix
            pixKey:
              type: string
              minLength: 1
              description: >-
                PIX key. Accepts CPF, CNPJ, e-mail, Brazilian phone
                (`+55XXXXXXXXXXX`), or a random EVP/UUID. The type is detected
                automatically; you do not need to send `pixKeyType`. Whitespace
                and punctuation are stripped server-side.
        description:
          type: string
          maxLength: 500
          description: Internal description for this withdrawal.
    Withdrawal:
      type: object
      properties:
        id:
          type: string
          format: uuid
        txId:
          type: string
        grossAmount:
          type: number
        feeAmount:
          type: number
        netAmount:
          type: number
        pixKey:
          type: string
          description: >-
            The destination PIX key, masked. The full key is never returned by
            the API once the withdrawal is created.
        pixKeyType:
          type: string
          description: Type of PIX key (CPF, CNPJ, EMAIL, PHONE, RANDOM).
        status:
          $ref: '#/components/schemas/WithdrawalStatus'
        isSandbox:
          type: boolean
        createdAt:
          type: string
          format: date-time
        paymentMethod:
          type: string
          enum:
            - PIX
        currency:
          type: string
          enum:
            - BRL
        processedAt:
          type: string
          format: date-time
          nullable: true
        errorMessage:
          type: string
          nullable: true
          description: >-
            Human-readable failure message. Treat as opaque text and surface
            only to internal operators.
    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.
    WithdrawalStatus:
      type: string
      enum:
        - PENDING
        - PROCESSING
        - COMPLETED
        - FAILED
        - CANCELLED
      description: Possible withdrawal statuses.
  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
    RateLimited:
      description: Rate limit exceeded.
      headers:
        X-RateLimit-Limit:
          schema:
            type: integer
          description: Request limit per window.
        X-RateLimit-Remaining:
          schema:
            type: integer
          description: Remaining requests in window.
        X-RateLimit-Reset:
          schema:
            type: integer
          description: Seconds until the window resets.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: RATE_LIMIT_EXCEEDED
              message: Too many requests
  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**.

````