Subscription Lifecycle
- Applies to
- Gateway+Developer Portal
- Hosting
- Managed EdgeManaged DedicatedSelf-Hosted
This guide covers the full lifecycle of a customer subscription: creation, trials, upgrades, downgrades, cancellation, and reactivation.
Subscription states
A subscription's lifecycle status is computed from its activeFrom/activeTo
window — it is not a stored field, and transitions happen automatically as time
passes. The four possible values reflect lifecycle only; payment status is
tracked separately (see the note below).
| Status | API access | Description |
|---|---|---|
active | Yes | Currently in effect with no scheduled end |
canceled | Yes | Scheduled to end at a future date; access continues until that date |
inactive | No | Has ended, or was canceled before becoming active |
scheduled | No | Has not yet started — activeFrom is in the future |
When a customer cancels a subscription with next_billing_cycle timing, its
status flips from active to canceled immediately (with activeTo set to the
period end). The customer keeps access throughout the canceled window, and the
status transitions to inactive once activeTo passes. A subscription in the
canceled state can be reactivated — see Reactivation below.
Access is also governed by payment status, which is tracked separately. If a
renewal payment is overdue beyond the grace period (default 3 days), access is
blocked even for active subscriptions. The first payment of a subscription,
including the first charge after a trial ends, has no grace period, so access is
blocked until it succeeds. The grace period is configurable per-customer,
per-plan, or per-bucket — see
Subscription and payment validation.
In the Zuplo admin UI, lifecycle status and payment status are combined into
derived display labels such as "Access Blocked" or "Payment Failed" to surface
the effective state at a glance. In the Developer Portal, a subscription with a
future activeTo (whether active or canceled) is shown with an "Expiring"
badge and the upcoming end date.
Creating subscriptions
Self-serve (Developer Portal)
The standard path. Customer signs up in the Developer Portal, picks a plan, completes Stripe Checkout, and gets their API key immediately.
- Customer visits the pricing page
- Clicks "Subscribe" on their chosen plan
- Completes Stripe Checkout (enters payment details)
- Returns to the Developer Portal to review the subscription summary
- Clicks "Confirm & Subscribe" to finalize
- Subscription is active, API key is generated
In the Zuplo Portal
You can create a subscription for a customer yourself, for example for a sales-assisted signup:
- Open Services → Monetization → Customers and select the customer.
- Click Create Subscription.
- Under Published plan, select a plan. Only published plans appear.
- Confirm the Customer email.
- Under Start subscription, choose Immediately or On a specific date. For a specific date, enter a Start date and time in the future.
- Click Create Subscription.
To find a customer, type in the Search customers... box on the Customers page. The search matches the customer's name, customer key, and email address.
Programmatic (API)
Create subscriptions directly via the API for cases where the checkout happens outside the Developer Portal (custom frontend, sales-assisted onboarding, internal tooling):
1. Create the customer
The subscription belongs to an existing customer. Customers who subscribe in the Developer Portal get a customer record automatically. For a customer who hasn't subscribed there yet, create the customer first.
The Developer Portal finds a user's subscriptions and API keys through the
customer whose key is the user's sub claim from your identity provider. Set
both sub and key to that value, or the customer won't see the subscription
in the Developer Portal:
Code
| Field | Required | Description |
|---|---|---|
sub | Yes | The user's sub claim from your identity provider. The user becomes the customer's owner. |
email | No | The owner's email address. |
key | No | The customer's identifier. Set it to the same value as sub so the Developer Portal can find the customer. When omitted, it defaults to a generated cus_ value, which the Developer Portal can't match to the user. |
billingName | No | The customer's display name, used for billing. Defaults to key. |
billingEmail | No | The email address for billing and invoices. Defaults to email. The customer needs a billing email or an email before you can subscribe them, and it becomes the contact on the subscription's API keys. |
currency | No | A three-letter currency code, such as USD. It must match the currency of the plans you subscribe the customer to. When omitted, the customer's first paid subscription sets it. |
usageAttribution | No | { "subjectKeys": [...] }, the subjects whose usage counts toward this customer. Defaults to key. Set it only when your usage events use a different subject. |
Other optional fields are firstName, lastName, description, metadata,
and billingAddress. The endpoint returns 201 Created with the customer and
its owner in members. It returns 403 Forbidden when your API key can't edit
the bucket, 409 Conflict when a customer already has the key (use that
customer instead), and 422 Unprocessable Entity for any field it doesn't
accept.
To subscribe the customer to a paid plan through the API, the customer also needs a Stripe customer with a default payment method. Otherwise the subscription fails the billing setup check described under Errors. For a customer without one, have them subscribe through Stripe Checkout in the Developer Portal instead.
2. Create the subscription
Code
| Field | Required | Description |
|---|---|---|
planId | Yes | The plan's ID. List plans with GET /v3/metering/{bucketId}/plans. |
customerId | Yes | The customer's id from the create customer response, or its key. |
customerEmail | Yes | The customer's email address. For a private plan, it must be an invited email address. |
timing | No | "immediate" (the default) or a UTC timestamp in RFC 3339 format ending in Z or +00:00, such as "2027-01-01T00:00:00Z". A future timestamp schedules the start. |
addons | No | Add-ons to attach, each as { "addon": { "id": "<addonId>" }, "quantity": 1 }. quantity defaults to 1, and an optional timing ("immediate" by default) sets when the add-on starts. |
apiKey | No | An existing API key to import for the subscription, instead of generating a new one. The key must not already exist in the bucket. |
The endpoint rejects any other field with 422 Unprocessable Entity.
A successful request returns 201 Created with the subscription and its
consumer, which holds the subscription's API keys. When the customer's key
is the user's sub, the user sees the subscription and its API key in the
Developer Portal.
Errors
Error responses use the
Problem Details format, and detail
says what went wrong.
| Status | When |
|---|---|
400 | A field has an invalid value, such as a timing that isn't "immediate" or a UTC timestamp. Also returned when the customer has no primaryEmail or key, or has a pending or failed payment on a current subscription. |
403 | Your API key can't edit the bucket, or the plan is private and customerEmail doesn't have an invite to it. |
404 | The plan or the customer doesn't exist. |
409 | The customer already has a subscription to this plan, has reached the maximum number of active subscriptions, or the plan isn't available for purchase. Also returned when an imported apiKey already exists, or the billing setup check fails (see the next table). |
422 | The body has a field the endpoint doesn't accept, such as plan, customerKey, or billingAnchor, or a field has the wrong type. |
A subscription to a paid plan must pass a billing setup check. When the check
fails, the endpoint returns 409 Conflict and doesn't create the subscription.
The detail names the cause:
| Cause | Fix |
|---|---|
| Billing isn't set up for the bucket | Connect Stripe in the Monetization settings. See Stripe integration. |
| The customer isn't linked to a Stripe customer | Have the customer subscribe through Stripe Checkout in the Developer Portal, or link them to a Stripe customer first. |
| The linked Stripe customer doesn't exist in the connected Stripe account | Link the customer to a Stripe customer in this account. A test-mode Stripe customer doesn't exist in a live-mode account. |
| The Stripe customer has no default payment method, or the payment method no longer exists | Add or update the customer's payment method in Stripe. |
| The default payment method has no billing address | Add a billing address to the payment method in Stripe. |
| The Stripe customer has no email address, which invoice collection needs to send invoices | Add an email address to the Stripe customer. |
Listing a customer's subscriptions with
GET /v3/metering/{bucketId}/customers/{customerId}/subscriptions returns
404 Not Found when the customer doesn't exist or was deleted.
Free trials
Trials are modeled as the first phase of a multi-phase plan. No special trial API is needed.
How trials work
- Customer subscribes to a plan that has a trial phase
- The subscription is activated with the trial phase's entitlements (e.g., 1,000 requests)
- When the trial phase duration expires:
- The subscription transitions to the next phase (the paid phase)
- Stripe charges the customer for the first paid period
- Entitlements update to the paid phase's rate cards
- If that first charge fails, access is blocked until it succeeds. The payment grace period covers later renewals, not the first charge after the trial
Trial configuration example
14-day trial with automatic conversion to paid:
Code
This plan gives customers a 14-day trial with 1,000 requests (hard limit, no billing). When the trial ends, they automatically transition to the paid Pro phase at $99/month with 50,000 requests and overage billing. No cron jobs, no webhook handlers, no transition code.
What happens when a trial expires
If the plan has a paid phase after the trial:
- Stripe charges the customer automatically
- On success: subscription transitions to the paid phase with paid entitlements
- On failure: access is blocked until the payment succeeds. The grace period doesn't cover the first charge after the trial
What happens if the customer cancels during the trial depends on whether the trial phase has billable rate cards:
- Free trial (no priced rate cards in the trial phase, like the example above): no payment is charged and the trial does not convert to the paid phase. In the Developer Portal, the customer can keep access until the trial period ends (the default) or end the subscription immediately
- Paid trial (the trial phase has a price, e.g., a $1 introductory rate):
access continues until the end of the trial period (default
next_billing_cycletiming), the trial fee is billed on the final invoice, and the trial does not convert to the subsequent paid phase
Plan changes (upgrades and downgrades)
Customer-initiated (Developer Portal)
Customers can change plans from the Manage Subscription section in the Developer Portal:
- Customer clicks "Switch Plan" on their active subscription
- Sees available plans with pricing comparison
- Selects the new plan
- Stripe handles proration (charge or credit the difference)
- For an upgrade, new entitlements take effect immediately; for a downgrade, they apply at the next billing cycle
- The API key stays the same
In the Zuplo Portal
To move a customer's subscription to a different plan, open the subscription from the customer's Subscriptions tab and use the buttons in Subscription Information.
Change plan:
-
Click Change plan.
-
Under Plan, select the new plan. The list includes the published plans in the subscription's currency, including private plans, and excludes the plan the subscription is already on.
-
Under When it applies, choose a timing:
Timing What happens Immediately The new plan starts now. Next billing cycle The current plan stays until the billing period ends. Automatic Upgrades start now. Downgrades start at the next billing cycle. -
Click Confirm change.
Changing the plan cancels every manual top-up on the subscription and removes its remaining balance.
Cancel plan change: while a change is scheduled, the subscription shows a Cancel plan change button. Click it, then click Cancel plan change again in the dialog to delete the scheduled subscription and keep the current one active. You can't cancel a change in the last 5 minutes before it takes effect, and top-ups already canceled by the change aren't restored.
Programmatic (API)
Plan changes go through the dedicated change endpoint, which closes the
current subscription and starts a new one on the target plan:
Code
| Field | Required | Description |
|---|---|---|
planId | Yes | The ID of the plan to change to. |
timing | No | "immediate" or "next_billing_cycle". When omitted, upgrades take effect immediately and downgrades take effect at the next billing cycle. |
customerEmail | No | An invited email address, for a change to a private plan. Defaults to the customer's primary email. |
The endpoint rejects any other field with 422 Unprocessable Entity.
The response is the new subscription, which has a new ID. The customer's consumer and API key move to the new subscription, so the key keeps working.
The errors follow the create endpoint, with these differences:
400when the subscription is inactive or has ended, or the target plan is the current plan or isn't active.404when the subscription doesn't exist.
To preview the proration credit before committing, call
POST /v3/metering/{bucketId}/subscriptions/{subscriptionId}/change/estimate-credit
with the same timing.
Proration behavior
When a customer changes plans mid-billing-period, Zuplo uses max_consumption_based proration to calculate a fair credit from the old plan. Instead of only considering how much time has passed, the system looks at both elapsed time and actual quota usage, then uses whichever is greater.
This prevents situations where a customer consumes most of their quota early in the billing period, switches plans, and receives a large time-based credit that does not reflect their actual usage.
Upgrade (e.g., Starter → Pro):
- New entitlements take effect immediately
- A proration credit from the old plan appears as a line-item discount on the new plan's invoice
Downgrade (e.g., Pro → Starter):
- New (lower) entitlements take effect at the next billing cycle
- No proration credit is issued. The customer keeps the higher-tier entitlements for the remainder of the current cycle they already paid for.
Example: A customer on Starter ($29/month, 10,000 requests) upgrades to Pro on day 15 of a 30-day period, having used 7,000 requests.
| Factor | Value |
|---|---|
| Time elapsed | 50% (15 / 30) |
| Quota consumed | 70% (7K / 10K) |
| Max of the two | 70% |
| Credit applied | $8.70 |
The credit amount is calculated once at the moment of the plan change. It is applied as a line-item discount on the next invoice's upfront flat-fee line. If the credit exceeds that line's amount, the remainder cascades onto subsequent invoices in chronological order until it is fully consumed.
Quota on plan change
Each subscription tracks its own quota independently. When a customer changes plans, a brand-new subscription is created and its entitlement starts measuring usage from the switch time — usage from the previous plan does not count against the new plan's quota.
Walking through the example above: a customer used 8,000 of their 10,000-request Starter quota in the first 15 days. After upgrading to Pro on day 15, the customer has the full 50,000-request Pro quota available from day 15 onward, regardless of how much was used on Starter. The 8,000 stays attributed to the Starter subscription for billing purposes only.
Gaming via short-lived upgrades is constrained by two other mechanisms:
- Downgrades take effect at the next billing cycle (not immediately), so a customer cannot briefly upgrade and immediately downgrade to grab a fresh quota.
- Max-consumption-based proration issues zero refund when the old plan's quota was already mostly consumed (see Proration behavior above), so paying for a short-lived upgrade is not economical.
Cancellation
Customer-initiated
Customers can cancel from the Manage Subscription section in the Developer Portal:
- Customer clicks Cancel subscription.
- The dialog asks When should your subscription end? with two options: At the end of the billing period (the default) and Immediately.
- Customer types the plan name to confirm and clicks Cancel subscription.
- With At the end of the billing period, the customer keeps access until the period ends, then access is revoked and the API key stops working. With Immediately, access stops right away.
A subscription still in its free trial phase works the same way. The default is the end of the billing period, which is the end of the trial. The subscription ends before the trial converts to the paid phase, so nothing is charged whichever option the customer picks.
If the cancellation fails, the dialog shows the reason under Could not cancel subscription and leaves the subscription unchanged.
A customer who cancels at the end of the billing period can change their mind before it ends. The subscription shows Resume subscription in Manage Subscription, which removes the pending cancellation.
In the Zuplo Portal
To cancel a customer's subscription yourself, open it from the customer's Subscriptions tab and click Cancel subscription. Choose Next billing cycle (access continues until the period ends) or Immediately (access is revoked right away), then click Confirm cancel.
Programmatic cancellation
Code
timing controls when the cancellation takes effect:
- Omitted (or
"immediate") — the subscription is canceled immediately and access stops right away. Use this for refund-style flows. "next_billing_cycle"— access continues until the end of the current billing period, then is revoked. This matches the Developer Portal default.- An RFC 3339 timestamp — schedule cancellation at a specific time.
Cancellation behavior
| Scenario | Behavior |
|---|---|
| Customer cancels (Developer Portal) | Customer chooses; defaults to access until period end, then revoked |
| Customer cancels during a free trial | Defaults to the end of the trial; nothing is charged either way |
| Cancel with Immediately | Access is revoked right away |
| Subscription with overage | Overage billed on final invoice |
| Cancellation fails | The dialog shows the reason and the subscription is unchanged |
Reactivation
A canceled subscription (scheduled for end-of-period) can be reactivated before the period ends:
Code
This removes the pending cancellation. The subscription continues as normal.
In the Zuplo Portal
Open a subscription that is scheduled to cancel and click Restore. The dialog shows the scheduled end date. Click Confirm restore to clear the end date and return the subscription to active, or Keep canceled to leave it. Restore is available only until the scheduled end date passes.
In the Developer Portal, customers use Resume subscription in Manage Subscription for the same result.
If the subscription has already ended, create a new subscription rather than restoring the old one.
Subscription API keys in the Zuplo Portal
The subscription page in the Zuplo Portal has an API Keys card for the linked consumer.
- Click the eye icon to show a key, or the copy icon to copy it.
- Click Roll API key to create a replacement key. Under Expire old key, choose Immediately or At a specific date and time and enter the Expiration (local time), then click Confirm roll. Update your applications to the new key before the old key expires.
- Click Edit consumer to change the consumer's metadata. The subject and key manager are read-only.
- When a consumer has more than three keys, View all shows the rest.
To manage keys through the API, see Manage subscriber API keys.
Subscriptions per customer
By default, each customer can hold one active subscription at a time. The
Developer Portal returns 409 Conflict ("the maximum number of active
subscriptions has been reached") when a customer tries to subscribe while
another subscription is still active or pending cancellation — a subscription in
the canceled wind-down state still counts toward the cap.
To allow more, turn on Allow multiple subscriptions under Payment
Provider → Billing & Subscriptions in the Zuplo Portal, or set
multipleSubscriptionsEnabled in the
bucket monetization configuration.
A customer still can't hold two subscriptions on the same plan. Use it for
scenarios like:
- A primary monthly subscription plus a credit pack top-up
- Separate subscriptions for different API products
- A team subscription and a personal subscription
Each subscription is bound to its own consumer record and its own API key, both generated when the subscription is created. When a customer holds multiple subscriptions, they use the appropriate key for each.