Astron PayAstron Pay

Integration

How to integrate with Astron Pay

From the first request to the first production payment in just a few REST calls. Here is the end-to-end flow.

How to integrate with Astron Pay

The flow in 4 steps

  1. 1

    Create your account and get your keys

    Create the account, finish onboarding and generate your credential pair (x-api-key and x-api-secret). Every API call uses these two headers. Start in the sandbox, isolated from production.

  2. 2

    Request a quote

    Before each order you request a quote and receive the exact conversion amount, locked for 30 seconds. That way the price does not change mid-way.

    curl -X POST https://api.astronpay.co/api/v1/quote/payin \
      -H "x-api-key: $API_KEY" \
      -H "x-api-secret: $API_SECRET" \
      -H "Content-Type: application/json" \
      -d '{
        "receiverId": "rcv_01hxy...",
        "amountBrl": 1000,
        "targetToken": "USDC"
      }'
    
    # 200 OK — cotação travada por 30s
    {
      "quoteId": "qt_01hxy...",
      "amountBrl": 1000,
      "amountToken": "195.69",
      "targetToken": "USDC",
      "expiresAt": "2026-04-17T18:30:30Z"
    }
  3. 3

    Create the payment order

    With the quote in hand, create the payin order. The response includes the PIX code (copy-paste / QR) for the payer. Cash-out (payout) follows the same pattern to pay any key.

    curl -X POST https://api.astronpay.co/api/v1/payin \
      -H "x-api-key: $API_KEY" \
      -H "x-api-secret: $API_SECRET" \
      -H "Content-Type: application/json" \
      -d '{
        "receiverId": "rcv_01hxy...",
        "quoteId": "qt_01hxy...",
        "destinationWallet": "4k5dSo1EnderecoSolana..."
      }'
    
    # 201 Created
    {
      "id": "ord_01hxy...",
      "type": "PAYIN",
      "status": "AWAITING_PAYMENT",
      "amountBrl": 1000,
      "targetToken": "USDC",
      "pixPaymentCode": "00020126..."
    }
  4. 4

    Get confirmation via webhook

    Astron calls your URL on every status change — paid, completed, failed, refunded. This is how your application knows the result in real time, without polling the API.

    // A Astron Pay chama a sua URL a cada mudança de status.
    POST https://sua-api.com/webhooks/astronpay
    
    {
      "event": "order.completed",
      "data": {
        "id": "ord_01hxy...",
        "type": "PAYIN",
        "status": "COMPLETED",
        "amountBrl": 1000,
        "amountToken": "195.69",
        "targetToken": "USDC"
      }
    }

Ready for the details?

The documentation covers every endpoint, field and response, plus an unlimited sandbox with ready-made examples.