Create plan
const url = 'http://localhost:8080/v1/plans';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"code":"example","name":"example","description":"example","currency":"example","billing_interval":"monthly","base_amount_cents":1,"base_bill_timing":"in_advance","prices":[{"meter_id":"example","dimension_match":{"additionalProperty":"example"},"mode":"per_unit","unit_amount_cents":"example","tiers":[{"up_to":1,"unit_amount_cents":"example"}],"package_size":1,"package_amount_cents":"example"}],"status":"active","tax_code":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/v1/plans \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "code": "example", "name": "example", "description": "example", "currency": "example", "billing_interval": "monthly", "base_amount_cents": 1, "base_bill_timing": "in_advance", "prices": [ { "meter_id": "example", "dimension_match": { "additionalProperty": "example" }, "mode": "per_unit", "unit_amount_cents": "example", "tiers": [ { "up_to": 1, "unit_amount_cents": "example" } ], "package_size": 1, "package_amount_cents": "example" } ], "status": "active", "tax_code": "example" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Makes the call safe to retry. Send a unique value (a UUID works) and
the same value on every retry. For 24 hours, a repeat with the same
key, method, path and body gets the first response again, with an
Idempotent-Replayed: true header, instead of running again. The
error cases are in docs/api-surface.md. The usage routes do not take
it: each usage event carries its own idempotency_key.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Required when base_amount_cents is above 0. With a base
of 0 it may be left out, and the plan is in_arrears;
in_advance with a base of 0 is refused. See
Plan.base_bill_timing (ADR-031).
The plan’s usage prices, created with it in one request. Each takes the plan’s currency.
One price to add to a plan.
object
The labels an event must carry for the price to take it.
Values are strings of 1 to 100 characters, keys too; at
most 16 labels. Omitted or {} takes every event of the
meter. Two prices of one plan and meter that could both take
one event with the same number of labels are refused (409
price_conflict).
object
per_unit bills quantity × unit_amount_cents. graduated bills each tier’s part of the quantity at that tier’s rate. package bills ceil(quantity ÷ package_size) × package_amount_cents: a part package bills as a whole one.
Price per unit in cents, as a decimal string (e.g. “0.0003” = $3.00 per 1,000,000 units). Used when mode is per_unit. 0 or more, under 10^18, at most 12 decimal places (trailing zeros do not count), and at most 100 characters. A JSON number is also read. A value outside them is refused with 422 and param naming the field. Invoice line amounts round to whole cents.
Used when mode is graduated. Each up_to is a whole number above the one before. The last tier has up_to: null (no upper bound), and only the last. Otherwise 422 with param tiers. A tier’s rate takes the limits of unit_amount_cents; a refusal names tiers[i].unit_amount_cents (i counts from 0).
object
The tier’s upper bound in whole units: the tier prices the quantity above the previous tier’s bound, up to this one. null on the last tier, which has no upper bound. Only the last tier is null, and it must be.
Price per unit in cents in this tier, as a decimal string.
Used when mode is package. Must be above 0.
Price of one package in cents, as a decimal string (e.g. “0.2” with package_size 1000 = $0.002 per 1,000 units), with the limits of unit_amount_cents. Used when mode is package.
Optional. A plan is created active; archive it with PATCH.
Stripe product tax code for the base fee, such as
txcd_10103001. Empty or omitted means the tenant’s
default_product_tax_code.
Responses
Section titled “Responses”Plan created, with its prices
A plan as Get, Create and Update plan answer it.
object
When the recurring base fee is invoiced relative to the period it covers. in_arrears: base + usage billed at period end. in_advance: base billed at period start (day 1 on create; cycle-close invoice carries upcoming period’s base + elapsed period’s usage). Usage lines are always arrears regardless of this field. A plan with no base fee is in_arrears. See ADR-031.
The plan’s usage prices from now on. A plan’s meters are the meters it has a price for.
One usage price of a plan: a meter, the events it takes
(dimension_match) and its rate. The price takes the plan’s
currency. Its id stays the same when its rate changes; its meter
and dimension_match are its identity and never change.
object
The labels an event must carry for this price to take it, for
example {"model": "claude-opus-4.5", "token_type": "input"}.
{} takes every event of the meter. Of the prices whose labels
an event carries, the one with the most labels takes it.
object
As on PriceShape.
Price per unit in cents, as a decimal string.
Empty ([]) unless mode is graduated.
object
The tier’s upper bound in whole units: the tier prices the quantity above the previous tier’s bound, up to this one. null on the last tier, which has no upper bound. Only the last tier is null, and it must be.
Price per unit in cents in this tier, as a decimal string.
Price of one package in cents, as a decimal string.
When the content shown was saved.
Stripe tax code for this plan. Absent means the tenant’s default_product_tax_code.
Whether a subscription has ever used the plan (canceled ones and scheduled plan changes included). On a plan no one has used, a price change applies at once; on a used plan, from each subscriber’s next billing period, and from the join for a subscriber who first joins the plan in a period after it.
Subscriptions on this plan that are not canceled. While it
is above 0, base_amount_cents cannot change (see Update
plan).
Example
{ "billing_interval": "monthly", "status": "active", "base_bill_timing": "in_advance", "prices": [ { "id": "hc_prc_1a2b3c4d5e6f7890abcdef12", "mode": "per_unit" } ]}price_exists: two prices name the same meter and
dimension_match. price_conflict: two prices on one meter
could both take one event with the same number of labels, so
neither would win; the message names the other price, and
param names the second one. Nothing is created.
object
object
One of invalid_request_error, authentication_error,
rate_limit_error or api_error. Every error the API
answers has this shape, including an unknown path (404,
code route_not_found) and a method the path does not take
(405, code method_not_allowed, with an Allow header).
The few exceptions are listed in docs/api-surface.md.
The request field the error is about. Sent only when the error
names one. A request body may hold only the fields its
operation lists, spelled and cased as listed: any other
field, or one the server sets (such as id), is refused
with 422 and param naming it. An operation with no request body lists no fields: send
no body, {} or null. The Stripe and Postmark webhooks and
the LiteLLM callback take their sender’s body as it comes.
Example
{ "error": { "type": "invalid_request_error" }}A field failed validation (a price names an unknown meter, a
rate is outside its limits, base_bill_timing is missing with a
base fee above 0 or is in_advance with a base of 0), status
is set to anything but active (a plan is created active;
archive it with PATCH), or the body has an unknown field
(param names it, prices[i]. first for a price; the body must
use only the fields listed here).
object
object
One of invalid_request_error, authentication_error,
rate_limit_error or api_error. Every error the API
answers has this shape, including an unknown path (404,
code route_not_found) and a method the path does not take
(405, code method_not_allowed, with an Allow header).
The few exceptions are listed in docs/api-surface.md.
The request field the error is about. Sent only when the error
names one. A request body may hold only the fields its
operation lists, spelled and cased as listed: any other
field, or one the server sets (such as id), is refused
with 422 and param naming it. An operation with no request body lists no fields: send
no body, {} or null. The Stripe and Postmark webhooks and
the LiteLLM callback take their sender’s body as it comes.
Example
{ "error": { "type": "invalid_request_error" }}