> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blockra.io/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /checkout/sessions — Create a Checkout Session

> Create a Blockra hosted checkout session and get a redirect URL for your buyer. Accepts amount, currency, label, reference, email, and redirect URLs.

Creates a Blockra-hosted checkout session and returns a URL to redirect your buyer to. On the hosted page the buyer picks which coin to pay with, sees the deposit address and exact amount, and is sent to your `success_url` once the payment confirms. Requires the `payments:write` scope.

## Request

**`POST https://api.blockra.io/checkout/sessions`**

### Body parameters

<ParamField body="amount" type="number" required>
  The amount to charge, in fiat. Blockra locks the live exchange rate once the buyer picks a coin. Example: `9.99`.
</ParamField>

<ParamField body="currency" default="USD" type="string">
  The fiat currency to price in. One of `USD`, `EUR`, or `GBP`. Defaults to your account's settlement currency.
</ParamField>

<ParamField body="label" type="string">
  A short description shown on the checkout page (max 255 characters).
</ParamField>

<ParamField body="reference" type="string">
  Your own order or reference ID (max 255 characters). Echoed back on the resulting payment and in webhook payloads.
</ParamField>

<ParamField body="customer_email" type="string">
  Pre-fills the buyer's email and associates the payment with a customer record.
</ParamField>

<ParamField body="success_url" type="string">
  URL to redirect the buyer to after a successful payment. Falls back to your checkout settings when omitted.
</ParamField>

<ParamField body="cancel_url" type="string">
  URL to redirect the buyer to if they cancel. Falls back to your checkout settings when omitted.
</ParamField>

## Response

Returns a `201` with the session ID and the hosted checkout URL. Redirect your buyer to `url`.

<ResponseField name="id" type="string">
  The checkout session ID, prefixed `cs_`.
</ResponseField>

<ResponseField name="url" type="string">
  The hosted checkout page URL — redirect your buyer here.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl https://api.blockra.io/checkout/sessions \
    -X POST \
    -H "X-API-Key: bk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "amount": 9.99,
      "currency": "USD",
      "reference": "order_1234",
      "success_url": "https://your-site.com/thanks",
      "cancel_url": "https://your-site.com/cart"
    }'
  ```

  ```ts Node.js theme={null}
  const res = await fetch("https://api.blockra.io/checkout/sessions", {
    method: "POST",
    headers: {
      "X-API-Key": process.env.BLOCKRA_API_KEY!,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      amount: 9.99,
      currency: "USD",
      reference: "order_1234",
      success_url: "https://your-site.com/thanks",
      cancel_url: "https://your-site.com/cart",
    }),
  });
  const { data } = await res.json();
  // redirect the buyer to data.url
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "data": {
      "id": "cs_a1b2c3d4e5f6g7h8i9j0k1l2",
      "url": "https://checkout.blockra.io/cs_a1b2c3d4e5f6g7h8i9j0k1l2"
    },
    "error": null
  }
  ```
</ResponseExample>
