npm install @ionicfi/sdk gives you typed calls for every request
below; the server SDK guide has details. Each example also
shows raw curl.
Lifecycle
1
Create the subscription
Your server calls
POST /v1/subscriptions with a customer ID, one or more recurring-price items, and a collection method. An initial invoice is issued immediately unless the subscription opens with a trial.2
Trial period (optional)
When
trial_end is set, the subscription starts in trialing and no invoice is issued. At trial_end, Ionic charges default_payment_method and advances the status to active.3
Automatic renewals
At each
current_period_end, Ionic issues a renewal invoice and advances the period. A failed renewal moves the subscription to past_due; exhausting the retry period moves it to unpaid.4
Gate access with entitlement
Call
GET /v1/subscriptions/{id}/entitlement on each access check. Listen for subscription.updated and subscription.canceled webhooks to react to state changes.Create a subscription
Request fields
Item fields
The billing cycle
Each subscription exposes these period fields on the response object:Status values
Cancel a subscription
Passat_period_end: true to let the current period run out before canceling. Omit the field or pass false for an immediate cancellation.
canceled. A period-end cancellation sets cancel_at_period_end: true on the subscription; the status remains unchanged until the period ends, when the subscription is canceled automatically.
Resume a scheduled cancellation
Reverses a period-end cancellation that has not yet taken effect. Only valid whencancel_at_period_end is true.
Update items
Replaces the subscription’s billed items. Items with a knownid (si_…) are updated in place; items without an id are added as new items. All items must share the subscription’s existing currency and billing cadence.
Update collection method
Update default payment method
Passnull for default_payment_method to clear it.
Update metadata
Replaces the metadata map entirely. Keys absent from the request are removed.Check entitlement
Call the entitlement endpoint to check whether the subscription currently includes access. Useentitled as the gate.
Retrieve and list
customer, status, limit (default 20, max 100), and offset.
Webhooks
Read
data.object on every event for the full subscription snapshot. Do not infer access from the event type alone.
A period-end cancellation fires
subscription.updated with cancel_at_period_end: true. The subscription.canceled event arrives later, when the period ends. Keep the subscriber’s access open between these two events.Subscriptions for connected merchants
A platform creates and manages subscriptions for a connected merchant with its platform secret key. Send the merchant ID in theIonic-Account header, or pass
the account request option to the server SDK (@ionicfi/sdk 0.4.4 or later).
The subscription belongs to that merchant.
- The platform key and the merchant’s connection must both grant
subscriptions:write. To create the plan’s product and price for the merchant, both also needproducts:write. - The customer, prices, and payment method must belong to the selected
merchant in the same mode. An object from another merchant returns
404. - Creating, resuming, and changing items, collection method, or default
payment method need the merchant to be ready to take payments in that mode.
Until then they return
403 PAYMENTS_NOT_ENABLED(403 LIVE_PAYMENTS_NOT_ENABLEDin live mode), or422 account_not_yet_activewhile the merchant’s payment account is still being set up. Cancel and metadata updates don’t need payments to be ready, so you can stop billing after a merchant’s payments are disabled. Every write returns403 MERCHANT_INACTIVEwhile the merchant is not active. - The subscription issues and collects its own invoices, including renewals.
Your platform reads them with
invoices:readand needs no invoice write permission. See Connect billing. - Your platform webhook endpoint receives the merchant’s subscription events
when the connection grants
subscriptions:read. Each event names the merchant inevent.account.
Operational guidance
- Always send an
Idempotency-Keyon write requests. Network retries can otherwise create duplicate subscriptions, double item updates, or duplicate cancellations. - A
409 Conflictresponse means the subscription was modified concurrently. Retry the same request with the sameIdempotency-Key. - For
charge_automaticallysubscriptions, keepdefault_payment_methodcurrent. An expired card causes the renewal to fail and moves the subscription topast_due. - Store your plan IDs, seat counts, or feature flags in
metadata. Update metadata from your application layer; do not derive access decisions from it. - Use the entitlement endpoint for runtime access checks. Use webhooks to react to state changes asynchronously in your provisioning and access-control systems.
What’s next
Test a subscription lifecycle
Advance test time to verify trials, renewals, retries, and cancellations.
Review renewal invoices
Follow how each period’s invoice is issued and collected.
Read billing for connected accounts
Read a connected account’s subscriptions and gate access with entitlement.

