Cancelar antecipação
curl --request POST \
--url https://api.sandbox.z2pay.com/v1/anticipations/{id}/cancel \
--header 'x-api-key: <api-key>'const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.sandbox.z2pay.com/v1/anticipations/{id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sandbox.z2pay.com/v1/anticipations/{id}/cancel"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text){
"id": "stl_ant_k4w9m2x7q1v8b3n6c5z0p2r7t",
"recipientId": "rec_h7d4s9k2m6p1q8w3x5z0v4b7n",
"status": "cancelled",
"amount": 100000,
"fee": 2500,
"netAmount": 97500,
"reachedAmount": null,
"requestedAt": "2026-10-21T13:01:12.000Z",
"reachedAt": null,
"liquidatedAt": null,
"createdAt": "2026-10-21T13:01:12.000Z",
"updatedAt": "2026-10-21T13:03:40.000Z"
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "Anticipation not found"
}
}{
"error": {
"code": "ANTICIPATION_REJECTED",
"message": "Only anticipations still `requested` can be cancelled."
}
}{
"error": "Idempotency key already used with a different request body"
}{
"error": {
"code": "ANTICIPATION_PROVIDER_UNAVAILABLE",
"message": "We couldn't complete your request right now. Please try again in a few moments."
}
}Antecipações
Cancelar antecipação
Desfaz um pedido de antecipação que ainda não foi aprovado.
POST
/
anticipations
/
{id}
/
cancel
Cancelar antecipação
curl --request POST \
--url https://api.sandbox.z2pay.com/v1/anticipations/{id}/cancel \
--header 'x-api-key: <api-key>'const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.sandbox.z2pay.com/v1/anticipations/{id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sandbox.z2pay.com/v1/anticipations/{id}/cancel"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text){
"id": "stl_ant_k4w9m2x7q1v8b3n6c5z0p2r7t",
"recipientId": "rec_h7d4s9k2m6p1q8w3x5z0v4b7n",
"status": "cancelled",
"amount": 100000,
"fee": 2500,
"netAmount": 97500,
"reachedAmount": null,
"requestedAt": "2026-10-21T13:01:12.000Z",
"reachedAt": null,
"liquidatedAt": null,
"createdAt": "2026-10-21T13:01:12.000Z",
"updatedAt": "2026-10-21T13:03:40.000Z"
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "Anticipation not found"
}
}{
"error": {
"code": "ANTICIPATION_REJECTED",
"message": "Only anticipations still `requested` can be cancelled."
}
}{
"error": "Idempotency key already used with a different request body"
}{
"error": {
"code": "ANTICIPATION_PROVIDER_UNAVAILABLE",
"message": "We couldn't complete your request right now. Please try again in a few moments."
}
}POST /anticipations/{id}/cancel
Faz parte do recurso Antecipações — o passo a passo e os status estão lá.
Cancela o pedido. Nada é cobrado, e o valor volta a ficar disponível para antecipar.
Só funciona em
requested. Assim que a antecipação é aprovada, não dá mais para voltar atrás:
approved, processing, ur_reached, liquidated e failed respondem 409. A aprovação não
depende de você e pode acontecer logo depois do pedido — se cancelar faz parte do seu fluxo, trate
o 409 como resultado normal, não como exceção.Cancelar o que já está cancelado não é erro. A resposta é
200 com a antecipação
cancelled, como na primeira vez.Exemplo
curl -X POST https://api.sandbox.z2pay.com/v1/anticipations/stl_ant_k4w9m2x7q1v8b3n6c5z0p2r7t/cancel \
-H "x-api-key: SUA_CHAVE_DE_SANDBOX"
Resposta 200
{
"id": "stl_ant_k4w9m2x7q1v8b3n6c5z0p2r7t",
"recipientId": "rec_h7d4s9k2m6p1q8w3x5z0v4b7n",
"status": "cancelled",
"amount": 100000,
"fee": 2500,
"netAmount": 97500,
"reachedAmount": null,
"requestedAt": "2026-10-21T13:01:12.000Z",
"liquidatedAt": null
}
Response
Antecipação cancelada