---
title: "Creates a dynamic Pix: JSON with `oferta` (`pacote` with `usd`, or `saldo` with `centavos`) and the payer."
method: POST
path: "/api/credito/asaas"
---

# Creates a dynamic Pix: JSON with \`oferta\` (\`pacote\` with \`usd\`, or \`saldo\` with \`centavos\`) and the payer.

`POST /api/credito/asaas`

## Request

- Base URL: `https://okfindex.com`
- URL: `https://okfindex.com/api/credito/asaas`
- Auth: none declared

The payment releases what was bought by itself: the pack becomes the `cred_…` token already in the response; the balance goes to the logged-in account's organization. The first purchase needs `documento` (CPF or CNPJ, sent to the gateway and not stored here) and `nome`; `email`, `pagina` and `navegador_id` are optional. With `forma: "cartao_boleto"` the charge is open: the response brings `pagamento_em`, the gateway page where you pay by card, boleto or Pix (due in three days). With `forma: "cartao"` and `cartao` (`titular`, `numero`, `mes`, `ano`, `cvv`, `documento`, `email`, `cep`, `numero_endereco`, `telefone`), the charge is paid by card in the same request: 200 with `estado: "pago"`, 202 with `conferir` while the issuer reviews it, 422 when the card is declined; the card is not stored. Set `usd` to an amount from `pacotes` or `exatos` in the GET response. The server sets the amount in cents and rejects amounts that the app has not declared.
Returns: { id, credito, forma, pix, pagamento_em, estado, estado_em, cancelamento }

## Response `200`

{ id, credito, forma, pix, pagamento_em, estado, estado_em, cancelamento }

- object
  - `id` string, required: Charge id, to follow up.
  - `credito` string, required: For a pack: the `cred_…` token, shown ONCE; valid when the payment arrives.
  - `forma` string, required: `pix` (the default), `cartao` or `cartao_boleto`.
  - `pix` object, required: `copia_e_cola`, `imagem` (PNG QR, data URI) and `expira_em`; `pix` form only.
  - `pagamento_em` string, required: In the `cartao_boleto` form: the gateway payment page.
  - `estado` string, required: In the `cartao` form: `pago`, or `pendente` with `conferir`.
  - `estado_em` string, required: Where to follow the payment.
  - `cancelamento` string, required: Capability to cancel a pending Pix or boleto charge.

## Other responses

- `400`: Credit amount outside `pacotes` and `exatos`, amount out of range, invalid CPF/CNPJ, name or e-mail, invalid card data (`cartao_dados`, with the `campo`), or the gateway refused the payer (`pagador_recusado`, with the reason in `detalhe`).
- `422`: Card declined (`cartao_recusado`, with the `campo` when the gateway says which); try another card with `POST /api/credito/asaas/:id/cartao`.
- `429`: Limit of 3 attempts per minute or 10 per day, per account or network, or the card limit.
- `502`: The gateway did not create the Pix; try again.
- `503`: Automatic Pix unavailable in this app, the gateway is busy (`asaas_ocupado`, wait `retry_after_s`), or too many charges from people not signed in waiting for payment.

---

[API](https://skmtc.dev/okfindex/apis/okf-index.md) · [All operations](https://skmtc.dev/okfindex/apis/okf-index/llms.txt) · [OpenAPI document](https://skmtc.dev/okfindex/apis/okf-index/revisions/4b13ca3c739f?raw)
