Create a plan
POST / v1 / plans
You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
Parameters
- currency enum Required Three-letter ISO currency code, in lowercase. Must be a supported currency.
- interval enum Required Specifies billing frequency. Either
day,week,monthoryear. Possible enum valuesdaymonthweekyear - product object Required The product whose pricing the created plan will represent. This can either be the ID of an existing product, or a dictionary containing fields used to create a service product.
- active boolean Whether the plan is currently available for new subscriptions. Defaults to
true. - amount integer Required unless billing_scheme=tiered A positive integer in the smallest currency unit (or 0 for a free plan) representing how much to charge on a recurring basis.
- metadata map Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata. - nickname string A brief description of the plan, hidden from customers.
More parameters
- amount _ decimal string
- billing _ scheme enum
- id string
- interval _ count integer
- meter string
- tiers array of objects Required if billing_scheme=tiered
- tiers _ mode enum Required if billing_scheme=tiered
- transform _ usage object
- trial _ period _ days integer
- usage _ type enum
Returns
Returns the plan object.
Response
{ "id": "plan_NjpIbv3g3ZibnD", "object": "plan", "active": true, "amount": 1200, "amount_decimal": "1200", "billing_scheme": "per_unit", "created": 1681851647, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "product": "prod_NjpI7DbZx6AlWQ", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed"}
Update a plan
POST / v1 / plans /:id
Updates the specified plan by setting the values of the parameters passed. Any parameters not provided are left unchanged. By design, you cannot change a plan’s ID, amount, currency, or billing cycle.
Parameters
- active boolean Whether the plan is currently available for new subscriptions.
- metadata map Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata. - nickname string A brief description of the plan, hidden from customers.
More parameters
- product string
- trial _ period _ days integer
Returns
The updated plan object is returned upon success. Otherwise, this call raises an error.
Response
{ "id": "plan_NjpIbv3g3ZibnD", "object": "plan", "active": true, "amount": 1200, "amount_decimal": "1200", "billing_scheme": "per_unit", "created": 1681851647, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": { "order_id": "6735" }, "nickname": null, "product": "prod_NjpI7DbZx6AlWQ", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed"}
Retrieve a plan
GET / v1 / plans /:id
Retrieves the plan with the given ID.
Parameters
No parameters.
Returns
Returns a plan if a valid plan ID was provided. Raises an error otherwise.
Response
{ "id": "plan_NjpIbv3g3ZibnD", "object": "plan", "active": true, "amount": 1200, "amount_decimal": "1200", "billing_scheme": "per_unit", "created": 1681851647, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "product": "prod_NjpI7DbZx6AlWQ", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed"}
