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

# Cancellation

> Cancel subscriptions immediately or at the end of the billing period.

## Canceling a Subscription

```bash theme={null}
curl -X POST https://api.fluxrate.co/api/v1/subscriptions/<subscription_id>/cancel \
  -H "Content-Type: application/json" \
  -H "Cookie: access_token=<token>" \
  -d '{
    "cancel_at_period_end": true,
    "reason": "Customer requested cancellation"
  }'
```

## Cancellation Options

| Option                        | Description                                                             |
| ----------------------------- | ----------------------------------------------------------------------- |
| `cancel_at_period_end: true`  | Subscription remains active until the current period ends, then cancels |
| `cancel_at_period_end: false` | Subscription cancels immediately                                        |

## Immediate vs. End-of-Period Cancellation

**Immediate cancellation** (`cancel_at_period_end: false`):

* Status changes to `CANCELED` right away
* A final prorated invoice is generated for usage up to the cancellation date
* No future invoices

**End-of-period cancellation** (`cancel_at_period_end: true`):

* Status remains `ACTIVE` until the period ends
* `canceled_at` is set to the cancellation request time
* Subscription proceeds normally until `current_period_end`
* Cancels automatically after the last invoice

## Deleting a Subscription

To permanently delete a subscription record:

```bash theme={null}
DELETE /api/v1/subscriptions/<subscription_id>
```

<Warning>
  Deleting a subscription is permanent and cannot be undone. Canceling is preferred — it preserves billing history while stopping future charges.
</Warning>
