Subscriptions
A subscription bills a customer for one or more recurring prices on the same billing period. Each period produces an invoice that Bias charges to the saved card or bank account, or emails to the customer. The subscriptions guide covers renewals and failed payments, and plan changes covers proration.
The Subscription object
- Name
object
- Type
- "subscription",
- Description
- The object's type.
- Name
id
- Type
- string,
- Description
- Unique identifier for the object.
- Name
live
- Type
- boolean,
- Description
trueif the object is live, orfalseif it's in a sandbox.
- Name
created_at
- Type
- integer,
- Description
- When the object was created, in milliseconds since the Unix epoch.
- Name
billing_cycle_anchor_at
- Type
- integer,
- Description
- When billing periods are counted from, as a Unix timestamp in milliseconds. Renewals fall on the anchor's day and time in UTC.
- Name
cancel_at
- Type
- integer or null,
- Description
- When the subscription is scheduled to be canceled, as a Unix timestamp in milliseconds. Null once it's canceled.
- Name
cancel_at_period_end
- Type
- boolean,
- Description
- Whether the subscription cancels at the end of its current period.
- Name
canceled_at
- Type
- integer or null,
- Description
- When the subscription was canceled or scheduled to be canceled, as a Unix timestamp in milliseconds.
- Name
cancellation_details
- Type
- object,
- Description
- Why the subscription was canceled or is scheduled to be canceled.
- Properties
- Name
collection_method
- Type
- enum,
- Description
- How the invoice is paid.
- Properties
- Name
customer
- Type
- string or Customer,
- Description
- Expandable. The customer who is subscribed.
- Name
days_until_due
- Type
- integer or null,
- Description
- For
send_invoicesubscriptions, the number of days the customer has to pay each invoice.
- Name
default_payment_method
- Type
- string or null,
- Description
- The saved payment method charged for renewals. When null, the customer's
default_payment_methodis charged.
- Name
default_taxes
- Type
- array of objects,
- Description
- The taxes applied to each invoice.
- Properties
- Name
ended_at
- Type
- integer or null,
- Description
- When a canceled subscription ended, as a Unix timestamp in milliseconds.
- Name
incomplete_expires_at
- Type
- integer or null,
- Description
- For an
incompletesubscription, when it's canceled if its first invoice still isn't paid, as a Unix timestamp in milliseconds.
- Name
items
- Type
- array of object,
- Description
- The prices the subscription bills each period.
- Properties
- Name
latest_invoice
- Type
- string or Invoice or null,
- Description
- Expandable. The most recent invoice for this subscription.
- Name
metadata
- Type
- object,
- Description
- Your own key-value data on the object.
- Name
next_renewal_at
- Type
- integer or null,
- Description
- When the subscription next renews, as a Unix timestamp in milliseconds. Null when it won't renew.
- Name
payment_retries_end_at
- Type
- integer or null,
- Description
- For a
past_duesubscription, when payment retries stop, as a Unix timestamp in milliseconds.
- Name
pending_change
- Type
- object or null,
- Properties
- Name
resumes_at
- Type
- integer or null,
- Description
- When a paused subscription resumes on its own, as a Unix timestamp in milliseconds. Null for a pause with no end.
- Name
shipping_cost
- Type
- object or null,
- Description
- The shipping charged each period.
- Properties
- Name
shipping_details
- Type
- object or null,
- Description
- Where each period's order is shipped.
- Properties
- Name
status
- Type
- enum,
- Description
- The status of the subscription.
- Properties
- Name
trial_end_at
- Type
- integer or null,
- Description
- When the trial ends and the first paid period starts, as a Unix timestamp in milliseconds.
- Name
trial_start_at
- Type
- integer or null,
- Description
- When the trial started, as a Unix timestamp in milliseconds.
- Name
updated_at
- Type
- integer,
- Description
- When the object was last updated, in milliseconds since the Unix epoch.
The Subscription object
The SubscriptionItem object
A subscription’s items are the prices it bills each period. They’re changed by updating the subscription.
- Name
object
- Type
- "subscription_item",
- Description
- The object's type.
- Name
id
- Type
- string,
- Description
- Unique identifier for the object.
- Name
created_at
- Type
- integer,
- Description
- When the object was created, in milliseconds since the Unix epoch.
- Name
current_period
- Type
- object,
- Description
- The item's current billing period.
- Properties
- Name
metadata
- Type
- object,
- Description
- Your own key-value data on the object.
- Name
price
- Type
- Price,
- Properties
- Name
quantity
- Type
- integer, at least 1,
- Description
- The quantity billed.
- Name
subscription
- Type
- string,
- Description
- The subscription this item belongs to.
The SubscriptionItem object
Create a subscription
A new subscription bills the customer for its items every period. With a trial, it’s trialing and nothing is invoiced until the trial ends. Otherwise its first invoice is finalized in the request and charged with charge_automatically, or emailed with send_invoice.
If the first charge is declined, the subscription is incomplete until the invoice is paid, and is canceled at incomplete_expires_at. With payment_behavior: error_if_incomplete, the decline is returned as a payment_error instead.
Required parameters
- Name
customer
- Type
- string,
- Description
- The customer to subscribe.
- Name
items
- Type
- array of object,
- Description
- The prices to bill each period, all on the same interval.
- Properties
Optional parameters
- Name
expand
- Type
- object,
- Properties
- Name
default_payment_method
- Type
- string or null,
- Description
- The saved payment method charged for renewals. When null, the customer's
default_payment_methodis charged. An unattached payment method is attached to the customer.
- Name
collection_method
- Type
- enum,
- Description
- How each invoice is paid. Defaults to
charge_automatically. - Properties
- Name
off_session
- Type
- boolean,
- Description
- Whether the customer is absent for the first charge. Defaults to
false, which starts the recurring agreement renewals refer to. Withtrue, the first invoice is charged like a renewal, which requires the customer's earlier agreement to be charged with this payment method.
- Name
payment_behavior
- Type
- enum,
- Description
- What happens if the first invoice's charge is declined.
- Properties
- Name
days_until_due
- Type
- integer or null,
- Description
- For
send_invoicesubscriptions, the number of days the customer has to pay each invoice. Defaults to 30.
- Name
default_taxes
- Type
- array of objects,
- Description
- The taxes applied to each invoice.
- Properties
- Name
trial_period_days
- Type
- integer, at least 1, at most 730,
- Description
- Starts the subscription with a free trial of this many days.
- Name
trial_end_at
- Type
- integer,
- Description
- Starts the subscription with a free trial that ends at this Unix timestamp in milliseconds. Billing periods are counted from the trial end.
- Name
cancel_at
- Type
- "period_end" or integer or null,
- Description
- Cancels the subscription at this Unix timestamp in milliseconds, or with
period_end, at the end of the first period. Unused time isn't credited.
- Name
shipping_details
- Type
- object or null,
- Description
- Where each period's order is shipped.
- Properties
- Name
shipping_rate
- Type
- string or null,
- Description
- The shipping rate to charge each period, at its amount when the subscription is created.
- Name
metadata
- Type
- object or null,
- Description
- Your own key-value data on the object.
Returns
Returns the subscription object.
Create a subscription
Response example
Get a subscription
Retrieve a subscription by its ID.
Required parameters
- Name
id
- Type
- string,
- Description
- The ID of the subscription to retrieve.
Optional parameters
- Name
expand
- Type
- object,
- Properties
Returns
Returns the subscription object.
Retrieve a subscription
Response example
Preview the upcoming invoice
The upcoming invoice shows what a customer will pay at their next renewal, or what a plan change would cost them before they confirm it.
These fields are specific to upcoming invoices and differ from the Invoice object:
periodis the period the renewal bills for.prorationbreaks down what a plan change would credit and charge immediately.balance_appliedis how much of the customer’s balance the renewal would use after any proration credit.amount_billedis what the renewal would charge afterbalance_applied.
Required parameters
- Name
id
- Type
- string,
- Description
- The ID of the subscription to preview.
Optional parameters
- Name
items
- Type
- array of object,
- Description
- Item changes to preview, in the same shape as an update.
- Properties
- Name
apply_at
- Type
- enum,
- Description
- When a change to
itemstakes effect. Defaults tonow. - Properties
- Name
proration_behavior
- Type
- enum,
- Description
- How changing
itemsmid-period is billed. Defaults toalways_invoice. - Properties
- Name
proration_at
- Type
- integer,
- Description
- When the change is prorated from, as a Unix timestamp in milliseconds. Defaults to now.
Returns
Returns the upcoming invoice, or a no_upcoming_invoice error if the subscription won’t renew, for example because it’s paused, canceled, or set to cancel before its next renewal.
Preview the upcoming invoice
Response example
Update a subscription
Updates change what a subscription bills and how: its items, payment method, collection method, taxes, shipping or scheduled cancellation. Item changes are prorated unless proration_behavior is none.
A change with a prorated charge applies once its invoice is paid, and is discarded if it isn’t paid within 15 minutes. With payment_behavior: error_if_incomplete, a decline is returned as a payment_error instead.
Setting a payment method on a subscription with an unpaid invoice charges that invoice right away.
Required parameters
- Name
id
- Type
- string,
Optional parameters
- Name
expand
- Type
- object,
- Properties
- Name
items
- Type
- array of object,
- Description
- Items to add, change or remove.
- Properties
- Name
apply_at
- Type
- enum,
- Description
- When a change to
itemstakes effect. Defaults tonow. - Properties
- Name
proration_behavior
- Type
- enum,
- Description
- How changing
itemsmid-period is billed. Defaults toalways_invoice. - Properties
- Name
proration_at
- Type
- integer,
- Description
- When the change is prorated from, as a Unix timestamp in milliseconds. Defaults to now. The
proration_atfrom an upcoming invoice preview made in the last 30 minutes charges what the preview showed.
- Name
payment_behavior
- Type
- enum,
- Description
- What happens if the charge for a change to
itemsis declined. - Properties
- Name
pending_change
- Type
- null,
- Description
nullcancels the scheduled change. Changingitemsalso cancels or replaces it.
- Name
default_payment_method
- Type
- string or null,
- Description
- The saved payment method charged for renewals. When null, the customer's
default_payment_methodis charged.
- Name
collection_method
- Type
- enum,
- Description
- How future invoices are paid.
- Properties
- Name
days_until_due
- Type
- integer or null,
- Description
- For
send_invoicesubscriptions, the number of days the customer has to pay each invoice.
- Name
default_taxes
- Type
- array of objects,
- Description
- The taxes applied to each invoice.
- Properties
- Name
trial_end_at
- Type
- "now" or integer,
- Description
- For a trialing subscription, when the trial ends, as a Unix timestamp in milliseconds.
nowends the trial and starts the first paid period immediately.
- Name
cancel_at
- Type
- "period_end" or integer or null,
- Description
- Cancels the subscription at this Unix timestamp in milliseconds, or with
period_end, at the end of the current period. Unused time isn't credited.nullremoves a scheduled cancellation.
- Name
cancellation_details
- Type
- object,
- Description
- The customer's reason for canceling.
- Properties
- Name
shipping_details
- Type
- object or null,
- Description
- Where each period's order is shipped.
- Properties
- Name
shipping_rate
- Type
- string or null,
- Description
- The shipping rate to charge from the next renewal, at its current amount.
nullstops charging shipping.
- Name
metadata
- Type
- object or null,
- Description
- Your own key-value data on the object.
Returns
Returns the subscription object.
Update a subscription
Response example
List all subscriptions
Retrieve a paginated list of subscriptions, most recently created first.
Optional parameters
- Name
expand
- Type
- object,
- Description
- Related objects to expand in the response.
- Properties
- Name
ending_before
- Type
- string,
- Description
- The ID of the object to list before, for pagination.
- Name
starting_after
- Type
- string,
- Description
- The ID of the object to list after, for pagination.
- Name
limit
- Type
- integer, at least 1, at most 1000, default is 50
- Description
- The maximum number of objects to return, from 1 to 1000. Defaults to 50.
- Name
filters
- Type
- object, object, or object,
- Description
- Properties
Returns
Returns a list of subscription objects.
List all subscriptions
Response example
Cancel a subscription
Canceling ends an active subscription immediately.
To schedule a cancelation, update with cancel_at instead.
With proration enabled, the unused value is credited to the customer’s balance or refunded.
Required parameters
- Name
id
- Type
- string,
Optional parameters
- Name
expand
- Type
- object,
- Properties
- Name
prorate
- Type
- boolean,
- Description
- Credits the unused time on the current period with a credit note. Defaults to
false.
- Name
unused_credit
- Type
- enum,
- Description
- What happens to the credit
prorateissues for the unused time.keep(the default) adds it to the customer's balance, andrefundrefunds what's left of it to the period's payments. - Properties
- Name
cancellation_details
- Type
- object,
- Description
- Why the customer canceled.
- Properties
Returns
Returns the canceled subscription object.
Cancel a subscription
Response example
Pause a subscription
Pausing stops a subscription’s renewals until it’s resumed, or until resumes_at. A pause until the end of the next period skips one renewal.
Required parameters
- Name
id
- Type
- string,
Optional parameters
- Name
expand
- Type
- object,
- Properties
- Name
resumes_at
- Type
- integer or null,
- Description
- When the subscription resumes on its own, as a Unix timestamp in milliseconds. Without it, the subscription stays paused until it's resumed.
Returns
Returns the paused subscription object.
Pause a subscription
Response example
Resume a subscription
Resuming restarts billing for a paused subscription. If the paid period hasn’t ended, billing continues on its schedule; otherwise a new period starts and is billed right away.
Required parameters
- Name
id
- Type
- string,
Optional parameters
- Name
expand
- Type
- object,
- Properties
Returns
Returns the subscription object.