Skip to main content
POST
Create a subscription

Authorizations

Authorization
string
header
required

Use a Bouclay secret key (sk_test_..., sk_live_...) or restricted key (rk_test_..., rk_live_...).

A secret key can call every endpoint. A restricted key can only call the endpoints its scopes cover. A scope is {resource}:{access}, for example customers:read or refunds:write, and write includes read. GET requests need read access and everything else needs write, except POST /subscriptions/{id}/items/{item}/preview, which only needs subscriptions:read. A request outside the key's scopes gets 403 permission_denied naming the missing scope, and its Idempotency-Key is not used up.

Publishable keys (pk_...) are rejected by server-side API endpoints. A key's mode scopes what it can see and charge: a test key can never reach a live card.

Headers

Idempotency-Key
string
required

Required for POST and PATCH requests. Replays identical method + path + body requests and rejects mismatched re-use.

Required string length: 1 - 255

Body

application/json
customer
string
required
collectionMode
enum<string>
required

automatic charges a card. A subscription with something due today opens incomplete and starts on its first payment. manual sends invoices to pay by transfer or on the hosted invoice page: it opens active at once, on its payment terms (daysUntilDue), and an invoice still unpaid a day after it's due turns it past_due and is chased by reminder emails, then suspended as your dunning settings say.

Available options:
automatic,
manual
items
object[]
required

The base plan first, then add-on plans. Each plan is taken whole: a plan made of several charges goes on as one item per active charge, each at its price in one way to pay. Name it with a planId (and billingInterval when it offers several), or with one or more of its prices: the other charges are filled in with the only price each offers in that way to pay. A plan with one charge is the price given, as always. A meter is billed by one charge per subscription.

Minimum array length: 1
paymentMethod
string
trialEndBehavior
enum<string>
Available options:
cancel,
pause,
create_invoice
daysUntilDue
integer | null

Payment terms for this subscription's manual invoices: each is due this many days after it's issued (0 is due on receipt). Left out, the business's payment terms apply (7 days unless changed in Billing settings, Invoicing). Manual dunning counts from the due date. Ignored for automatic collection.

Required range: 0 <= x <= 365
reference
string

The buyer's purchase order number or other reference, printed as "Your reference" on every invoice the subscription issues (PDF, hosted page, invoice and receipt emails).

Maximum string length: 100
requirePaymentMethod
boolean

Overrides the business setting for this subscription. When nothing is due at signup (every paid price is billed at the end of the period) and no paymentMethod is given, true opens the subscription incomplete behind a small card-verification invoice that is refunded once it settles; false starts it active with no card. Ignored for manual collection and free subscriptions.

On a free trial the business setting doesn't apply: a trial needs a card when its price has trialRequiresPaymentInfo, or when this is true. It then opens incomplete behind the card check and becomes trialing once the card is saved; abandoned there, it expires like any unpaid start and doesn't use up the customer's trial.

invoicingThreshold
number | null

Early access: refused until metered billing is turned on for your account.

Invoice usage early once what the subscription has used this period, and not yet been billed for, reaches this amount. Fixed fees never count toward it. The period's own invoice then bills only the rest.

Required range: x >= 0
minimumCommitment
number | null

Early access: refused until metered billing is turned on for your account.

The least the subscription bills each billing period, in major units of its currency. Fees, usage and prorations count toward it after discounts and before tax; credit the customer spends still counts. When a period bills less, the invoice that closes it adds a minimum line for the difference (with the next period's fees when the subscription bills up front, or on the final invoice when it is cancelled). A trial owes none; a period cut short by a cancellation, or paused for part of it, owes its share.

Required range: x >= 0
spendingCap
object

Early access: refused until metered billing is turned on for your account.

The most the subscription bills each billing period. Spend is what the period bills, after discounts and before tax: its usage (covers: usage, the default) or everything it bills (covers: all). A cap that stops billing (behavior: cap, the default) takes what goes past it off the invoice that bills it, with a negative maximum line; fees billed up front are always billed in full. One that only warns (behavior: warn) bills in full. At each point in warnAt (percent of the cap) your app gets spend_alert.created, once per period and cap.

discountCode
string

A discount code as the customer typed it, matched without regard to case. It is redeemed onto the subscription and takes money off its invoices from the first one (after a trial, the conversion invoice). A code no discount has, or one that has expired, is switched off, is used up or doesn't cover these prices, is refused with a 422 on discountCode saying why, and nothing is created. Not with discount.

Maximum string length: 255
discount
string

A discount's id (disc_…), in place of discountCode. Refused the same way.

Response

Subscription response.

data
object
required
meta
object
required