Referência da API
Criar cobrança
POST /v1/charges
POST /v1/chargesCria uma cobrança avulsa e devolve uma checkoutUrl para o cliente pagar.
Autenticação: Authorization: Bearer <api_key>
Corpo (JSON)
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
currency | string | sim | ISO 4217, 3 letras (usd, brl). |
items[] | array | —¹ | { name: string, quantity: int, unitAmountInCents: int }. |
amountInCents | integer | —¹ | Total em centavos. Use quando não enviar items. |
customer | object | — | { email?: string, name?: string }. |
description | string | — | Até 255 caracteres. |
metadata | object | — | Pares chave/valor. Retornam nos webhooks. |
postbackUrl | string | — | URL (https) para os webhooks desta cobrança. |
successUrl | string | — | Redirecionamento após o pagamento. |
cancelUrl | string | — | Redirecionamento ao cancelar. |
¹ Envie items ou amountInCents (pelo menos um, com total > 0).
Resposta 201
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Id da cobrança (chg_…). |
status | string | pending na criação. |
amountInCents | integer | Total calculado. |
currency | string | Moeda. |
items | array | Itens enviados. |
checkoutUrl | string | URL do checkout — leve o cliente até ela. |
postbackSecret | string | Só aqui. Valida os webhooks do postbackUrl. |
metadata | object | Sua metadata. |
Erros
{ "error": { "type": "invalid_request", "message": "Informe `items` ou um `amountInCents` maior que zero.", "param": "items" } }{ "error": { "type": "authentication", "message": "Chave de API inválida." } }
