Desfazer cancelamento agendado
curl --request POST \
--url https://api.sandbox.z2pay.com/v1/subscriptions/{id}/uncancel \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"reasonDetails": "<string>"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({reasonDetails: '<string>'})
};
fetch('https://api.sandbox.z2pay.com/v1/subscriptions/{id}/uncancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sandbox.z2pay.com/v1/subscriptions/{id}/uncancel"
payload = { "reasonDetails": "<string>" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "sub_hsm2kigu74htdxj3nw2z6f9xw",
"number": {
"sequence": 42
},
"referenceCode": "CONTRATO-2026-0042",
"customerId": "cust_c72q6ogr9iko0we85mqal04te",
"customerEmail": "maria.silva@example.com",
"customerName": "Maria Silva",
"customerDocument": "12345678909",
"currency": "BRL",
"status": "active",
"billingGroupId": null,
"currentPeriodStart": "2025-06-01T03:00:00.000Z",
"currentPeriodEnd": "2025-07-01T03:00:00.000Z",
"nextInvoiceAt": "2025-07-01T03:00:00.000Z",
"recurrence": {
"interval": 1,
"unit": "month",
"anchor": "day_of_month",
"anchorDay": 1,
"collectionTiming": "prepaid"
},
"collectionMethod": "charge_automatically",
"collectionTiming": "prepaid",
"invoiceGenerationMode": "just_in_time",
"cancelAtPeriodEnd": false,
"canceledAt": null,
"endedAt": null,
"cancellationReason": null,
"pausedAt": null,
"pauseResumesAt": null,
"pauseReason": null,
"trialEnd": null,
"incompleteExpiresAt": null,
"trialRemindersFired": [],
"maxCycles": null,
"issuedCycles": 1,
"completedCycles": 1,
"defaultPaymentMethodRef": {
"id": "crd_tsj66oabsygc9kwvvzt8189f9",
"type": "card"
},
"splitConfig": null,
"paymentBehavior": "allow_incomplete",
"latestInvoiceId": "inv_c3qahi4qnkc258lfc14gplupt",
"paymentUpdateToken": null,
"paymentUpdateMethods": null,
"metadata": {},
"createdAt": "2025-06-01T13:45:30.000Z",
"updatedAt": "2025-06-29T13:45:30.000Z"
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed",
"issues": [
{
"path": "status",
"message": "Status inválido. Valores aceitos: pending, waiting_payment, paid, refused, canceled, refunded"
},
{
"path": "startDate",
"message": "Data deve ser ISO 8601 com timezone (ex.: 2026-06-24T00:00:00Z)"
}
]
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "Subscription not found"
}
}{
"error": {
"code": "CONFLICT",
"message": "No refundable payment found"
}
}{
"error": "Idempotency key already used with a different request body"
}Ciclo de vida
Desfazer cancelamento agendado
Limpa um cancelamento marcado para o fim do período, enquanto ele ainda não aconteceu.
POST
/
subscriptions
/
{id}
/
uncancel
Desfazer cancelamento agendado
curl --request POST \
--url https://api.sandbox.z2pay.com/v1/subscriptions/{id}/uncancel \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"reasonDetails": "<string>"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({reasonDetails: '<string>'})
};
fetch('https://api.sandbox.z2pay.com/v1/subscriptions/{id}/uncancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sandbox.z2pay.com/v1/subscriptions/{id}/uncancel"
payload = { "reasonDetails": "<string>" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "sub_hsm2kigu74htdxj3nw2z6f9xw",
"number": {
"sequence": 42
},
"referenceCode": "CONTRATO-2026-0042",
"customerId": "cust_c72q6ogr9iko0we85mqal04te",
"customerEmail": "maria.silva@example.com",
"customerName": "Maria Silva",
"customerDocument": "12345678909",
"currency": "BRL",
"status": "active",
"billingGroupId": null,
"currentPeriodStart": "2025-06-01T03:00:00.000Z",
"currentPeriodEnd": "2025-07-01T03:00:00.000Z",
"nextInvoiceAt": "2025-07-01T03:00:00.000Z",
"recurrence": {
"interval": 1,
"unit": "month",
"anchor": "day_of_month",
"anchorDay": 1,
"collectionTiming": "prepaid"
},
"collectionMethod": "charge_automatically",
"collectionTiming": "prepaid",
"invoiceGenerationMode": "just_in_time",
"cancelAtPeriodEnd": false,
"canceledAt": null,
"endedAt": null,
"cancellationReason": null,
"pausedAt": null,
"pauseResumesAt": null,
"pauseReason": null,
"trialEnd": null,
"incompleteExpiresAt": null,
"trialRemindersFired": [],
"maxCycles": null,
"issuedCycles": 1,
"completedCycles": 1,
"defaultPaymentMethodRef": {
"id": "crd_tsj66oabsygc9kwvvzt8189f9",
"type": "card"
},
"splitConfig": null,
"paymentBehavior": "allow_incomplete",
"latestInvoiceId": "inv_c3qahi4qnkc258lfc14gplupt",
"paymentUpdateToken": null,
"paymentUpdateMethods": null,
"metadata": {},
"createdAt": "2025-06-01T13:45:30.000Z",
"updatedAt": "2025-06-29T13:45:30.000Z"
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed",
"issues": [
{
"path": "status",
"message": "Status inválido. Valores aceitos: pending, waiting_payment, paid, refused, canceled, refunded"
},
{
"path": "startDate",
"message": "Data deve ser ISO 8601 com timezone (ex.: 2026-06-24T00:00:00Z)"
}
]
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "Subscription not found"
}
}{
"error": {
"code": "CONFLICT",
"message": "No refundable payment found"
}
}{
"error": "Idempotency key already used with a different request body"
}POST /subscriptions/:id/uncancel
Faz parte do recurso Assinaturas — o conceito e os dez estados estão lá.
Limpa o cancelAtPeriodEnd de uma assinatura que foi cancelada com
mode: "at_period_end" e ainda está dentro da janela. A assinatura
volta a renovar normalmente.
Só funciona antes de o cancelamento acontecer. Depois que o motor transiciona a assinatura
para
canceled, a rota responde 409 — e não há outra que reverta. Um cancelamento
immediate nunca pode ser desfeito, porque não passa por janela nenhuma.Para o cliente voltar depois disso, o caminho é uma assinatura nova.Responde
409 se não houver nada a desfazer. Chamar a rota numa assinatura sem cancelamento
agendado é erro, não operação sem efeito.reason e reasonDetails são obrigatórios. O corpo não é vazio — enviar {} responde 400.Exemplo
curl -X POST https://api.sandbox.z2pay.com/v1/subscriptions/sub_x33m4yn6brazh71en4mki6f5c/uncancel \
-H "x-api-key: SUA_CHAVE_DE_SANDBOX" \
-H "Content-Type: application/json" \
-d '{
"reason": "customer_reconsidered",
"reasonDetails": "Cliente aceitou o desconto oferecido pela retenção."
}'
Resposta 200
{
"id": "sub_x33m4yn6brazh71en4mki6f5c",
"status": "active",
"cancelAtPeriodEnd": false,
"canceledAt": null,
"cancellationReason": null,
"currentPeriodEnd": "2026-09-10T12:00:00.000Z",
"nextInvoiceAt": "2026-09-10T12:00:00.000Z",
"updatedAt": "2026-08-10T18:20:00.000Z"
}
O
nextInvoiceAt, que o cancelamento agendado havia zerado, volta a apontar para a próxima
emissão.Body
application/json
Response
Cancelamento revertido