Subscriptions
A subscription is a recurring-billing schedule. The billing worker creates a charge for each cycle on the configured live channel. Use a live API key; test keys cannot manage subscriptions. Watcher-backed on-chain channels are rejected with channel_not_recurring, and test channels with channel_not_live. Settlement follows the selected channel: custodial or direct Stripe routing. GoCardless reuses an authorized mandate for later debits, and Stripe charges a saved card each cycle when the subscription opts into card on file; otherwise the payer completes a hosted checkout for each cycle. subscription.charged means a cycle order was created, not that payment succeeded; confirm funds through payment.succeeded. Lifecycle events are delivered as webhooks.
The subscription model
- Name
id- Type
- string
- Description
The subscription id, prefixed
sub_.
- Name
title- Type
- string
- Description
Human label for the subscription.
- Name
customer- Type
- string
- Description
Optional payer identifier (e.g. an email) stamped onto each generated order.
- Name
amount- Type
- string
- Description
Amount charged each cycle, as a decimal string.
- Name
currency- Type
- string
- Description
Pricing currency / asset.
- Name
channel- Type
- string
- Description
The channel each cycle charges on.
- Name
channel_name- Type
- string
- Description
Human-readable display name of that channel, resolved by the platform.
- Name
interval_unit- Type
- string
- Description
day,week, ormonth.
- Name
interval_count- Type
- integer
- Description
Number of units per billing period.
- Name
status- Type
- string
- Description
active,paused,past_due,canceled, orcompleted.
- Name
cycles_done- Type
- integer
- Description
Charges generated so far; also the next cycle's index.
- Name
total_cycles- Type
- integer
- Description
Cycle cap.
0means unlimited.
- Name
billing_anchor- Type
- timestamp
- Description
Fixed origin of the schedule (the first charge's due time).
- Name
next_charge_at- Type
- timestamp
- Description
When the next cycle is due.
- Name
ends_at- Type
- timestamp
- Description
Optional hard end — no charge is scheduled past this. May be
null.
- Name
last_order_id- Type
- string
- Description
The most recently generated order, or
null.
- Name
failure_count- Type
- integer
- Description
Consecutive billing failures (reset on success).
- Name
created_at- Type
- timestamp
- Description
When the subscription was created.
- Name
return_url- Type
- string
- Description
Where every cycle's hosted checkout sends the payer after paying. Absent when not set (the channel's own page).
- Name
cancel_url- Type
- string
- Description
Where every cycle's hosted checkout sends the payer who cancels it. Absent when not set.
- Name
tax_code- Type
- string
- Description
Stripe product tax code every cycle's charge carries. Absent when not set (the channel's default).
- Name
card_on_file- Type
- boolean
- Description
Whether each cycle charges the payer's saved card off-session (see Card on file).
- Name
mandate_ref- Type
- string
- Description
The reusable payment authorization later cycles charge, once there is one: a GoCardless mandate id, or for a Stripe saved card
cus_…:pm_…(Stripe ids only, never card data).
Card on file
On a Stripe channel (the platform's Stripe or your own Stripe key; not Stripe Connect), set card_on_file: true to bill each cycle without the payer:
- The first payment saves the card. Either create the subscription with
starts_atnow and let its first cycle be a hosted-checkout invoice (fromsubscription.charged'scheckout_url), or take the first payment yourself as a one-off charge withsave_payment_method: trueand create the subscription afterwards withpayment_method_order_idset to that paid order, so the card it saved is charged from the first cycle on. The card is recorded beforepayment.succeededis delivered, so you can create the subscription from that event; an order whose payer paid with a wallet saved no card and is refused with409 payment_method_not_saved. - Later cycles charge the saved card off-session.
subscription.chargedcarriesauto_charge:succeededmeans the card was charged andpayment.succeededfollows for the cycle's order (payment events of a subscription's order carrysubscription_idandsubscription_cycle). - A declined card falls back to an invoice. When the issuer declines (
auto_charge: "declined", withdecline_code), wants the payer to authenticate (authentication_required), or the saved card is gone (card_unavailable), nothing is charged: the cycle's order is a hosted-checkout invoice,subscription.chargedcarries itscheckout_url, and paying it saves the new card for the next cycles. An invoice left unpaid goes through the usual dunning (retries, thenpast_dueandsubscription.payment_failed).
While no card is saved every cycle is an invoice that saves one. Cards are saved on the Stripe account the cycle is charged on; if your Stripe routing changes (you save your own key, or link Stripe Connect), the next cycle is an invoice again. Moving the subscription to another channel drops the saved card. With your own Stripe key, your Stripe webhook endpoint must also listen to payment_intent.succeeded, which confirms an off-session charge. method must be empty or card. Fluxa never sees or stores card data, only Stripe's customer and payment-method ids.
List subscriptions
Signed locally — your secret stays in this browser and is never sent or stored.
No keys yet? Create an API key pair in the merchant portal — the secret is shown only once. Open the merchant portal →
Return your subscriptions as a plain data array.
Request
curl "$BASE/api/v1/subscriptions" \
-H "X-Api-Key: $KEY_ID" \
-H "X-Timestamp: $TS" \
-H "X-Signature: $SIG"
Response
{
"data": [
{
"id": "sub_9Qw8",
"title": "Pro plan",
"amount": "19.00",
"currency": "USD",
"channel": "stripe",
"interval_unit": "month",
"interval_count": 1,
"status": "active",
"cycles_done": 2,
"total_cycles": 0,
"next_charge_at": "2026-07-11T00:00:00Z"
}
]
}
Create a subscription
Signed locally — your secret stays in this browser and is never sent or stored.
No keys yet? Create an API key pair in the merchant portal — the secret is shown only once. Open the merchant portal →
Create a recurring schedule.
Required attributes
- Name
amount- Type
- string
- Description
Amount per cycle, as a decimal string.
- Name
currency- Type
- string
- Description
Pricing currency / asset.
- Name
channel- Type
- string
- Description
Channel
codeeach cycle charges on.
- Name
interval_unit- Type
- string
- Description
day,week, ormonth.
Optional attributes
- Name
title- Type
- string
- Description
Human label.
- Name
customer- Type
- string
- Description
Payer identifier stamped onto each order.
- Name
interval_count- Type
- integer
- Description
Units per period. Defaults to
1.
- Name
total_cycles- Type
- integer
- Description
Stop after this many cycles.
0(default) means unlimited.
- Name
ends_at- Type
- timestamp
- Description
Hard end date (RFC 3339).
- Name
starts_at- Type
- timestamp
- Description
First charge's due time (honored on create only). Defaults to now.
- Name
return_url- Type
- string
- Description
Where every cycle's hosted checkout sends the payer after paying, like a charge's
return_url(an absolutehttporhttpsURL, else400 invalid_return_url). On an edit, omitted means unchanged and""clears it.
- Name
cancel_url- Type
- string
- Description
Where every cycle's hosted checkout sends the payer who cancels it (
400 invalid_cancel_urlwhen not an absolutehttporhttpsURL). On an edit, omitted means unchanged and""clears it.
- Name
tax_code- Type
- string
- Description
Stripe product tax code every cycle's Checkout line item carries, with the same rules as a charge's
tax_code(400 invalid_tax_code,400 tax_code_required). On an edit, omitted means unchanged and""clears it.
- Name
card_on_file- Type
- boolean
- Description
Charge the payer's saved card off-session each cycle (Stripe channels; see Card on file). On a channel that cannot, or with
methodpinned to anything butcard, fails with400 card_on_file_unsupported. On an edit, omitted means unchanged.
- Name
payment_method_order_id- Type
- string
- Description
A paid live order of yours created with
save_payment_method: true: the subscription charges the card it saved, from the first cycle on. Impliescard_on_file. An order that saved no card fails with409 payment_method_not_saved; another merchant's order, or a test order, with400 invalid_payment_method_order.
Request
curl "$BASE/api/v1/subscriptions" \
-H "X-Api-Key: $KEY_ID" \
-H "X-Timestamp: $TS" \
-H "X-Signature: $SIG" \
-H "Content-Type: application/json" \
-d '{
"title": "Pro plan",
"customer": "ada@example.com",
"amount": "19.00",
"currency": "USD",
"channel": "stripe",
"interval_unit": "month",
"interval_count": 1
}'
Response
{
"id": "sub_9Qw8",
"title": "Pro plan",
"customer": "ada@example.com",
"amount": "19.00",
"currency": "USD",
"channel": "stripe",
"interval_unit": "month",
"interval_count": 1,
"status": "active",
"cycles_done": 0,
"total_cycles": 0,
"next_charge_at": "2026-06-11T00:00:00Z"
}
Retrieve a subscription
Signed locally — your secret stays in this browser and is never sent or stored.
No keys yet? Create an API key pair in the merchant portal — the secret is shown only once. Open the merchant portal →
Fetch one subscription plus its recent generated orders (its billing history).
Request
curl "$BASE/api/v1/subscriptions/sub_9Qw8" \
-H "X-Api-Key: $KEY_ID" \
-H "X-Timestamp: $TS" \
-H "X-Signature: $SIG"
Response
{
"subscription": {
"id": "sub_9Qw8",
"status": "active",
"cycles_done": 2,
"next_charge_at": "2026-07-11T00:00:00Z"
},
"orders": [
{ "id": "ord_5K2m", "status": "paid", "amount": "19.00" }
]
}
Update a subscription
Signed locally — your secret stays in this browser and is never sent or stored.
No keys yet? Create an API key pair in the merchant portal — the secret is shown only once. Open the merchant portal →
Edit the subscription's amount, currency, channel, title, customer, interval and end conditions. The schedule columns (cycles_done, next_charge_at, status) are not touched. Send the editable fields just as for create (starts_at is ignored here). card_on_file, payment_method_order_id, return_url, cancel_url and tax_code are the exception: omit them to leave them as they are. Changing channel drops the saved card.
Request
curl -X PUT "$BASE/api/v1/subscriptions/sub_9Qw8" \
-H "X-Api-Key: $KEY_ID" \
-H "X-Timestamp: $TS" \
-H "X-Signature: $SIG" \
-H "Content-Type: application/json" \
-d '{
"title": "Pro plan (annual)",
"amount": "190.00",
"currency": "USD",
"channel": "stripe",
"interval_unit": "month",
"interval_count": 12
}'
Change status
Signed locally — your secret stays in this browser and is never sent or stored.
No keys yet? Create an API key pair in the merchant portal — the secret is shown only once. Open the merchant portal →
Pause, resume or cancel a subscription.
Required attributes
- Name
status- Type
- string
- Description
active(resume),paused, orcanceled.
Request
curl -X PATCH "$BASE/api/v1/subscriptions/sub_9Qw8" \
-H "X-Api-Key: $KEY_ID" \
-H "X-Timestamp: $TS" \
-H "X-Signature: $SIG" \
-H "Content-Type: application/json" \
-d '{ "status": "paused" }'
Response
{
"id": "sub_9Qw8",
"status": "paused"
}