# Subscription plans

> Create, list, change and archive subscription plans from your own code. A plan is a price many customers can subscribe to, with its own sign-up page.

Source: https://railbed.com/docs/api/subscription-plans/ · Updated: 2026-11-23 · Railbed developer docs

For AI assistants: the index of every docs page, with the rules for an integration, is https://railbed.com/docs/llms.txt

## The plan object

A plan is a price many customers can subscribe to: a name, an amount per period and how often it bills, with an optional free trial. It's the same plan you make under [Subscriptions](https://app.railbed.io/subscriptions) → Plans in the dashboard, and it shows up there. Its `url` is a public sign-up page where a customer gives their name and email and pays the first invoice. You can also put a customer on it yourself with [Create a subscription](https://railbed.com/docs/api/subscriptions.md#create-a-subscription) and `plan`.

A plan only sets what new subscriptions start with. Each [subscription](https://railbed.com/docs/api/subscriptions.md) copies the plan's price, interval, trial and settings when it's made, so changing or archiving a plan never changes the subscriptions already on it. Nothing is ever charged automatically: each period, a subscription issues an [invoice](https://railbed.com/docs/api/invoices.md) its customer pays themselves.

| Field | Type | Description |
|---|---|---|
| `id` | string | The plan's id, `spl_…` |
| `object` | string | `"subscription_plan"` |
| `livemode` | boolean | `false` for Test mode, `true` for Live mode |
| `name` | string | What customers see, such as `Pro`. Each invoice's line reads it |
| `description` | string or null | A sentence or two for the sign-up page |
| `features` | array | Up to 8 short texts the sign-up page lists |
| `currency` | string | `USD`, `EUR`, `GBP`, `CAD`, `AUD`, `INR` or `SEK` |
| `amount` | string | One period's price before tax, such as `"49.00"` |
| `interval` | object | How often it bills: `unit` (`day`, `week`, `month` or `year`) and `count`, such as `{ "unit": "month", "count": 3 }` for every three months |
| `trial_days` | integer | Free days before the first paid period, `0` for none |
| `tax_percent`, `tax_label` | string or null | The tax each invoice adds (`"8.25"`, `"Sales tax"`) |
| `terms` | string or null | Your terms, printed on each invoice |
| `billing` | object | How each period's invoice is sent and collected. See [The billing object](#the-billing-object) |
| `routing` | object | Which card providers its invoices offer. See [The routing field](https://railbed.com/docs/api/payment-links.md#the-routing-field) |
| `collect` | object or null | What the payment page asks besides the email. See [The collect field](https://railbed.com/docs/api/checkout-sessions.md#the-collect-field) |
| `success_url` | string or null | Where the customer lands once an invoice is paid |
| `payout_wallet_id` | string or null | The saved wallet its invoices pay, `pw_…`, or `null` for the account's payout wallet |
| `self_serve` | boolean | Whether its page takes sign-ups. Off, the page says so and only you add subscribers |
| `url` | string | The sign-up page, `https://pay.railbed.io/subscribe/…`. Share it, or link to it from your pricing page |
| `status` | string | `active`, or `archived`: it takes no new subscribers, and its subscribers carry on |
| `subscribers` | object | Its subscriptions now: `paying` (started, and active or past due), `trialing`, and `total` (every one not canceled) |
| `mrr` | string | What its paying subscribers add up to a month, before tax, in its currency |
| `version` | integer | Goes up with every change. Send it back as `expected_version` when you [update it](#update-a-subscription-plan) |
| `created`, `updated` | integer | When it was made and last changed, in Unix seconds |
| `warnings` | array | On create and update only, and only when there is something to say: what the card providers' minimums mean for this price. See [Provider minimums](https://railbed.com/docs/api/checkout-sessions.md#provider-minimums) |

Example: A plan · response 200 OK

```json
{
  "id": "spl_8Hq2mVx5RtLc3NwZb7Ks",
  "object": "subscription_plan",
  "livemode": false,
  "name": "Pro",
  "description": "Everything in Starter, plus priority support.",
  "features": [
    "5 seats",
    "Priority support",
    "Monthly report"
  ],
  "currency": "USD",
  "amount": "49.00",
  "interval": {
    "unit": "month",
    "count": 1
  },
  "trial_days": 0,
  "tax_percent": null,
  "tax_label": null,
  "terms": "Cancel any time from your subscription page.",
  "billing": {
    "lead_days": 7,
    "terms_days": 3,
    "cancel_after_days": 14,
    "reminders": [
      -3,
      0,
      3,
      7
    ],
    "send_emails": true,
    "email_receipts": true,
    "allow_customer_cancel": true
  },
  "routing": {
    "choice": "buyer",
    "provider": null,
    "fallback": true,
    "providers": null
  },
  "collect": null,
  "success_url": null,
  "payout_wallet_id": null,
  "self_serve": true,
  "url": "https://pay.railbed.io/subscribe/5e2b9c71d04a4f68b3c8e1a7f9d2c6b0",
  "status": "active",
  "subscribers": {
    "paying": 0,
    "trialing": 0,
    "total": 0
  },
  "mrr": "0.00",
  "version": 0,
  "created": 1790380525,
  "updated": 1790380525
}
```

### The billing object

Plans and subscriptions share it. Leave it out and a plan gets the defaults for its interval; send only the fields you want to change.

| Field | Type | Description |
|---|---|---|
| `lead_days` | integer | How many days before its period an invoice goes out: `0`, `1`, `3`, `7` or `14`, and at most half the period |
| `terms_days` | integer | How many days after the period starts it's due: `0`, `1`, `3`, `7`, `14` or `30`, and less than the period. A daily plan's invoice is due the day it goes out |
| `cancel_after_days` | integer or null | Unpaid this many days past its due date, the subscription ends: `3`, `7`, `14`, `30` or `60`. `null` keeps it past due until you act |
| `reminders` | array or null | Days around each due date when Railbed emails a reminder, from `-7`, `-3`, `-1`, `0`, `1`, `3`, `7`, `14` and `30`. `null` for none |
| `send_emails` | boolean | Railbed emails each invoice and its reminders in your business's name. Turn it off to send your own from the [`subscription.invoice_issued`](https://railbed.com/docs/webhooks/events.md#subscription-invoice-issued) event |
| `email_receipts` | boolean | The customer gets a receipt for each payment |
| `allow_customer_cancel` | boolean | The customer can cancel from their subscription page (and the customer portal). It then ends when the time they paid for does |

The defaults follow the interval. Monthly or longer: sent 7 days ahead (14 for yearly or longer), due 3 days into the period, ended 14 days past due, reminders at `[-3, 0, 3, 7]`. Weekly to under a month: 1 day ahead, due after 1 day, ended 7 days past due, reminders at `[0, 3]`. Shorter: sent and due on the day, ended 3 days past due, no reminders. Every default emails invoices and receipts and lets the customer cancel.

## Create a subscription plan

`POST /v1/subscription_plans`

Makes an active plan in the credential's mode. Its sign-up page works at once.

| Parameter | Type | Description |
|---|---|---|
| `name` | string · required | Up to 80 characters |
| `currency` | string · required | `USD`, `EUR`, `GBP`, `CAD`, `AUD`, `INR` or `SEK`, in any letter case |
| `amount` | string · required | One period's price before tax, a decimal string such as `"49.00"`. With tax it must be from 1.00 to 100,000.00 and at least the smallest card payment |
| `interval` | object · required | `unit` and `count`: every 1–365 days, 1–52 weeks, 1–24 months or 1–3 years |
| `description` | string | Up to 300 characters |
| `features` | array | Up to 8 texts of up to 80 characters each |
| `trial_days` | integer | 0–365. Default `0` |
| `tax` | object | `{ "percent": "8.25", "label": "Sales tax" }` |
| `terms` | string | Your terms, up to 2,000 characters |
| `billing` | object | See [The billing object](#the-billing-object) |
| `routing` | object | As on a [payment link](https://railbed.com/docs/api/payment-links.md#the-routing-field) |
| `collect` | object | As on a [checkout session](https://railbed.com/docs/api/checkout-sessions.md#the-collect-field) |
| `success_url` | string | Where the customer lands once an invoice is paid. Live mode needs a public `https://` page on your own site |
| `payout_wallet_id` | string | One of the account's other saved wallets, `pw_…`. [List payout wallets](https://railbed.com/docs/api/payout-wallets.md#list-payout-wallets) gives their ids |
| `self_serve` | boolean | Its page takes sign-ups. Default `true` |

Money is always a decimal string, never a JSON number. A field plans don't have is refused with `400 unknown_field`, and the message names the one you probably meant.

Example: cURL

```bash
curl https://pay.railbed.io/v1/subscription_plans \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: plan-pro-monthly" \
  -d '{
    "name": "Pro",
    "description": "Everything in Starter, plus priority support.",
    "features": ["5 seats", "Priority support", "Monthly report"],
    "currency": "USD",
    "amount": "49.00",
    "interval": { "unit": "month", "count": 1 },
    "terms": "Cancel any time from your subscription page."
  }'
```

Example: Node\.js

```js
const plan = await fetch('https://pay.railbed.io/v1/subscription_plans', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RAILBED_SECRET_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': 'plan-pro-monthly',
  },
  body: JSON.stringify({
    name: 'Pro',
    currency: 'USD',
    amount: '49.00',
    interval: { unit: 'month', count: 1 },
  }),
}).then((r) => r.json());
// plan.url is its sign-up page.
```

Example: Response · response 201 Created

```json
{
  "id": "spl_8Hq2mVx5RtLc3NwZb7Ks",
  "object": "subscription_plan",
  "livemode": false,
  "name": "Pro",
  "description": "Everything in Starter, plus priority support.",
  "features": [
    "5 seats",
    "Priority support",
    "Monthly report"
  ],
  "currency": "USD",
  "amount": "49.00",
  "interval": {
    "unit": "month",
    "count": 1
  },
  "trial_days": 0,
  "tax_percent": null,
  "tax_label": null,
  "terms": "Cancel any time from your subscription page.",
  "billing": {
    "lead_days": 7,
    "terms_days": 3,
    "cancel_after_days": 14,
    "reminders": [
      -3,
      0,
      3,
      7
    ],
    "send_emails": true,
    "email_receipts": true,
    "allow_customer_cancel": true
  },
  "routing": {
    "choice": "buyer",
    "provider": null,
    "fallback": true,
    "providers": null
  },
  "collect": null,
  "success_url": null,
  "payout_wallet_id": null,
  "self_serve": true,
  "url": "https://pay.railbed.io/subscribe/5e2b9c71d04a4f68b3c8e1a7f9d2c6b0",
  "status": "active",
  "subscribers": {
    "paying": 0,
    "trialing": 0,
    "total": 0
  },
  "mrr": "0.00",
  "version": 0,
  "created": 1790380525,
  "updated": 1790380525
}
```

**Retries.** Send an `Idempotency-Key` (1–120 printable ASCII characters): the same key with the same body (compared as sent, in any field order) answers the plan it made, with `200`, for 24 hours; the same key with a different body is `409 idempotency_conflict`.

| Error | Cause |
|---|---|
| `400 unknown_field` | A field plans don't have, here or inside `interval`, `tax` or `billing`. `field` names it |
| `400 missing_name`, `400 invalid_features`, `400 too_long` | No name; `features` isn't a list of at most 8 texts (`field` names the item, such as `features.2`); or a text field is over its limit |
| `400 invalid_amount`, `400 invalid_currency` | The price isn't a decimal string above zero, its total is outside 1.00–100,000.00 or under the smallest card payment, or the currency isn't supported |
| `400 invalid_interval`, `400 invalid_trial` | The interval is outside its bounds, or `trial_days` isn't a whole number from 0 to 365 |
| `400 invalid_billing`, `400 invalid_reminders`, `400 invalid_value` | A `billing` value isn't one of its choices or doesn't fit the interval, or a switch isn't `true` or `false`. `field` names it, such as `billing.lead_days` |
| `400 invalid_tax`, `400 invalid_routing`, `400 invalid_collect`, `400 invalid_url`, `400 invalid_payout_wallet` | As on [Create an invoice](https://railbed.com/docs/api/invoices.md#create-an-invoice) |
| `409 idempotency_conflict`, `409 idempotency_in_progress` | The key was used with a different body, or its first request hasn't finished: retry after `Retry-After` |
| `409 payout_wallet_unusable` | Live mode, and the wallet in `payout_wallet_id` can't take live payments |
| `409 commerce_paused`, `403 integration_disabled` | The account has paused payments, or the API is turned off for it |

## Retrieve a subscription plan

`GET /v1/subscription_plans/:id`

Returns one of your plans in the credential's mode, with its subscriber counts as they are now. One in the other mode is `404 not_found`, and the message says which mode it's in.

Example: cURL

```bash
curl https://pay.railbed.io/v1/subscription_plans/spl_8Hq2mVx5RtLc3NwZb7Ks \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY"
```

To list its subscribers, use [List subscriptions](https://railbed.com/docs/api/subscriptions.md#list-subscriptions) with `plan=spl_…`.

## Update a subscription plan

`PATCH /v1/subscription_plans/:id`

Changes the fields you send and leaves the rest, with the parameters of [Create a subscription plan](#create-a-subscription-plan). Send `null` to clear an optional field. A change reaches **new subscribers only**: subscriptions already on the plan keep the price, interval and settings they started with. To change one of those, use [Update a subscription](https://railbed.com/docs/api/subscriptions.md#update-a-subscription). A new `interval` resets `billing` to that interval's defaults unless you send `billing` too.

| Parameter | Type | Description |
|---|---|---|
| `status` | string | `archived` to stop new subscribers (its page says it's no longer available, and [Create a subscription](https://railbed.com/docs/api/subscriptions.md#create-a-subscription) on it answers `409 plan_archived`), or `active` to restore it. Its subscribers carry on either way |
| `expected_version` | integer | The `version` you read. If anyone changed the plan since, it answers `409 plan_changed` instead of overwriting their change |

Example: cURL

```bash
curl -X PATCH https://pay.railbed.io/v1/subscription_plans/spl_8Hq2mVx5RtLc3NwZb7Ks \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "archived", "expected_version": 0 }'
```

A plan is never deleted, so its subscriptions and figures keep their history: archive it instead.

| Error | Cause |
|---|---|
| `409 plan_changed` | Someone changed it since `expected_version`, or while the request ran. Read it again, then make your change |
| `400 invalid_status` | `status` isn't `active` or `archived` |
| `400 invalid_expected_version` | Not a whole number |

The create errors apply to the fields you send.

## List subscription plans

`GET /v1/subscription_plans`

Returns your plans in the credential's mode, newest first.

| Parameter | Type | Description |
|---|---|---|
| `limit` | integer | 1–100. Default 20 |
| `starting_after` | string | A plan id from the previous page's `next_cursor` |
| `status` | string | `active` or `archived` |
| `created_gte` | integer | Created on or after this Unix timestamp in seconds |
| `created_lte` | integer | Created on or before this Unix timestamp in seconds, including the whole ending second |

Example: cURL

```bash
curl "https://pay.railbed.io/v1/subscription_plans?status=active" \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY"
```

Example: Response · response 200 OK

```json
{
  "data": [
    {
      "id": "spl_8Hq2mVx5RtLc3NwZb7Ks",
      "object": "subscription_plan",
      "livemode": false,
      "name": "Pro",
      "description": "Everything in Starter, plus priority support.",
      "features": [
        "5 seats",
        "Priority support",
        "Monthly report"
      ],
      "currency": "USD",
      "amount": "49.00",
      "interval": {
        "unit": "month",
        "count": 1
      },
      "trial_days": 0,
      "tax_percent": null,
      "tax_label": null,
      "terms": "Cancel any time from your subscription page.",
      "billing": {
        "lead_days": 7,
        "terms_days": 3,
        "cancel_after_days": 14,
        "reminders": [
          -3,
          0,
          3,
          7
        ],
        "send_emails": true,
        "email_receipts": true,
        "allow_customer_cancel": true
      },
      "routing": {
        "choice": "buyer",
        "provider": null,
        "fallback": true,
        "providers": null
      },
      "collect": null,
      "success_url": null,
      "payout_wallet_id": null,
      "self_serve": true,
      "url": "https://pay.railbed.io/subscribe/5e2b9c71d04a4f68b3c8e1a7f9d2c6b0",
      "status": "active",
      "subscribers": {
        "paying": 0,
        "trialing": 0,
        "total": 0
      },
      "mrr": "0.00",
      "version": 0,
      "created": 1790380525,
      "updated": 1790380525
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## Access

Retrieving and listing need the `payments:read` [scope](https://railbed.com/docs/api.md#scopes), which **Read only** keys have. Creating and changing need `checkouts:write`, which **Full access** keys and agents with full access have. Plans send no webhook events of their own; their subscriptions do ([Subscription events](https://railbed.com/docs/webhooks/events.md#subscription-events)).
