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

# Cancel Subscription

> Cancel a subscription

# Cancel Subscription

Cancel a subscription either immediately or at the end of the current billing period.

## Authentication

```bash theme={null}
Authorization: Bearer glm_test_YOUR_API_KEY
```

## Path Parameters

| Parameter | Type   | Required | Description     |
| --------- | ------ | -------- | --------------- |
| `id`      | string | Yes      | Subscription ID |

## Request Body

```json theme={null}
{
  "cancel_at_period_end": true,
  "reason": "customer_request"
}
```

| Parameter              | Type    | Required | Description                                    |
| ---------------------- | ------- | -------- | ---------------------------------------------- |
| `cancel_at_period_end` | boolean | No       | If true, cancel at period end (default: false) |
| `reason`               | string  | No       | Cancellation reason                            |

## Response

```json theme={null}
{
  "id": "sub_abc123xyz",
  "status": "cancelled",
  "cancel_at_period_end": true,
  "current_period_end": "2025-11-18T14:30:00Z",
  "cancelled_at": "2025-10-20T10:00:00Z"
}
```

## Examples

### Cancel at Period End

```bash theme={null}
curl -X POST https://api.withgale.com/api/v2/subscriptions/sub_abc123xyz/cancel \
  -H "Authorization: Bearer glm_test_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cancel_at_period_end": true,
    "reason": "customer_request"
  }'
```

### Immediate Cancellation

```bash theme={null}
curl -X POST https://api.withgale.com/api/v2/subscriptions/sub_abc123xyz/cancel \
  -H "Authorization: Bearer glm_test_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cancel_at_period_end": false
  }'
```

## Related Endpoints

* [Get Subscription](/api-reference/endpoint/get-subscription)
* [List Subscriptions](/api-reference/endpoint/list-subscriptions)
