This page covers the API. To end or restore a subscription in the app, see Subscriptions. For the lifecycle, see Subscriptions explained.
subscriptions:write scope. Both return the updated subscription.
End a subscription
POST /v1/subscriptions/{id}/end takes a single required field, when.
Ending a subscription doesn’t refund or credit the current period. The customer keeps what they’ve paid for.
End at period end
End now
Withnow you can also clean up the subscription’s invoices in Xero. Both options default to false, so Saasybill leaves your accounting documents alone unless you say otherwise.
Both are refused, with
422, when when is period_end. Invoices are only removed when a subscription ends now.
Ending near renewal
If the next period’s renewal invoice has already been raised, a subscription that won’t renew has no use for it. Ending the subscription, now or at period end, voids the invoice in Xero if it was approved, or deletes it. Restoring later raises the invoice again. The end is refused while that invoice has a payment or credit on it, because the customer has already paid for the next period. The answer is409 invalid_state. To end it after that period, change End after in the subscription’s details in the app.
When it can’t be ended
A subscription that can’t be ended answers409 invalid_state, with a message that says why. Examples include a subscription that has already ended, and Setup Mode when you ask to remove invoices, because nothing can be changed in Xero.
Restore a subscription
POST /v1/subscriptions/{id}/restore undoes an end. It takes an empty JSON object.
- a subscription set to end at period end, which goes back to renewing
- an
endedsubscription, before its renewal date
When it can’t be restored
A subscription that can’t be restored answers409 invalid_state, with a message that says why.
Tell your platform
Both actions send webhooks, so you can confirm the outcome without polling.
See Webhook events.