Skip to main content
POST
Error

Authorizations

Authorization
string
header
required

A merchant secret key (sk_…) sent as Authorization: Bearer <key>.

Headers

Ionic-Account
string

Merchant ID when an authorized Platform acts for a connected Merchant. Omit when authenticating directly as that Merchant.

Pattern: ^mer_[0-9A-Za-z]{14}$
Idempotency-Key
string

A unique key that makes retries safe: the same key with the same request body returns the original response instead of repeating the operation.

Maximum string length: 255

Body

application/json
customer
string
required

Customer id (cus_…).

items
object[]
required

The recurring prices and quantities to bill.

collection_method
enum<string>
required

One of charge_automatically (charged automatically against the default payment method) or send_invoice (the buyer pays each invoice through the hosted invoice page).

Available options:
charge_automatically,
send_invoice
default_payment_method
string | null

Payment method id (pm_…). Required for charge_automatically subscriptions that start with a trial.

trial_start
integer | null

Unix epoch seconds. Start of the trial period. Defaults to the creation time when trial_end is set.

trial_end
integer | null

Unix epoch seconds. End of the trial period. No initial invoice is issued while the subscription is trialing.

metadata
object

Custom key-value pairs for your use.

Response

The created subscription.

id
string
required

Unique identifier for the subscription (sub_…).

object
enum<string>
required
Available options:
subscription
customer
string
required

Customer id (cus_…).

status
enum<string>
required

incomplete: created; first invoice not yet paid. trialing: in free trial; no invoice yet (or a zero-total one). active: most recent invoice paid; in good standing. past_due: most recent invoice payment failed; in dunning. unpaid: dunning exhausted; service stopped. Terminal. canceled: terminated (immediately or at period end). Terminal.

Available options:
incomplete,
trialing,
active,
past_due,
unpaid,
canceled
collection_method
enum<string>
required

One of charge_automatically (charged automatically against the default payment method) or send_invoice (the buyer pays each invoice through the hosted invoice page).

Available options:
charge_automatically,
send_invoice
items
object[]
required

The recurring prices and quantities the subscription bills.

current_period_start
integer
required

Unix epoch seconds. Start of the current billing period.

current_period_end
integer
required

Unix epoch seconds. End of the current billing period.

billing_cycle_anchor
integer
required

Unix epoch seconds. The reference point used to compute period boundaries.

cancel_at_period_end
boolean
required

True when the subscription is scheduled to cancel at the end of the current period.

metadata
object
required

Custom key-value pairs for your use.

livemode
boolean
required
test_clock
string | null
required

The logical billing clock inherited from the customer; null when the subscription uses wall-clock time.

created_at
integer
required

Unix epoch seconds.

updated_at
integer
required

Unix epoch seconds when the subscription was last updated.

default_payment_method
string | null

The payment method used for automatic renewal charges (pm_…). Null when not set.

trial_start
integer | null

Unix epoch seconds. Start of the trial period. Null when the subscription was not created with a trial.

trial_end
integer | null

Unix epoch seconds. End of the trial period. Null when no trial.

canceled_at
integer | null

Unix epoch seconds. When the cancellation was requested. Null while not canceled.

ended_at
integer | null

Unix epoch seconds. When the subscription terminated. Null while active.

latest_invoice
string | null

Most recent invoice id (inv_…). Null before the first invoice is issued.