Skip to main content
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.upag.io/v1/subscriptions/sub_abc123xyz \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "cancelAtPeriodEnd": false,
    "cancellationReason": "other"
  }'

Parâmetros

id
string
required
ID único da assinatura, começando com sub_.
cancelAtPeriodEnd
boolean
Padrão false. Se true, agenda cancelamento ao fim do período de cobrança atual.
cancellationReason
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"
}