Cancelar Assinatura
curl --request DELETE \
--url https://api.billing.upag.io/v1/subscriptions/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancelAtPeriodEnd": true,
"cancellationReason": "<string>"
}
'const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancelAtPeriodEnd: true, cancellationReason: '<string>'})
};
fetch('https://api.billing.upag.io/v1/subscriptions/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.billing.upag.io/v1/subscriptions/{id}';
const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancelAtPeriodEnd: true, cancellationReason: '<string>'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Assinaturas
Cancelar Assinatura
Cancela uma assinatura imediatamente
DELETE
https://api.billing.upag.io
/
v1
/
subscriptions
/
{id}
Cancelar Assinatura
curl --request DELETE \
--url https://api.billing.upag.io/v1/subscriptions/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancelAtPeriodEnd": true,
"cancellationReason": "<string>"
}
'const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancelAtPeriodEnd: true, cancellationReason: '<string>'})
};
fetch('https://api.billing.upag.io/v1/subscriptions/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.billing.upag.io/v1/subscriptions/{id}';
const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancelAtPeriodEnd: true, cancellationReason: '<string>'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Cancela uma assinatura. O comportamento depende do body opcional: com
cancelAtPeriodEnd: false (padrão), o cancelamento é imediato; com cancelAtPeriodEnd: true, a assinatura segue até o fim do período atual. Também é possível definir cancelAtPeriodEnd via atualização da assinatura sem chamar delete.
Endpoint
cURL
curl -X DELETE https://api.billing.upag.io/v1/subscriptions/sub_abc123xyz \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"cancelAtPeriodEnd": false,
"cancellationReason": "other"
}'
Parâmetros
string
required
ID único da assinatura, começando com
sub_.boolean
Padrão
false. Se true, agenda cancelamento ao fim do período de cobrança atual.string
Opcional. Valores alinhados ao enum da API, por exemplo:
low_quality, missing_features, other, switched_service, too_complex, too_expensive, unused.Resposta
Response
{
"id": "sub_abc123xyz",
"livemode": false,
"customerId": "cus_ahwDXrgYvur89iPs",
"paymentMethodId": "pm_abc123xyz",
"status": "canceled",
"currency": "BRL",
"interval": "month",
"intervalCount": 1,
"cancelAtPeriodEnd": false,
"startDate": "2024-11-15T10:00:00.000Z",
"endDate": "2024-11-15T11:00:00.000Z",
"trialStartDate": null,
"trialEndDate": null,
"currentPeriodStart": "2024-11-15T10:00:00.000Z",
"currentPeriodEnd": "2024-12-15T10:00:00.000Z",
"canceledAt": "2024-11-15T11:00:00.000Z",
"cancellationReason": "other",
"items": [
{
"id": "si_abc123xyz",
"subscriptionId": "sub_abc123xyz",
"productId": "prod_xyz789abc",
"priceId": "price_def456ghi",
"name": "Plano Pro",
"amount": 9900,
"quantity": 1,
"createdAt": "2024-11-15T10:00:00.000Z",
"updatedAt": "2024-11-15T10:00:00.000Z"
}
],
"createdAt": "2024-11-15T10:00:00.000Z",
"updatedAt": "2024-11-15T11:00:00.000Z"
}