Cancel Subscription
POST
/api/subscriptions/cancelCancels an active subscription. You can choose to cancel immediately (the customer loses access right away and is refunded the unused portion of the current period) or at period end (the customer keeps access until the current period expires and is not billed for the next cycle). Cancellations are irreversible — if the customer changes their mind, create a new subscription. This endpoint fires a subscription.cancelled webhook so your application can revoke access and update its records.
Request headers
| Field | Type | Required | Description |
|---|---|---|---|
| Authorization | string | required | Your test or live API key. Example: pg_live_xxx |
| Content-Type | string | required | Must be application/json. Example: application/json |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| subscription_id | string | required | The subscription_id returned by Subscription Checkout. Example: sub_01HZY8K2R4T8AB7CDEF9G2H3JK |
| cancel_immediately | boolean | optional | True cancels at once and prorates a refund. False (default) cancels at the end of the current period. Example: false |
Response
200 OK
1{2 "subscription_id": "sub_01HZY8K2R4T8AB7CDEF9G2H3JK",3 "status": "cancelled",4 "cancelled_at": "2026-05-30T15:00:00Z",5 "current_period_end": "2026-06-15T00:00:00Z",6 "access_until": "2026-06-15T00:00:00Z"7}TipDefault behaviour is graceful
If you omit
cancel_immediately, the customer keeps access until the end of the current period. This avoids the awkward situation of charging for a full month and then cutting access mid-month.Error codes
| Field | Type | Required | Description |
|---|---|---|---|
| 400 | already_cancelled | optional | Subscription is already cancelled. |
| 401 | unauthorized | optional | API key is missing or invalid. |
| 404 | not_found | optional | No subscription exists for the given id. |
WarningRefunds on immediate cancellation
cancel_immediately: true automatically issues a prorated refund for the unused portion of the period. Refunds to cards may take up to seven business days to appear on the customer's statement.