Checkouts

Create reusable checkout pages and widgets from your own code, with their look, and get the slug a buy button takes. Every buyer who pays one gets their own payment. The same checkouts you make in the dashboard.

On this page

The checkout object

A checkout is a reusable page with a fixed price, such as a product, a course or a donation: share its link, or put a buy button on your site, and every buyer who pays gets their own payment and order. It's the same checkout you can make under Checkouts in the dashboard. For one amount from one payer, use a payment link; for an order your server prices, a checkout session. To know which of your users paid a checkout, your server makes a session from it for that user.

FieldTypeDescription
idstringThe checkout's id, chk_…
objectstring"checkout"
kindstringpage, pricing_table or widget. The API creates pages and widgets; pricing tables are made in the dashboard
slugstringWhat a buy button takes: <railbed-button checkout="mug4k7tq2z">
urlstringThe hosted checkout page. Share it, or link to it
livemodebooleanfalse for Test mode, true for Live mode
activebooleanfalse once it was deleted in the dashboard, or while it's turned off there; either way it takes no new buyers. A turned-off checkout is still listed and can be turned on again in the dashboard
namestringShown to buyers
descriptionstring or nullShown under the name
amountstringThe price. A pricing table's lowest plan price
currencystringUSD, EUR, GBP, CAD, AUD, INR or SEK
success_urlstring or nullWhere buyers land once paid
themestringlight or dark. With a background, the background's own shade; with appearance.theme set to auto, the theme it falls back to
appearanceobjectHow it looks to buyers. See The appearance object
button_labelstring or nullThe pay button's text, or null for "Continue to pay" and the price
introstringA widget's first screen: form opens on the pay form (the default), offer on the product, its price and one button, which opens the form in the same card. Always form for pages and pricing tables
cryptobooleanWhether buyers may pay in crypto, when crypto payments are on for the account
payment_methodsarrayHow customers pay: ["card", "crypto"] or ["card"] for a Card Checkout, ["crypto"] for a Crypto Checkout (crypto only, no card providers). See How customers pay
routingobjectHow buyers reach a card provider: choice is smart (Smart Routing), buyer (buyers choose) or fixed (one provider, with fallback to Smart Routing when it can't take a buyer)
collectobject or nullWhat the page asks buyers for besides their email, or null for nothing more. See The collect field
optionsarray or nullA pricing table's two-way switch, such as ["Monthly", "Yearly"]
plansarrayA pricing table's plans: id, name, description, prices (amount and unit), features, recommended and cta (the words on its button, or null for "Choose" and its name). Empty for pages and widgets. A plan's id, with the side of options the buyer chose, is what a session from this checkout takes
createdintegerWhen it was created, in Unix seconds
updatedintegerWhen it last changed, in Unix seconds
discord_accessobjectOnly when it gives roles in a Discord server: the server, the roles and how long access lasts. See Discord access
warningsarrayOn the create and update responses only, and only when there is something to say: what the card providers' minimums mean for the price. See Provider minimums
A checkout
{
  "id": "chk_Mg7tR2vX9kQp4WnZc8Lb",
  "object": "checkout",
  "kind": "page",
  "slug": "mug4k7tq2z",
  "url": "https://pay.railbed.io/c/mug4k7tq2z",
  "livemode": false,
  "active": true,
  "name": "Ceramic mug",
  "description": "Hand-thrown, 350 ml.",
  "amount": "18.00",
  "currency": "USD",
  "success_url": "https://mugs.example/thanks",
  "theme": "light",
  "appearance": {
    "theme": "light",
    "use_brand": false,
    "accent": null,
    "background": null,
    "corners": "soft",
    "edge": "outline",
    "font": null,
    "heading_font": null,
    "logo": true,
    "header_image": null
  },
  "button_label": null,
  "intro": "form",
  "crypto": true,
  "payment_methods": [
    "card",
    "crypto"
  ],
  "routing": {
    "choice": "smart",
    "provider": null,
    "fallback": true
  },
  "collect": null,
  "options": null,
  "plans": [],
  "created": 1790380525,
  "updated": 1790380525
}
200 OK

The appearance object

The checkout's own look, never the account's: a null colour or font means the account's or Railbed's. Railbed derives every other shade from these, keeps the text readable on any background, and keeps the layout.

FieldTypeDescription
themestringlight, dark, or auto to follow the buyer's device (falling back to the top-level theme). While background is set, the card is light or dark by the background's own shade, and theme reads as that
use_brandbooleanWhether it takes your account's brand (colour, fonts and logo, from Settings → Brand) under its own settings
accentstring or nullThe accent colour, #RRGGBB. null is the account's
backgroundstring or nullThe card's colour, #RRGGBB, as you chose it. A colour too close to the text is moved just enough when it's drawn. null is Railbed's
cornersstringsharp, soft (Railbed's), rounded or round: the card, its fields and its buttons
edgestringoutline (Railbed's), shadow or none: the card's edge where it sits in your page
font, heading_fontstring or nullA Google Fonts family for the text and for headings, such as Inter or Newsreader, served from Railbed's own hosts. null is Railbed's
logobooleanWhether your account's logo shows
header_imageobject or nullThe picture at the top of the card, or null for none: url, then how it's framed: fit (cover fills the box, contain shows the whole picture), ratio (16:9, 2:1, 3:1 or 4:1), focus (x and y, whole percentages from 0 to 100), zoom (100 to 300, with cover), band (with contain: surface, accent or #RRGGBB) and alt (what it shows, up to 120 characters; "" when it's decorative). A picture added before framing existed reads with null framing until it's adjusted

The picture itself is added, replaced and removed in the dashboard, which resizes it in your browser before it uploads; the API adjusts its framing.

A widget with its own look
{
  "id": "chk_Wd3nK8pQ2vR7tYx4Hm9B",
  "object": "checkout",
  "kind": "widget",
  "slug": "wdg7mq3k2x",
  "url": "https://pay.railbed.io/c/wdg7mq3k2x",
  "livemode": false,
  "active": true,
  "name": "Ceramic mug",
  "description": "Hand-thrown, 350 ml.",
  "amount": "18.00",
  "currency": "USD",
  "success_url": "https://mugs.example/thanks",
  "theme": "light",
  "appearance": {
    "theme": "light",
    "use_brand": false,
    "accent": null,
    "background": "#FBF6EC",
    "corners": "rounded",
    "edge": "shadow",
    "font": "Inter",
    "heading_font": null,
    "logo": true,
    "header_image": null
  },
  "button_label": null,
  "intro": "offer",
  "crypto": true,
  "payment_methods": [
    "card",
    "crypto"
  ],
  "routing": {
    "choice": "smart",
    "provider": null,
    "fallback": true
  },
  "collect": null,
  "options": null,
  "plans": [],
  "created": 1790380525,
  "updated": 1790380525
}
200 OK

Create a checkout

POST /v1/checkouts

Creates a checkout page or widget in the key's mode, with the settings a new checkout starts with in the dashboard unless you send others.

ParameterTypeDescription
namestring RequiredShown to buyers, up to 80 characters
amountstring RequiredA decimal string from "1.00" to "100000.00", at most two decimals, and at least the smallest card payment (about "2.00" USD): see Provider minimums
currencystring RequiredUSD, EUR, GBP, CAD, AUD, INR or SEK, in any letter case
descriptionstringUp to 280 characters
success_urlstringWhere buyers land once paid. Live mode needs a public https:// page on your own site
kindstringpage (default) or widget, the card that sits in your own page. Pricing tables are made in the dashboard
themestringlight (default) or dark. The same as appearance.theme: send one or the other
appearanceobjectAny of the appearance fields except header_image: theme (also auto), use_brand, accent, background, corners, edge, font, heading_font and logo. Colours in any letter case; a font must be a Google Fonts family
button_labelstringThe pay button's text, up to 32 characters
introstringWidgets only: form (default) or offer, to open on the price and one button
cryptobooleanDefault true: buyers may pay in crypto when it's on for the account. Leave it out when you send payment_methods
payment_methodsarray["card", "crypto"] (the default), ["card"] or ["crypto"] for a Crypto Checkout, which needs crypto payments on. See How customers pay
routingobjectDefault { "choice": "smart" }. For one provider: { "choice": "fixed", "provider": "stripe", "fallback": true }
collectobjectWhat the page asks buyers for besides their email, as on a checkout session. Leave it out and the page asks for the email alone; a checkout made in the dashboard asks for the buyer's name too, so send { "name": "required" } to match it
discord_accessobjectRoles in a Discord server each purchase gives. See Setting Discord access
curl https://pay.railbed.io/v1/checkouts \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ceramic mug",
    "description": "Hand-thrown, 350 ml.",
    "amount": "18.00",
    "currency": "USD",
    "success_url": "https://mugs.example/thanks"
  }'
Response
{
  "id": "chk_Mg7tR2vX9kQp4WnZc8Lb",
  "object": "checkout",
  "kind": "page",
  "slug": "mug4k7tq2z",
  "url": "https://pay.railbed.io/c/mug4k7tq2z",
  "livemode": false,
  "active": true,
  "name": "Ceramic mug",
  "description": "Hand-thrown, 350 ml.",
  "amount": "18.00",
  "currency": "USD",
  "success_url": "https://mugs.example/thanks",
  "theme": "light",
  "appearance": {
    "theme": "light",
    "use_brand": false,
    "accent": null,
    "background": null,
    "corners": "soft",
    "edge": "outline",
    "font": null,
    "heading_font": null,
    "logo": true,
    "header_image": null
  },
  "button_label": null,
  "intro": "form",
  "crypto": true,
  "payment_methods": [
    "card",
    "crypto"
  ],
  "routing": {
    "choice": "smart",
    "provider": null,
    "fallback": true
  },
  "collect": null,
  "options": null,
  "plans": [],
  "created": 1790380525,
  "updated": 1790380525
}
201 Created

A widget with its own look, which opens on its price:

cURL
curl https://pay.railbed.io/v1/checkouts \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "widget",
    "name": "Ceramic mug",
    "amount": "18.00",
    "currency": "USD",
    "intro": "offer",
    "appearance": { "background": "#FBF6EC", "corners": "rounded", "edge": "shadow", "font": "Inter" }
  }'

Put it on your site with the slug:

A buy button
<script src="https://pay.railbed.io/embed.js" async></script>
<railbed-button checkout="mug4k7tq2z"></railbed-button>

The checkout follows the dashboard editor's rules, and an error's field names the parameter you sent. This endpoint ignores Idempotency-Key: after a timeout, list your checkouts before creating another.

ErrorCause
400 invalid_kindkind is something other than page or widget
400 unknown_fieldappearance has a field it doesn't take. The message names the nearest one
400 missing_name, 400 too_longname is empty, or a text field is over its limit
400 invalid_description, 400 invalid_button_labelThat field isn't a string
400 invalid_amountamount isn't a decimal string from "1.00" to "100000.00", or is under the smallest card payment (the message names it)
400 invalid_currencycurrency isn't USD, EUR, GBP, CAD, AUD, INR or SEK
400 invalid_urlsuccess_url isn't a full address, has a username or password, is a Railbed page, or in Live mode isn't a public https:// address (the message says which)
400 invalid_theme, 400 invalid_valuetheme isn't light or dark (or disagrees with appearance.theme), or crypto isn't a boolean
400 invalid_appearanceappearance isn't an object, or a field in it isn't a value it takes. field names it, such as appearance.corners
400 unknown_fontappearance.font or appearance.heading_font isn't a Google Fonts family
400 invalid_introintro isn't form or offer, or was sent for a page
409 no_header_imageappearance.header_image was sent: a new checkout has no picture yet. Add one in the dashboard, then adjust it
400 invalid_routingrouting names no choice, or a provider that can't take card payments
400 invalid_methodspayment_methods isn't a list of "card" and "crypto", or crypto disagrees with it
409 crypto_offpayment_methods is ["crypto"] while crypto payments are off for the account
400 invalid_collectcollect asks for something it can't. field names the part
409 no_payout_walletLive mode, and the account has no payout wallet yet, or its payout wallet can't take live payments (the message says why)
409 commerce_pausedThe account has paused taking payments
403 integration_disabledCheckouts, or the API, are turned off for the account
403 merchant_read_onlyThe account is suspended or archived

Retrieve a checkout

GET /v1/checkouts/:id

Returns one of your checkouts in the key's mode, including one deleted in the dashboard (active: false). Another account's, or one in the other mode, is 404 not_found.

cURL
curl https://pay.railbed.io/v1/checkouts/chk_Mg7tR2vX9kQp4WnZc8Lb \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY"

Update a checkout

PATCH /v1/checkouts/:id

Changes a saved checkout by the dashboard editor's rules, for any kind, and leaves the rest. It takes the parameters of Create a checkout except kind, plus active, and appearance.header_image to frame a picture added in the dashboard. A new price, currency or provider choice meets the same checks as a new checkout, and the checkout keeps its slug, so buttons already on your site show the change. In appearance, only the fields you send change, and null puts a colour or font back to the default and corners and edge back to Railbed's. A pricing table's plans and the header image itself are changed in the dashboard. Everything is checked before anything is saved.

ParameterTypeDescription
activebooleanfalse turns it off, so buyers see it isn't available; true turns it back on. Turning it off on its own is never refused, so a checkout can always be stopped; turning it on, like any other change, needs the account to be taking payments
appearance.header_imageobjectThe framing to change: any of fit, ratio, focus, zoom, band and alt, with the same values a read returns. A null field stays as it is, and url may be sent back only as it is, so a read object can be sent back whole. Its size always comes from the stored picture
cURL
curl -X PATCH https://pay.railbed.io/v1/checkouts/chk_Mg7tR2vX9kQp4WnZc8Lb \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "amount": "20.00" }'
Frame the header image
curl -X PATCH https://pay.railbed.io/v1/checkouts/chk_Mg7tR2vX9kQp4WnZc8Lb \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "appearance": { "corners": "rounded", "header_image": { "focus": { "x": 42, "y": 56 }, "zoom": 130, "alt": "A ceramic mug on an oak shelf" } } }'

The response is the checkout as changed, with warnings when there's something to say about the card providers' minimums.

ErrorCause
409 currency_lockedA buyer has paid, or gone to pay, from it, so its currency is fixed. Create a new checkout for another currency
409 checkout_deletedIt was deleted in the dashboard. Create a new one
400 invalid_amountA pricing table's price, which comes from its plans
400 invalid_appearance, 400 unknown_font, 400 invalid_introAs on create; intro is refused for a page or pricing table
400 invalid_headerA framing value is out of range, url isn't the checkout's own picture, or header_image is null while there is a picture (remove it in the dashboard). field names it, such as appearance.header_image.zoom
409 no_header_imageappearance.header_image was sent, but the checkout has no picture, or its file is gone. Nothing changed
409 header_image_changedThe picture was replaced in the dashboard while your request ran. Your other changes were saved; read the checkout and adjust the new picture
409 commerce_paused, 403 integration_disabledAnything but turning it off, while the account has paused payments or checkouts or the API are turned off for it

List checkouts

GET /v1/checkouts

Returns your checkouts of every kind in the key's mode that aren't deleted (turned-off ones included, with active: false), newest first.

ParameterTypeDescription
limitinteger1–100. Default 20
starting_afterstringA checkout id from the previous page's next_cursor
kindstringOnly page, pricing_table or widget
cURL
curl https://pay.railbed.io/v1/checkouts \
  -H "Authorization: Bearer $RAILBED_SECRET_KEY"
Response
{
  "data": [
    {
      "id": "chk_Mg7tR2vX9kQp4WnZc8Lb",
      "object": "checkout",
      "kind": "page",
      "slug": "mug4k7tq2z",
      "url": "https://pay.railbed.io/c/mug4k7tq2z",
      "livemode": false,
      "active": true,
      "name": "Ceramic mug",
      "description": "Hand-thrown, 350 ml.",
      "amount": "18.00",
      "currency": "USD",
      "success_url": "https://mugs.example/thanks",
      "theme": "light",
      "appearance": {
        "theme": "light",
        "use_brand": false,
        "accent": null,
        "background": null,
        "corners": "soft",
        "edge": "outline",
        "font": null,
        "heading_font": null,
        "logo": true,
        "header_image": null
      },
      "button_label": null,
      "intro": "form",
      "crypto": true,
      "payment_methods": [
        "card",
        "crypto"
      ],
      "routing": {
        "choice": "smart",
        "provider": null,
        "fallback": true
      },
      "collect": null,
      "options": null,
      "plans": [],
      "created": 1790380525,
      "updated": 1790380525
    }
  ],
  "has_more": false,
  "next_cursor": null
}
200 OK

Deleting a checkout happens in the dashboard. A checkout whose price changes keeps its slug, so buttons already on your site show the new price.

Access

Retrieving and listing need the payments:read scope, which Read only keys have. Creating and updating need checkouts:write, which Full access keys and agents with full access have.

Updated · This page as Markdown