> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upag.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancelar Assinatura

> Cancela uma assinatura imediatamente

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](./update) sem chamar delete.

## Endpoint

```bash cURL theme={null}
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

<ParamField path="id" type="string" required>
  ID único da assinatura, começando com `sub_`.
</ParamField>

<ParamField body="cancelAtPeriodEnd" type="boolean">
  Padrão `false`. Se `true`, agenda cancelamento ao fim do período de cobrança atual.
</ParamField>

<ParamField body="cancellationReason" type="string">
  Opcional. Valores alinhados ao enum da API, por exemplo: `low_quality`, `missing_features`, `other`, `switched_service`, `too_complex`, `too_expensive`, `unused`.
</ParamField>

## Resposta

```json Response theme={null}
{
  "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"
}
```
