Devoluções
Devolve, total ou parcialmente, um Pix recebido. Não há tarifa. O total devolvido não passa do líquido creditado na cobrança. Webhooks: pix.refund.completed quando conclui e pix.refund.failed quando o liquidante recusa (o saldo não é debitado e failureReason diz o motivo).
Solicitar uma devolução
POST
https://api.onzepay.com/v1/refundsrefunds.writeIdempotency-Key
Informe a cobrança por chargeId ou pelo endToEndId do Pix recebido.
Corpo
chargeIdstring- Id da cobrança (
chg_…). endToEndIdstring- Alternativa ao
chargeId. amountintegerobrigatório- Valor em centavos.
externalIdstring- Seu identificador. Único por conta.
reasonstring- Motivo (até 240 caracteres).
Erros
- 400
REFUND_TOO_HIGHPassa do líquido creditado. - 400
INVALID_CHARGECobrança não paga ou não encontrada. - 409
EXTERNAL_ID_CONFLICTJá existe devolução com esteexternalId.
curl -X POST "$ONZEPAY_API/v1/refunds" \
-H "Authorization: Bearer $ONZEPAY_SECRET_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"chargeId": "chg_034yDKstyRbto2AiOEPZJP",
"amount": 3000,
"externalId": "refund-4821",
"reason": "Cliente desistiu da compra"
}'const res = await fetch(`${process.env.ONZEPAY_API}/v1/refunds`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ONZEPAY_SECRET_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json'
},
body: JSON.stringify({
"chargeId": "chg_034yDKstyRbto2AiOEPZJP",
"amount": 3000,
"externalId": "refund-4821",
"reason": "Cliente desistiu da compra"
})
})
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/refunds",
headers={"Authorization": f"Bearer {os.environ['ONZEPAY_SECRET_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
json={
"chargeId": "chg_034yDKstyRbto2AiOEPZJP",
"amount": 3000,
"externalId": "refund-4821",
"reason": "Cliente desistiu da compra",
},
timeout=30,
)
res.raise_for_status()
data = res.json(){
"id": "rfd_034yDL0aB7cD9eF1gH2iJ3",
"externalId": "refund-4821",
"chargeId": "chg_034yDKstyRbto2AiOEPZJP",
"endToEndId": "D12345678202611161230abcdef987654",
"amount": 3000,
"feeAmount": 0,
"status": "completed",
"origin": "spontaneous",
"reason": "Cliente desistiu da compra",
"failureReason": null,
"createdAt": "2026-11-16T12:30:00.000Z"
}Consultar uma devolução
GET
https://api.onzepay.com/v1/refunds/{id}refunds.read
Parâmetros de caminho
idstringobrigatório- Id da devolução (
rfd_…).
curl -X GET "$ONZEPAY_API/v1/refunds/rfd_034yDL0aB7cD9eF1gH2iJ3" \
-H "Authorization: Bearer $ONZEPAY_SECRET_KEY"const res = await fetch(`${process.env.ONZEPAY_API}/v1/refunds/rfd_034yDL0aB7cD9eF1gH2iJ3`, {
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/refunds/rfd_034yDL0aB7cD9eF1gH2iJ3",
headers={"Authorization": f"Bearer {os.environ['ONZEPAY_SECRET_KEY']}"},
timeout=30,
)
res.raise_for_status()
data = res.json(){
"id": "rfd_034yDL0aB7cD9eF1gH2iJ3",
"externalId": "refund-4821",
"chargeId": "chg_034yDKstyRbto2AiOEPZJP",
"endToEndId": "D12345678202611161230abcdef987654",
"amount": 3000,
"feeAmount": 0,
"status": "completed",
"origin": "spontaneous",
"reason": "Cliente desistiu da compra",
"failureReason": null,
"createdAt": "2026-11-16T12:30:00.000Z"
}Buscar devoluções
GET
https://api.onzepay.com/v1/refundsrefunds.read
Com chargeId, lista as devoluções da cobrança. Com só externalId, devolve a devolução direto.
Query
chargeIdstring- Id da cobrança (
chg_…). externalIdstring- Seu identificador.
curl -X GET "$ONZEPAY_API/v1/refunds?chargeId=chg_034yDKstyRbto2AiOEPZJP" \
-H "Authorization: Bearer $ONZEPAY_SECRET_KEY"const res = await fetch(`${process.env.ONZEPAY_API}/v1/refunds?chargeId=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/refunds?chargeId=chg_034yDKstyRbto2AiOEPZJP",
headers={"Authorization": f"Bearer {os.environ['ONZEPAY_SECRET_KEY']}"},
timeout=30,
)
res.raise_for_status()
data = res.json(){
"data": [
{
"id": "rfd_034yDL0aB7cD9eF1gH2iJ3",
"externalId": "refund-4821",
"chargeId": "chg_034yDKstyRbto2AiOEPZJP",
"endToEndId": "D12345678202611161230abcdef987654",
"amount": 3000,
"feeAmount": 0,
"status": "completed",
"origin": "spontaneous",
"reason": "Cliente desistiu da compra",
"failureReason": null,
"createdAt": "2026-11-16T12:30:00.000Z"
}
]
}