Skip to navigation

Create Subscription

View as Markdown
Create a subscription and optionally process payment.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Path parameters

account_idstringRequired

Headers

Idempotency-Keystring or nullOptional>=8 characters
A unique key for this request. A retry with the same key returns the first response instead of running again, for 24 hours. Keys are per caller.

Request

This endpoint expects an object.
customer_idstringRequired
period_startdatetimeRequired
itemslist of objectsRequired
currencyenum or nullOptional
ISO 4217 currency codes.
period_enddatetime or nullOptional
descriptionstring or nullOptional
notestring or nullOptional

Optional free-text note to attach to the subscription. A non-empty value creates the note; omit it to attach none. Additive to description and backed by the same /notes record.

billing_intervalstring or nullOptional
billing_interval_countinteger or nullOptional>=1
trial_startdatetime or nullOptional
trial_enddatetime or nullOptional
total_billing_cyclesinteger or nullOptional>=1
contract_auto_renewboolean or nullOptional
collection_methodenumOptional
Allowed values:
net_dinteger or nullOptional>=0

Payment terms in days (Net X) for this subscription’s invoices: each is due this many days after it is issued. When unset, send_invoice invoices are due 30 days after issue and charge_automatically invoices are due on issue.

statement_descriptor_suffixstring or nullOptional

Statement descriptor suffix for this subscription. When set, overrides the default descriptor on renewals. A suffix too long for the account’s effective prefix is trimmed to fit; an empty, non-Latin or letterless suffix, or one with forbidden characters, is a 422.

statement_descriptor_overridesmap from strings to strings or maps from strings to strings or nullOptional

FULL statement descriptor override map, keyed by processor id (proc_…). When a charge runs on a keyed processor, its value is sent as the whole descriptor and takes precedence over the processor’s own statement descriptor and statement descriptor prefix. Two shapes are accepted. Flat: {“proc_…”: “DESCRIPTOR”} applies to every charge. By charge type: {“one_time”: {“proc_…”: ”…”}, “trial_conversion”: {…}, “recurring”: {…}} picks the descriptor by the kind of charge: one_time is a checkout charge that starts no subscription; trial_conversion is the first paid renewal of a subscription that had a trial, including its retries; recurring is every other subscription charge, including the first charge of a subscription with no trial. When the charge’s type has no entry for the processor, a trial_conversion charge uses the recurring entry, then the processor’s own statement descriptor; a one_time charge uses the processor’s own statement descriptor, else the prefix (the processor’s statement descriptor prefix, else the account prefix) plus the checkout’s suffix, and never the recurring entry. The two shapes cannot be mixed, and only one_time, trial_conversion and recurring are valid charge types (422 otherwise). Supported processors: Adyen, Checkout.com, Authorize.net, Airwallex and NMI. Stripe, PayPal, Braintree and other processors are not allowed as keys (422). Caveats: Authorize.net applies it only on TSYS/EVO-backed accounts; Airwallex applies it only after dynamic descriptors are enabled on the Airwallex account; NMI applies it only when custom descriptors are allowed on the processor. Applies to renewal/MIT charges. Keys must resolve to supported processors in the account (422 otherwise). Each value may be at most 22 characters after unsupported characters (< > \ ’ ” * and non-Latin) are removed; a longer value is rejected with a 422.

cancel_at_period_endboolean or nullOptional
default_payment_method_idstring or nullOptional
metadatamap from strings to any or nullOptional
process_paymentboolean or nullOptionalDefaults to false
idempotency_keystring or nullOptional
processor_idstring or nullOptional
processor_route_idstring or nullOptional

Processor route to pin to this subscription, in place of a separate POST /subscriptions/{id}/route call. While the account’s routing engine is enabled and the route applies, it overrides routing rules and the account default for the subscription’s card charges from the first one on, renewals and dunning retries included. An invoice of the subscription created with its own processor_route_id (POST /invoices) is charged through that route instead. A plan change that moves items to a new subscription (a different billing interval or contract terms) does not carry the pin to it; pin that subscription through POST /subscriptions/{id}/route. It applies only to card payment methods. Engine on or off, a pinned subscription’s charges never fall back to a network-token charge on a processor outside the route. Change it with POST /subscriptions/{id}/route and remove it with DELETE /subscriptions/{id}/route. A route that cannot be used is not pinned, and the subscription is still created: it runs the account’s routing (its routing rules, then the account default) as if no route had been named, and the response’s routing object gives fallback_reason and fallback_detail. That happens when the route is not an active route of this account (route_not_found, route_inactive), when it stops every payment (route_stops_every_payment), or when the first invoice’s automatic charge provably could never go through it (route_cannot_charge_card): no card that charge tries reaches a processor the route names that is active, supports the subscription currency and, for a card with an active India e-mandate, is the mandate’s processor. Which cards that charge tries: default_payment_method_id alone when the subscription is charged at create (process_payment, off-session charging allowed for the account, no running trial, not future-dated, a non-zero amount); otherwise default_payment_method_id first (with none, the most recently updated payment method), then the customer’s other payment methods up to the account’s fallback limit. When the first invoice’s discount (from coupon_id or promotion_code, or the customer’s own discount) and the customer’s spendable credit may cover the items’ amount, or the amount cannot be stated (a price whose amount cannot be computed, a trial-extension coupon), either may apply, and the route falls back only if it fails both ways. A card saved on no active processor, or held by its mandate, ends the attempt. Not checked, among others: a route whose effect depends on the payment (conditions, a weighted split over routes, last-successful-only); a default_payment_method_id the create charge cannot use (another customer’s, inactive, not usable off-session), which it does not replace with another card; a customer the charge would try no payment method for (none saved, or none it can use off-session); anything after a non-card payment method the charge reaches, which the pin does not apply to; and a send_invoice subscription, which is never charged automatically. routing also reports the route the charge made at create went through (charge_route_id, charge_route_decision_source); both are null when nothing was charged or the routing engine is off, in which case a route that can be used is still pinned and applies once the engine is on. Setting it requires the routing_rule:edit permission, like the dedicated route endpoint (403 otherwise).

coupon_idstring or nullOptional
promotion_codestring or nullOptional
custom_fieldsmap from strings to any or nullOptional
Custom field values to set on this subscription. Keys must match defined field keys for the subscription entity type. Set a key to null to delete that field's value.
simulation_idstring or nullOptional
ID of simulation this subscription belongs to. Only for simulated subscriptions.

Response

Successful Response
idstring
stateenum

The possible states of a subscription.

Most are self-explanatory: it starts INCOMPLETE (created, not yet paid for), or TRIALING / SCHEDULED, becomes ACTIVE once paid, and can end up PAUSED, PAST_DUE (a payment failed), or CANCELLED.

ACTIVE_UNSETTLED is the unusual one, added for slow bank rails like SEPA where the money does not arrive until days later. It means: “we already let the customer in at checkout, but their payment has not actually settled yet.” A subscription is created straight into this state — nothing ever moves INTO it from another state. It has exactly two ways out: it becomes ACTIVE if the payment settles, or CANCELLED if the payment fails, times out, or is later reversed (a chargeback).

INCOMPLETE_EXPIRED is terminal, and is where a subscription ends up when its first payment never completed. It exists to say something CANCELLED cannot: this subscription was never really bought. A cancellation is a customer leaving something they had; an expiry is a purchase that never happened. Keeping the two apart stops “never converted” being counted as churn, and — because it is terminal — takes the subscription out of the duplicate-product guard, so the customer is free to try that purchase again.

currencyenum
ISO 4217 currency codes.
descriptionstring or null
current_period_startdatetime
current_period_enddatetime
trial_startdatetime or null
trial_enddatetime or null
created_atdatetime
updated_atdatetime
itemslist of objects
customerobject
collection_methodenum
Allowed values:
payment_methodobject or null
Payment method API response model.
payment_statusstring or null

What the collection reported for the first payment, as a PaymentCollectionStatus value — the same vocabulary as POST /invoices/{invoice_id}/collect. Money was collected only for paid, already_paid and processing; requires_action means the customer must complete 3DS. Everything else means nothing was collected, and the value says why (no_payment_method, not_collectible, send_invoice, au_deferred, failed, …). Null when no collection was attempted at all — process_payment was false, or the subscription is scheduled to start later.

payment_errorstring or null

The collection’s own explanation of payment_status, when it has one — a processor decline reason, or why no charge was submitted. Null when the payment succeeded or nothing was attempted.

notestring or nullOptional

Free-text note attached to this subscription. Additive to description: read/written inline here as a convenience, and backed by the same /notes record (one note per object).

billing_intervalstring or nullOptional
billing_interval_countinteger or nullOptional
billing_anchor_dayinteger or nullOptional

Day of month (1-31) month and year periods renew on. A month without that day renews on its last day, and the next period returns to the anchor (Jan 31 -> Feb 28 -> Mar 31). Null: each period steps from the last end.

paused_atdatetime or nullOptional
resumes_atdatetime or nullOptional
pause_at_endboolean or nullOptional
cancel_at_period_endboolean or nullOptional
cancel_atdatetime or nullOptional
cancellation_refund_optionenum or nullOptional

Refund options when cancelling a subscription.

  • NONE: Cancel with no refund (current behavior)
  • FULL: Refund full current period amount
  • PRORATED: Refund unused portion of current period
  • CANCEL_UNPAID: Use dunning_end_behavior for unpaid invoices
Allowed values:
cancellation_detailsobject or nullOptional

Details about why a subscription was cancelled.

All fields are optional — callers can provide any combination. Stored as JSONB on the subscription entity.

net_dinteger or nullOptional
statement_descriptor_suffixstring or nullOptional
Statement descriptor suffix for this subscription.
statement_descriptor_overridesmap from strings to strings or maps from strings to strings or nullOptional

FULL statement descriptor override map, keyed by processor id (proc_…). When a charge runs on a keyed processor, its value is sent as the whole descriptor and takes precedence over the processor’s own statement descriptor and statement descriptor prefix. Two shapes are accepted. Flat: {“proc_…”: “DESCRIPTOR”} applies to every charge. By charge type: {“one_time”: {“proc_…”: ”…”}, “trial_conversion”: {…}, “recurring”: {…}} picks the descriptor by the kind of charge: one_time is a checkout charge that starts no subscription; trial_conversion is the first paid renewal of a subscription that had a trial, including its retries; recurring is every other subscription charge, including the first charge of a subscription with no trial. When the charge’s type has no entry for the processor, a trial_conversion charge uses the recurring entry, then the processor’s own statement descriptor; a one_time charge uses the processor’s own statement descriptor, else the prefix (the processor’s statement descriptor prefix, else the account prefix) plus the checkout’s suffix, and never the recurring entry. The two shapes cannot be mixed, and only one_time, trial_conversion and recurring are valid charge types (422 otherwise). Supported processors: Adyen, Checkout.com, Authorize.net, Airwallex and NMI. Stripe, PayPal, Braintree and other processors are not allowed as keys (422). Caveats: Authorize.net applies it only on TSYS/EVO-backed accounts; Airwallex applies it only after dynamic descriptors are enabled on the Airwallex account; NMI applies it only when custom descriptors are allowed on the processor. The processor receives at most 22 characters of each value.

total_billing_cyclesinteger or nullOptional
remaining_billing_cyclesinteger or nullOptional
contract_auto_renewboolean or nullOptional
discountobject or nullOptional
Response schema for discount data.
last_successful_processor_idstring or nullOptional

ID of the processor that last successfully charged this subscription. Historical record only — the next charge is routed by the payment method’s own processor attempt history, which may differ if the payment method has since changed.

processor_route_idstring or nullOptional

The processor route pinned to this subscription, or null when none is. While the account’s routing engine is on and the route is active, its card charges go through this route ahead of routing rules and the account default, except an invoice’s that has its own route (Invoice.processor_route_id). Set at create (processor_route_id) or with POST /subscriptions/{id}/route.

metadatamap from strings to any or nullOptional
split_from_subscriptionstring or nullOptional

ID of the subscription this was split from (cross-interval plan change).

split_to_subscriptionslist of strings or nullOptional

IDs of subscriptions created from this one (cross-interval plan change).

pending_plan_changeobject or nullOptional
Pending plan change scheduled for period end. Present when a deferred plan change is awaiting execution.
custom_fieldsmap from strings to any or nullOptional

Custom field values. Only included when expand=custom_fields is specified.

custom_fields_errorobject or nullOptional

Present (with HTTP 200) when the request’s custom_fields were rejected and DROPPED — custom_fields writes are all-or-nothing, so one unrecognized key or one wrong-typed value drops the whole set. Carries the submitted input and the reason. Null when custom fields were accepted or none were sent. Check it even on a successful create, since the subscription is still created.

routingobject or nullOptional

What became of the requested processor_route_id: pinned, or not pinned and why (the subscription then runs the account’s routing), plus the route the first charge made by this request went through. Present only when the request named a route.

Errors

422
Unprocessable Entity Error