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

# Cria ordem de payout

> Cria uma ordem de saída (crypto → BRL). Requer `quoteId` de `/quote/payout` não expirado. Após o receiver depositar o crypto no endereço fornecido (campo `depositAddress` na ordem), a plataforma executa a conversão e envia PIX para a chave configurada.



## OpenAPI

````yaml POST /payout
openapi: 3.1.0
info:
  title: Astron Pay API
  version: 1.0.0
  description: >-
    API B2B para integração de câmbio crypto ↔ BRL via PIX. Autentique com
    `x-api-key` + `x-api-secret`.
  contact:
    name: Astron Pay
    url: https://astronpay.co
    email: dev@astronpay.co
servers:
  - url: https://api.astronpay.co/api/v1
    description: Production
security:
  - apiKey: []
    apiSecret: []
  - bearerAuth: []
tags:
  - name: Fee Tiers
    description: Consulta e atualização das taxas do merchant.
  - name: Receivers
    description: CRUD, KYC, limites e wallet signing dos receivers.
  - name: Quote
    description: Cotações de payin e payout.
  - name: Payin
    description: Ordens de entrada (BRL → crypto).
  - name: Payout
    description: Ordens de saída (crypto → BRL).
  - name: Orders
    description: Consulta genérica de ordens.
  - name: Merchant Wallet
    description: Assinatura de transações com a wallet gerenciada do merchant.
  - name: Ledger
    description: Saldos, entries e liquidações.
  - name: Webhook Config
    description: Configuração de webhook e listagem de eventos.
paths:
  /payout:
    post:
      tags:
        - Payout
      summary: Cria ordem de payout
      description: >-
        Cria uma ordem de saída (crypto → BRL). Requer `quoteId` de
        `/quote/payout` não expirado. Após o receiver depositar o crypto no
        endereço fornecido (campo `depositAddress` na ordem), a plataforma
        executa a conversão e envia PIX para a chave configurada.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - receiverId
                - quoteId
                - amountCrypto
                - pixKey
                - pixKeyType
                - recipientName
                - recipientDocument
              properties:
                receiverId:
                  type: string
                  format: uuid
                quoteId:
                  type: string
                  format: uuid
                amountCrypto:
                  type: number
                  description: Quantidade de crypto a depositar (positivo).
                  example: 10.5
                sourceToken:
                  type: string
                  enum:
                    - USDC
                    - SOL
                  default: USDC
                  description: Token a converter para BRL.
                pixKey:
                  type: string
                  description: Chave PIX do destinatário.
                pixKeyType:
                  type: string
                  enum:
                    - CPF
                    - CNPJ
                    - PHONE
                    - EMAIL
                    - RANDOM
                    - QRCODE
                  description: Tipo da chave PIX.
                recipientName:
                  type: string
                  description: Nome completo do destinatário.
                recipientDocument:
                  type: string
                  description: CPF ou CNPJ do destinatário (11–18 chars).
                externalId:
                  type: string
                  maxLength: 255
                  description: ID opcional do merchant para rastreamento.
      responses:
        '201':
          description: >-
            Criado — o campo `depositAddress` na ordem indica o endereço Solana
            para depósito do crypto.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '400':
          description: Inputs inválidos ou quote expirado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Receiver fora dos limites, não aprovado, ou chave PIX inválida
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Order:
      type: object
      required:
        - id
        - merchantId
        - receiverId
        - type
        - status
        - chain
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
        externalId:
          type: string
          nullable: true
          description: ID do merchant para rastreamento interno.
        merchantId:
          type: string
          format: uuid
        receiverId:
          type: string
          format: uuid
        receiverName:
          type: string
          nullable: true
        merchantName:
          type: string
          nullable: true
        type:
          type: string
          enum:
            - PAYIN
            - PAYOUT
        status:
          type: string
          enum:
            - PENDING
            - AWAITING_PAYMENT
            - PAYMENT_RECEIVED
            - SWAPPING
            - TRANSFERRING
            - AWAITING_DEPOSIT
            - DEPOSIT_RECEIVED
            - PIX_SENDING
            - PIX_SENT_UNCONFIRMED
            - COMPLETED
            - FAILED
            - EXPIRED
            - REFUNDING
            - REFUNDED
        chain:
          type: string
          example: solana
        amountBrl:
          type: number
          nullable: true
          example: 1000
        amountCrypto:
          type: number
          nullable: true
          example: 199.5
        targetToken:
          type: string
          nullable: true
          description: 'Payin only. Token que o receiver recebe (ex: USDC).'
          example: USDC
        sourceToken:
          type: string
          nullable: true
          description: 'Payout only. Token que o receiver envia (ex: USDC).'
          example: USDC
        destinationWallet:
          type: string
          nullable: true
          description: Payin only. Endereço Solana onde o crypto é entregue.
          example: 4k5dSo1EnderecoSolana...
        depositAddress:
          type: string
          nullable: true
          description: >-
            Payout only. Endereço Solana para onde o receiver deve enviar o
            crypto.
          example: 7xMnSo2EnderecoDeposito...
        paymentReference:
          type: string
          nullable: true
          description: >-
            Payout only. PublicKey Solana **não custodial** (sem chave privada,
            sem saldo) usada como reference no padrão Solana Pay para
            correlacionar o depósito on-chain a esta order. Inclua essa pubkey
            como account read-only e não-signer na sua transação SPL Transfer —
            sem isso, a plataforma não consegue identificar que o depósito
            pertence a este payout e a order expira em `AWAITING_DEPOSIT`.
        exchangeRate:
          type: number
          nullable: true
          description: Taxa de câmbio utilizada na ordem (BRL/token).
          example: 5.01
        feePercentage:
          type: number
          nullable: true
          description: Percentual total de taxa aplicado.
          example: 2.5
        netAmountBrl:
          type: number
          nullable: true
          description: Valor BRL líquido após taxas.
          example: 975
        amountUsdc:
          type: number
          nullable: true
          example: 194.61
        amountToken:
          type: number
          nullable: true
          description: Quantidade final do token entregue.
          example: 194.61
        platformFeePercentage:
          type: number
          nullable: true
          example: 1.5
        platformFeeAmountBrl:
          type: number
          nullable: true
          example: 15
        merchantFeePercentage:
          type: number
          nullable: true
          example: 1
        merchantFeeAmountBrl:
          type: number
          nullable: true
          example: 10
        pixPaymentCode:
          type: string
          nullable: true
          description: Payin only. Código EMV copia-e-cola do PIX.
          example: 00020126...
        pixKey:
          type: string
          nullable: true
          description: Payout only. Chave PIX do destinatário.
        pixKeyType:
          type: string
          nullable: true
          enum:
            - CPF
            - CNPJ
            - PHONE
            - EMAIL
            - RANDOM
            - QRCODE
          description: Payout only. Tipo da chave PIX.
        recipientName:
          type: string
          nullable: true
          description: Payout only. Nome do destinatário no PIX.
        failureReason:
          type: string
          nullable: true
          description: Motivo da falha, preenchido quando status=FAILED.
        expiresAt:
          type: string
          format: date-time
          nullable: true
        completedAt:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/Transaction'
          description: Transações associadas à ordem (on-chain e PIX).
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
          example: VALIDATION_ERROR
        message:
          type: string
          example: Campo 'amountBrl' é obrigatório
        details:
          type: object
          additionalProperties: true
        requestId:
          type: string
          example: req_abc123
    Transaction:
      type: object
      required:
        - id
        - type
        - status
        - amount
        - currency
        - createdAt
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          description: 'Tipo da transação (ex: PIX_IN, SWAP, TRANSFER_OUT).'
        status:
          type: string
          description: Status da transação.
        chain:
          type: string
          nullable: true
          example: solana
        amount:
          type: number
          example: 199.5
        currency:
          type: string
          example: USDC
        txHash:
          type: string
          nullable: true
          description: Hash on-chain da transação, quando aplicável.
        createdAt:
          type: string
          format: date-time
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
    apiSecret:
      type: apiKey
      in: header
      name: x-api-secret
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````