Subscriptions
Recurring plans with the full lifecycle handled for you: checkout, renewals, payment failures, cancellation, and a self-service customer portal.
1. Create your plans#
/v1/plans| Field | Type | Description |
|---|---|---|
slugrequired | string | Your stable ID — pro_monthly, starter… Use it everywhere instead of UUIDs. |
namerequired | string | Display name on the checkout and paywalls |
amountrequired | integer | Cents per period (min 50) |
interval | string | daily, weekly, monthly (default), yearly, or one_time for a lifetime purchase |
currency | string | eur (default), usd, gbp |
trial_days | integer | Free trial length (1–365). Recurring plans only. |
entitlements | string[] | Feature keys this plan unlocks — ["pro", "no_ads"] |
description | string | Shown on the checkout page |
Plans exist per environment — create them in test mode first, then again in live mode (dashboard toggle, or your sk_live_ key) when you launch, with the same slugs. All endpoints accept the slug or the UUID interchangeably.
Plans can't be edited after creation. To change a price, create a new plan and point your paywalls at it; existing subscribers stay on their plan. Deleting a plan deactivates it for new checkouts — its slug stays reserved, so pick a new one (e.g. pro_monthly_v2).
2. Subscribe a customer#
/v1/subscriptions| Field | Type | Description |
|---|---|---|
plan_idrequired | string | Plan slug or UUID |
customer_idrequired | string | YOUR identifier — user id, device id, email, anything stable |
customer_email | string | Pre-fills the checkout email field |
success_url / cancel_url | string | Where the customer lands after paying / backing out — a web URL or an app deep link. Optional if defaults are set in Settings, otherwise required (400). |
offer_token | string | Signed discount from paywall resolve (win-back offers) — the SDK paywalls pass it for you |
{
"id": "8f3c2a1e-5b7d-4c1a-9e2f-0a6b3c4d5e6f",
"url": "https://paylo-six.vercel.app/pay/8f3c2a1e-5b7d-4c1a-9e2f-0a6b3c4d5e6f",
"status": "pending"
}Open url in the browser. The subscription activates when the payment completes; abandoned checkouts expire automatically after 24h. The same endpoint sells one_time plans (lifetime access): the purchase then stays active for good. Accepts an Idempotency-Key header.
url; the customer lands on your success_url once they pay.Free trials#
Set trial_days on a plan (API or dashboard) and everything follows: the checkout collects the card but charges nothing, the subscription starts as trialing(which counts as active for feature gating and paywall targeting), paywalls advertise the trial automatically (“7-day free trial” on the plan, “7 days free, then €9.99/mo” under the CTA), and Stripe charges when the trial ends. A failed first charge goes through the normal past_due dunning flow.
Webhooks: subscription.trial_started at checkout, subscription.trial_ending 3 days before the first charge (nudge your customer), then the usual subscription.renewed when it converts. In the customer status, is_trial and active_plan.trial_end tell you where the customer stands. Trials are excluded from MRR until they convert.
3. Gate premium features#
/v1/customers/:customerId/status{
"customer_id": "user_42",
"has_active_subscription": true,
"is_trial": false,
"entitlements": ["pro", "no_ads"],
"can_manage": true, // false for lifetime (one_time) purchases
"scheduled_change": null, // a pending downgrade — see Change plan
"active_plan": {
"name": "Pro Monthly",
"slug": "pro_monthly",
"amount": 999,
"currency": "eur",
"interval": "monthly",
"current_period_end": "2026-08-12T00:00:00.000Z"
// "trial_end": "…" while in a free trial
},
"subscriptions": [
{ "id": "8f3c2a1e-…", "status": "active", "plan_name": "Pro Monthly", "created_at": "…" }
]
}Check has_active_subscription on app launch. active, trialing and cancelling all count as active — a cancelling customer keeps access until the period ends. past_due does not: access stops when a renewal fails and comes back if Stripe's retry succeeds.
With multiple tiers, gate by entitlement instead of plan name: set feature keys on each plan (e.g. pro_monthly and pro_yearly both grant "pro"), then in the app: status.hasEntitlement('pro'). The response returns the union across all the customer's active and trialing subscriptions, so pricing changes never touch app code.
Lifecycle & statuses#
pending ──▶ (trialing) ──▶ active ──▶ cancelling ──▶ cancelled
│
├──▶ past_due (charge failed — Stripe retries)
├──▶ refunded (via POST /v1/refunds)
└──▶ expired (checkout abandoned)POST /v1/subscriptions/:id/cancel is two-step: the first call schedules cancellation at period end (cancelling), calling it again force-cancels immediately. A pending checkout is cancelled right away, a scheduled downgrade is dropped, and an ended subscription (cancelled, refunded, expired) returns 400. If Stripe refuses the cancellation you get a 502and nothing changes — it never reports a cancellation that didn't happen.
Change plan (upgrade / downgrade)#
/v1/subscriptions/:id/change-plan| Field | Type | Description |
|---|---|---|
new_plan_idrequired | string | Target plan slug or UUID — same currency, not one-time |
preview | boolean | true = return the proration amount, apply nothing |
The server picks the timing for you. An upgrade (or a same-priced lateral move) swaps the price and invoices the proration immediately; a downgrade takes effect at the end of the current period via a Stripe subscription schedule. Works on active, trialing (no proration during a trial) and cancelling subscriptions — an upgrade undoes a pending cancellation. It refuses a change to the same plan, to a one-time plan, or across currencies (400 with a reason), and returns 409 if a change is already scheduled.
{
"status": "ok",
"change": {
"type": "upgrade", // upgrade | downgrade | lateral
"timing": "immediate", // immediate | period_end
"from_plan": "pro_monthly",
"to_plan": "pro_yearly",
"currency": "eur"
},
"subscription": { "id": "8f3c2a1e-…", "status": "active", "plan_id": "<new plan UUID>", "current_period_end": "…" }
}
// preview: true → "change" also has "proration_amount" (cents billed now)
// downgrade → "change.effective_at" + "subscription.pending_plan_id"A scheduled downgrade surfaces on GET /v1/customers/:id/status as scheduled_change (with plan_name and effective_at), so your app can show “Switches to Starter on Aug 12”.
PayloAccountView shows an “Other plans” list automatically — preview, confirmation and apply are handled for you. For custom UIs: Paylo.switchPlan('pro_yearly').Customer portal (manage / cancel)#
/v1/subscriptions/:id/portalReturns { url } — a Stripe-hosted portal where the customer can cancel, update their payment method and download invoices, no UI to build. return_url is optional (defaults to your Success URL). In the SDKs: Paylo.openManagement() (Flutter) or paylo.openPortal(subscriptionId, returnUrl:), with the id from customerStatus(...).activeSubscription. Not available for lifetime purchases (can_manage: false).
Refunds#
/v1/refunds| Field | Type | Description |
|---|---|---|
subscription_idrequired | string | Subscription to refund |
reason | string | Stored on the Stripe refund |
Refunds the subscription's most recent successful charge, cancels it on Stripe immediately (access ends), and sets the status to refunded. A subscription can be refunded only once — a second call returns 400. Also available as a button in the dashboard. Lifetime (one_time) purchases and one-time sessions can't be refunded through the API yet.
past_due and fire the subscription.payment_failed webhook. Stripe retries automatically; a successful retry flips it back to active.