Cobranças Pix
Uma cobrança gera um QR Code dinâmico (copia e cola em copyPaste). Use expiresIn para cobrança imediata ou dueAt para cobrança com vencimento. Quando o pagador paga, a cobrança vira paid e você recebe charge.paid (a cobrança) e pix.in.received (o dinheiro que entrou, com chargeId). Cobranças vencidas mudam para expired automaticamente e disparam charge.expired.
Criar uma cobrança
https://api.onzepay.com/v1/chargesCria a cobrança e devolve o QR Code. Informe expiresIn ou dueAt, nunca os dois.
Corpo
amountintegerobrigatório- Valor em centavos.
3000= R$ 30,00. descriptionstring- Texto exibido ao pagador.
externalIdstring- Seu identificador. Único por conta.
expiresIninteger- Validade em segundos (cobrança imediata).
dueAtstring · date-time- Vencimento em ISO 8601 UTC (cobrança com vencimento).
Erros
- 400
VALIDATION_ERRORValor inválido, ouexpiresInedueAtjuntos. - 409
EXTERNAL_ID_CONFLICTJá existe cobrança com esteexternalId.
curl -X POST "$ONZEPAY_API/v1/charges" \
-H "Authorization: Bearer $ONZEPAY_SECRET_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"amount": 3000,
"description": "Pedido 4821",
"externalId": "order-4821",
"expiresIn": 3600
}'const res = await fetch(`${process.env.ONZEPAY_API}/v1/charges`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ONZEPAY_SECRET_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json'
},
body: JSON.stringify({
"amount": 3000,
"description": "Pedido 4821",
"externalId": "order-4821",
"expiresIn": 3600
})
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.code}: ${data.message}`)import os, uuid
import requests
res = requests.post(
f"{os.environ['ONZEPAY_API']}/v1/charges",
headers={"Authorization": f"Bearer {os.environ['ONZEPAY_SECRET_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
json={
"amount": 3000,
"description": "Pedido 4821",
"externalId": "order-4821",
"expiresIn": 3600,
},
timeout=30,
)
res.raise_for_status()
data = res.json(){
"id": "chg_034yDKstyRbto2AiOEPZJP",
"externalId": "order-4821",
"txid": "0f6a1c2e9b7d4e3fa1b2c3d4e5f60718",
"status": "active",
"amount": 3000,
"feeAmount": 30,
"netAmount": 2970,
"currency": "BRL",
"description": "Pedido 4821",
"copyPaste": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"qrCode": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"expiresAt": "2026-11-15T22:00:00.000Z",
"dueAt": null,
"endToEndId": null,
"pixInId": null,
"paidAt": null,
"createdAt": "2026-11-15T21:00:00.000Z",
"updatedAt": "2026-11-15T21:00:00.000Z"
}Consultar uma cobrança
https://api.onzepay.com/v1/charges/{id}Parâmetros de caminho
idstringobrigatório- Id da cobrança (
chg_…).
Erros
- 404
NOT_FOUNDCobrança não encontrada nesta conta.
curl -X GET "$ONZEPAY_API/v1/charges/chg_034yDKstyRbto2AiOEPZJP" \
-H "Authorization: Bearer $ONZEPAY_SECRET_KEY"const res = await fetch(`${process.env.ONZEPAY_API}/v1/charges/chg_034yDKstyRbto2AiOEPZJP`, {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.ONZEPAY_SECRET_KEY}`
}
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.code}: ${data.message}`)import os
import requests
res = requests.get(
f"{os.environ['ONZEPAY_API']}/v1/charges/chg_034yDKstyRbto2AiOEPZJP",
headers={"Authorization": f"Bearer {os.environ['ONZEPAY_SECRET_KEY']}"},
timeout=30,
)
res.raise_for_status()
data = res.json(){
"id": "chg_034yDKstyRbto2AiOEPZJP",
"externalId": "order-4821",
"txid": "0f6a1c2e9b7d4e3fa1b2c3d4e5f60718",
"status": "paid",
"amount": 3000,
"feeAmount": 30,
"netAmount": 2970,
"currency": "BRL",
"description": "Pedido 4821",
"copyPaste": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"qrCode": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"expiresAt": "2026-11-15T22:00:00.000Z",
"dueAt": null,
"endToEndId": "E18236120202611152100abcdef123456",
"pixInId": "pxi_034yDKu1QwzR8mJb3XyTnE",
"paidAt": "2026-11-15T21:05:00.000Z",
"createdAt": "2026-11-15T21:00:00.000Z",
"updatedAt": "2026-11-15T21:05:00.000Z"
}Listar cobranças
https://api.onzepay.com/v1/chargesLista da mais nova para a mais antiga. Com só externalId na query, devolve a cobrança direto (sem lista).
Query
statusstring- Filtra pelo estado.
activewaitingpaidexpiredcanceled externalIdstring- Seu identificador.
createdAfterstring · date-time- Criadas a partir de (ISO 8601 UTC).
createdBeforestring · date-time- Criadas até (ISO 8601 UTC).
limitinteger- Itens por página. Padrão 25, máximo 100.
startingAfterstring- Cursor: o
id(chg_…) do último item da página anterior.
curl -X GET "$ONZEPAY_API/v1/charges?status=paid&limit=25" \
-H "Authorization: Bearer $ONZEPAY_SECRET_KEY"const res = await fetch(`${process.env.ONZEPAY_API}/v1/charges?status=paid&limit=25`, {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.ONZEPAY_SECRET_KEY}`
}
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.code}: ${data.message}`)import os
import requests
res = requests.get(
f"{os.environ['ONZEPAY_API']}/v1/charges?status=paid&limit=25",
headers={"Authorization": f"Bearer {os.environ['ONZEPAY_SECRET_KEY']}"},
timeout=30,
)
res.raise_for_status()
data = res.json(){
"data": [
{
"id": "chg_034yDKstyRbto2AiOEPZJP",
"externalId": "order-4821",
"txid": "0f6a1c2e9b7d4e3fa1b2c3d4e5f60718",
"status": "active",
"amount": 3000,
"feeAmount": 30,
"netAmount": 2970,
"currency": "BRL",
"description": "Pedido 4821",
"copyPaste": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"qrCode": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"expiresAt": "2026-11-15T22:00:00.000Z",
"dueAt": null,
"endToEndId": null,
"pixInId": null,
"paidAt": null,
"createdAt": "2026-11-15T21:00:00.000Z",
"updatedAt": "2026-11-15T21:00:00.000Z"
}
],
"hasMore": true,
"nextCursor": "chg_034yDKstyRbto2AiOEPZJP"
}Alterar uma cobrança
https://api.onzepay.com/v1/charges/{id}Só cobranças active ou waiting. Mudar valor, expiresIn ou dueAt gera um novo QR Code (o anterior deixa de valer).
Parâmetros de caminho
idstringobrigatório- Id da cobrança (
chg_…).
Corpo
amountinteger- Novo valor em centavos.
descriptionstring- Nova descrição.
expiresIninteger- Nova validade em segundos a partir de agora.
dueAtstring · date-time- Novo vencimento (ISO 8601 UTC).
Erros
- 409
CHARGE_NOT_EDITABLEA cobrança já foi paga, expirou ou foi cancelada.
curl -X PATCH "$ONZEPAY_API/v1/charges/chg_034yDKstyRbto2AiOEPZJP" \
-H "Authorization: Bearer $ONZEPAY_SECRET_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"amount": 3500,
"expiresIn": 7200
}'const res = await fetch(`${process.env.ONZEPAY_API}/v1/charges/chg_034yDKstyRbto2AiOEPZJP`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.ONZEPAY_SECRET_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json'
},
body: JSON.stringify({
"amount": 3500,
"expiresIn": 7200
})
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.code}: ${data.message}`)import os, uuid
import requests
res = requests.patch(
f"{os.environ['ONZEPAY_API']}/v1/charges/chg_034yDKstyRbto2AiOEPZJP",
headers={"Authorization": f"Bearer {os.environ['ONZEPAY_SECRET_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
json={
"amount": 3500,
"expiresIn": 7200,
},
timeout=30,
)
res.raise_for_status()
data = res.json(){
"id": "chg_034yDKstyRbto2AiOEPZJP",
"externalId": "order-4821",
"txid": "0f6a1c2e9b7d4e3fa1b2c3d4e5f60718",
"status": "active",
"amount": 3500,
"feeAmount": 35,
"netAmount": 3465,
"currency": "BRL",
"description": "Pedido 4821",
"copyPaste": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"qrCode": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"expiresAt": "2026-11-15T23:10:00.000Z",
"dueAt": null,
"endToEndId": null,
"pixInId": null,
"paidAt": null,
"createdAt": "2026-11-15T21:00:00.000Z",
"updatedAt": "2026-11-15T21:10:00.000Z"
}Cancelar uma cobrança
https://api.onzepay.com/v1/charges/{id}/cancelO QR Code deixa de aceitar pagamento. Dispara charge.canceled. Cancelar de novo devolve a mesma cobrança.
Parâmetros de caminho
idstringobrigatório- Id da cobrança (
chg_…).
Erros
- 409
CHARGE_ALREADY_PAIDCobrança paga não pode ser cancelada. Use uma devolução.
curl -X POST "$ONZEPAY_API/v1/charges/chg_034yDKstyRbto2AiOEPZJP/cancel" \
-H "Authorization: Bearer $ONZEPAY_SECRET_KEY" \
-H "Idempotency-Key: $(uuidgen)"const res = await fetch(`${process.env.ONZEPAY_API}/v1/charges/chg_034yDKstyRbto2AiOEPZJP/cancel`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ONZEPAY_SECRET_KEY}`,
'Idempotency-Key': crypto.randomUUID()
}
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.code}: ${data.message}`)import os, uuid
import requests
res = requests.post(
f"{os.environ['ONZEPAY_API']}/v1/charges/chg_034yDKstyRbto2AiOEPZJP/cancel",
headers={"Authorization": f"Bearer {os.environ['ONZEPAY_SECRET_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
timeout=30,
)
res.raise_for_status()
data = res.json(){
"id": "chg_034yDKstyRbto2AiOEPZJP",
"externalId": "order-4821",
"txid": "0f6a1c2e9b7d4e3fa1b2c3d4e5f60718",
"status": "canceled",
"amount": 3000,
"feeAmount": 30,
"netAmount": 2970,
"currency": "BRL",
"description": "Pedido 4821",
"copyPaste": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"qrCode": "00020126580014br.gov.bcb.pix0136…6304ABCD",
"expiresAt": "2026-11-15T22:00:00.000Z",
"dueAt": null,
"endToEndId": null,
"pixInId": null,
"paidAt": null,
"createdAt": "2026-11-15T21:00:00.000Z",
"updatedAt": "2026-11-15T21:20:00.000Z"
}