Api reference
Cancel subscription
Cancel a subscription either immediately or at the end of the current billing period.
Modes:
immediately: Status set to "canceled", access revoked nowperiod_end: cancelAtPeriodEnd flag set, access continues until period end
Related endpoints
POST /subscriptions— Create a new subscriptionGET /subscriptions— List subscriptionsGET /subscriptions/{id}— Get subscription by IDPATCH /subscriptions/{id}— Update subscription detailsDELETE /subscriptions/{id}— Delete subscriptionPOST /subscriptions/{id}/change-plan— Change subscription planPOST /subscriptions/{id}/change-quantity— Change subscription quantityPOST /subscriptions/{id}/preview-renewal— Preview subscription renewal
Common errors
400 invalid_request— malformed payload or failed validation.401 unauthenticated— missing, malformed, or revoked API key.404 resource_missing— the referenced resource does not exist or is not visible to your key.
Idempotency
Pass an Idempotency-Key header (UUID v4 recommended) to make retries safe. Keys are valid for 24 hours; see the idempotency guide.
x-api-key<token>
Your RevKeen API key (powered by Unkey). Get it from Dashboard > Settings > API Keys. Use rk_sandbox_* for test mode and rk_live_* for production.
In: header
Path Parameters
id*string
Subscription UUID
Format
uuidRequest Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://api.revkeen.com/v2/subscriptions/00000000-0000-0000-0000-000000000000/cancel" \ -H "x-api-key: $REVKEEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mode": "immediately", "reason": "string" }'{
"data": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"merchantId": "c3073b9d-edd0-49f2-a28d-b7ded8ff9a8b",
"customerId": "87d8e330-2878-4742-a86f-dbbb3bf522ac",
"productId": "dcd53ddb-8104-4e48-8cc0-5df1088c6113",
"priceId": "b245ceea-4bc7-4619-ae4c-559a1faf418e",
"planId": "b3f60ba2-c1fd-4b3a-a23d-8e876e0ef75d",
"status": "trialing",
"quantity": 1,
"amountMinor": 0,
"currency": "str",
"billingInterval": "day",
"currentPeriodStart": "2019-08-24T14:15:22Z",
"currentPeriodEnd": "2019-08-24T14:15:22Z",
"trialEnd": "2019-08-24T14:15:22Z",
"canceledAt": "2019-08-24T14:15:22Z",
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z",
"dunning": {
"isInDunning": true,
"phase": 0,
"phaseLabel": "string",
"phaseSeverity": "info",
"retryCount": 0,
"totalPossibleRetries": 0,
"nextRetryAt": "2019-08-24T14:15:22Z",
"daysInDunning": 0,
"accessRestricted": true
}
}
}Empty
Empty
Empty