Naafi Pay

Cancel Subscription

POST/api/subscriptions/cancel

Cancels 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

FieldTypeRequiredDescription
AuthorizationstringrequiredYour test or live API key.
Example: pg_live_xxx
Content-TypestringrequiredMust be application/json.
Example: application/json

Request body

FieldTypeRequiredDescription
subscription_idstringrequiredThe subscription_id returned by Subscription Checkout.
Example: sub_01HZY8K2R4T8AB7CDEF9G2H3JK
cancel_immediatelybooleanoptionalTrue 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

FieldTypeRequiredDescription
400already_cancelledoptionalSubscription is already cancelled.
401unauthorizedoptionalAPI key is missing or invalid.
404not_foundoptionalNo 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.
Updated at: May 30, 2026