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

# Create PIX Withdrawal

> Creates a new PIX withdrawal by providing the PIX key and destination account holder details.

**Required permission:** `WITHDRAWAL:WRITE` or `FULL_ACCESS`

**IP restriction:** If the credential has an allowed IP list configured, requests from outside of it are rejected with `403`. Recommended for credentials with this permission.

> [!NOTE]
>
> **Asynchronous processing.** Withdrawal creation returns a non-terminal status (`pending` or `processing`) — the definitive outcome is always delivered via webhook (`withdrawal.completed` or `withdrawal.failed`). Treat the webhook as the source of truth; do not treat the creation response as the final result.
>
> Validation errors (insufficient balance, limit exceeded, invalid data) return an error in the call itself.

## Dispatch queue

Once accepted, the withdrawal enters a queue to be sent to the payment institution. Most of the time it is sent immediately; during volume peaks it can take from seconds to minutes, and the withdrawal stays in `processing` while it waits.

* **First come, first served.** Withdrawals are sent in the order they were created.
* **Nonexistent keys are expensive.** Every withdrawal looks up the destination PIX key in DICT, and the Central Bank limits those lookups — a lookup for a key that does not exist consumes far more of the limit than a successful one. When an account accumulates refusals for nonexistent or invalid keys, its next withdrawals lose priority in the queue and wait longer. Validate keys before sending and do not use withdrawals to test whether a key exists.
* **Key lookup block.** If the institution signals that the lookup limit has been reached, withdrawals not yet sent wait in the queue until it is lifted. Those already sent may come back as `withdrawal_failed`, with the amount returned to your balance.
* **Maximum wait.** A withdrawal that cannot be sent within 6 hours fails (`withdrawal_failed`) and the reserved amount returns to your balance.

In every case the outcome arrives by webhook.


## OpenAPI

````yaml openapi.en.json POST /withdrawals
openapi: 3.0.0
info:
  title: Tresor Global API
  description: Tresor Global Payment API documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://api.tresorglobal.net/v2
security: []
paths:
  /withdrawals:
    post:
      tags:
        - External API - Withdrawals (Saques)
      summary: Create a PIX withdrawal
      description: >-
        Creates a new PIX withdrawal by providing the PIX key and destination
        account holder details.


        **Required permission:** `WITHDRAWAL:WRITE` or `FULL_ACCESS`


        **IP restriction:** If the credential has an allowed IP list configured,
        requests from outside of it are rejected with `403`. Recommended for
        credentials with this permission.
      operationId: ExternalWithdrawalsController_create
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Unique client-provided key (8-255 chars) that makes the request
            idempotent. Retries with the same key return the cached response
            (24h TTL). The same key with a different body returns 422.
          schema:
            type: string
            minLength: 8
            maxLength: 255
        - $ref: '#/components/parameters/SubAccount'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateExternalWithdrawalInput'
      responses:
        '201':
          description: Withdrawal created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetExternalWithdrawalOutput'
        '400':
          description: Bad Request - Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestErrorResponse'
        '401':
          description: Unauthorized - Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorResponse'
        '403':
          description: Forbidden - Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorResponse'
        '404':
          description: Not Found - Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
      security:
        - bearerAuth: []
components:
  parameters:
    SubAccount:
      name: X-Sub-Account
      in: header
      required: false
      description: >-
        Reference of the sub-account the operation runs against. When omitted,
        the operation happens on the main account; the reserved value
        `principal` also resolves to the main account and is equivalent to
        omitting the header. Accepted on every endpoint except `POST /auth` and
        the `/sub-accounts` endpoints themselves, which always operate on the
        main account.


        Possible errors: `404 SUB_ACCOUNT_NOT_FOUND`, `403
        SUB_ACCOUNT_FORBIDDEN`, `403 SUB_ACCOUNT_SUSPENDED`.


        Requires the credential to have **sub-account access** enabled (Settings
        → Integration → API Credentials). It starts turned off and is not
        replaced by any permission, not even `FULL_ACCESS`: without it the
        response is `403 SUB_ACCOUNT_FORBIDDEN`.
      schema:
        type: string
        pattern: ^[a-z0-9][a-z0-9_-]{1,31}$
        example: loja-centro
  schemas:
    CreateExternalWithdrawalInput:
      type: object
      description: >-
        Data to create a PIX withdrawal. Provide **exactly one** of `amount`
        (gross amount debited from the balance) **or** `netAmount` (net amount
        the recipient should receive).
      properties:
        projectId:
          type: string
          description: >-
            ID of the project the withdrawal belongs to. If omitted, the
            withdrawal inherits the account's project when there is a single
            one; with multiple projects the withdrawal is created without a
            project — same behavior as PIX charge creation.
          format: uuid
          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
        amount:
          type: number
          minimum: 1
          description: >-
            **Gross** amount in BRL debited from the balance. The recipient
            receives `amount - feeAmount`. Minimum R$ 1.00. Provide `amount` OR
            `netAmount` — never both.
          example: 150.75
        netAmount:
          type: number
          minimum: 1
          description: >-
            **Net** amount in BRL the recipient should receive. The API computes
            the required gross (`gross = netAmount + feeAmount`) and debits that
            total from the balance. Minimum R$ 1.00. Provide `amount` OR
            `netAmount` — never both.
          example: 150
        pixKey:
          type: string
          description: Recipient's PIX key.
          example: '12345678901'
        pixKeyType:
          type: string
          enum:
            - cpf
            - cnpj
            - email
            - phone
            - random
          description: PIX key type.
          example: cpf
        holderName:
          type: string
          description: PIX account holder's name.
          example: João da Silva
        holderDocument:
          type: string
          description: Account holder's CPF or CNPJ.
          example: '12345678901'
        holderDocumentType:
          type: string
          enum:
            - cpf
            - cnpj
          description: Holder's document type.
          example: cpf
        externalReference:
          type: string
          maxLength: 255
          description: >-
            Your external reference ID (optional). It is returned in the
            response and in the `withdrawal_completed` and `withdrawal_failed`
            webhooks to make reconciliation with your internal systems easier.
          example: saque-empresa-001
      required:
        - pixKey
        - pixKeyType
        - holderName
        - holderDocument
        - holderDocumentType
    GetExternalWithdrawalOutput:
      type: object
      description: Details of the created withdrawal.
      properties:
        id:
          type: string
          format: uuid
          description: Withdrawal ID
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        projectId:
          type: string
          nullable: true
          description: >-
            Project ID of the withdrawal (null when not provided at creation and
            the account has 2+ projects)
          format: uuid
        amount:
          type: number
          description: Withdrawal amount in BRL
          example: 150.75
        feeAmount:
          type: number
          description: Fee amount in BRL
          example: 2.5
        netAmount:
          type: number
          description: Net amount in BRL
          example: 148.25
        status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
          description: Withdrawal status
          example: completed
        snapshotPixKey:
          type: string
          nullable: true
          description: PIX key used at the time of the withdrawal
          example: '12345678901'
        snapshotPixKeyType:
          type: string
          enum:
            - cpf
            - cnpj
            - email
            - phone
            - random
          nullable: true
          description: Type of the PIX key used at the time of the withdrawal
          example: cpf
        snapshotHolderName:
          type: string
          description: Holder's name at the time of the withdrawal
          example: João da Silva
        snapshotHolderDocument:
          type: string
          description: Holder's document at the time of the withdrawal
          example: '12345678901'
        failureReason:
          type: string
          nullable: true
          description: Failure reason (when status = failed)
          example: null
        pspReference:
          type: string
          nullable: true
          description: PSP (payment service provider) reference
          example: null
        createdAt:
          type: string
          format: date-time
          description: Creation date
          example: '2026-02-10T14:30:00.000Z'
        processedAt:
          type: string
          format: date-time
          nullable: true
          description: Processing date
          example: '2026-02-10T14:30:01.000Z'
        externalReference:
          type: string
          nullable: true
          description: >-
            Your external reference sent when the withdrawal was created
            (optional)
          example: saque-empresa-001
      required:
        - id
        - amount
        - feeAmount
        - netAmount
        - status
        - snapshotHolderName
        - snapshotHolderDocument
        - createdAt
    BadRequestErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 400
        error:
          type: string
          example: BadRequest
        message:
          type: string
          example: name must be longer than or equal to 2 characters
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    UnauthorizedErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 401
        error:
          type: string
          example: Unauthorized
        message:
          type: string
          example: Authentication token is required
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    ForbiddenErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 403
        error:
          type: string
          example: Forbidden
        message:
          type: string
          example: You do not have permission to access this resource
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    NotFoundErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 404
        error:
          type: string
          example: NotFound
        message:
          type: string
          example: Resource with id 550e8400-e29b-41d4-a716-446655440000 not found
        details:
          type: object
          example:
            resource: Example
            id: 550e8400-e29b-41d4-a716-446655440000
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
      required:
        - statusCode
        - error
        - message
        - timestamp
    InternalServerErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          example: 500
        error:
          type: string
          example: InternalError
        message:
          type: string
          example: An unexpected error occurred
        details:
          type: object
        timestamp:
          type: string
          example: '2025-12-15T22:00:00.000Z'
        traceId:
          type: string
          example: 2771463d58840c8e116dc6dda1e1e5d0
      required:
        - statusCode
        - error
        - message
        - timestamp
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Access token obtained from POST /auth (client_id + client_secret). Valid
        for 300 seconds.

````

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