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

# Cancel Subscription

Cancel a subscription immediately or schedule cancellation for the next renewal boundary.

Use this endpoint only from an authenticated merchant backend. Derive the customer from the logged-in user or team; never accept an authoritative `customer_id` from browser input.

**Auth:** secret key only. Publishable keys are always rejected.

<ParamField path="id" type="string" required>
  The subscription ID to cancel.
</ParamField>

<ParamField query="customer_id" type="string" required>
  External customer ID derived by the trusted merchant backend. The subscription must belong to that customer and organization.
</ParamField>

<ParamField query="cancellation_policy" type="string" default="immediate">
  `end_of_period` keeps the subscription active until its next renewal boundary. `immediate` terminates it now. The raw HTTP API defaults to `immediate` for backward compatibility; the Node.js and Python SDK methods default to `end_of_period`.
</ParamField>

### Response

For `end_of_period`, the subscription remains `active` and `ending_at` contains the next renewal boundary. The billing engine terminates it at that boundary and prevents another renewal invoice. Repeating the request does not extend an earlier scheduled ending.

For `immediate`, the response contains the terminated subscription.

```bash theme={null}
curl --request DELETE \
  'https://api.nozle.app/api/v1/subscriptions/sub_123?customer_id=cust_123&cancellation_policy=end_of_period' \
  --header 'Authorization: Bearer sk_live_...'
```
