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

# Quickstart

> Create a sandbox checkout session and handle the normalized merchant webhook.

This quickstart creates a sandbox checkout session, redirects the buyer to hosted checkout, and shows the webhook payload your app should handle.

## 1. Create a checkout session

Use the gateway sessions endpoint directly:

```bash theme={null}
curl https://dash.getopenrails.com/api/gateway/sessions \
  -H "Content-Type: application/json" \
  -d '{
    "product": "Creator plan",
    "amount": 116,
    "customer": "buyer@example.com",
    "preferredRoute": "card",
    "redirectUrl": "https://merchant.example/success?order=ord_284",
    "environment": "sandbox",
    "idempotencyKey": "ord_284_checkout",
    "clientReferenceId": "ord_284",
    "metadata": {
      "order_id": "ord_284"
    }
  }'
```

The response includes a `checkoutUrl` hosted on `pay.getopenrails.com`.

```json theme={null}
{
  "id": "chk_demo_1779900000000",
  "object": "checkout_session",
  "checkoutUrl": "https://pay.getopenrails.com/checkout/chk_demo_1779900000000",
  "redirectUrl": "https://merchant.example/success?order=ord_284",
  "status": "routed"
}
```

Agents can also create checkout sessions using the agent action endpoint:

```bash theme={null}
curl https://dash.getopenrails.com/api/agent/actions/checkout.create \
  -H "Content-Type: application/json" \
  -d '{
    "product": "Creator plan",
    "amount": 116,
    "customer": "buyer@example.com",
    "environment": "sandbox",
    "idempotencyKey": "ord_284_checkout"
  }'
```

## 2. Redirect the buyer

Send the customer to `checkoutUrl`. Open Rails hosts the checkout, selects the route, and sends the buyer through the payment flow.

## 3. Read records after creation

After the session is created, you can look up the customer and track the payment:

```bash theme={null}
# Look up the customer
curl "https://dash.getopenrails.com/api/gateway/customers?email=buyer@example.com"

# Look up the payment by session ID
curl https://dash.getopenrails.com/api/gateway/payments/chk_demo_1779900000000
```

## 4. Handle the webhook

Your fulfillment app should listen for `payment.paid` before shipping, unlocking credits, or marking an invoice as paid.

```json theme={null}
{
  "id": "evt_chk_nimbus_1056_paid",
  "type": "payment.paid",
  "livemode": false,
  "created": "2026-05-26T14:32:00Z",
  "data": {
    "session_id": "chk_nimbus_1056",
    "customer_id": "cus_nimbus_42",
    "status": "paid",
    "amount": 116,
    "currency": "USD",
    "asset": "USDC",
    "network": "Base",
    "metadata": {
      "order_id": "ord_284"
    }
  }
}
```

## 5. Inspect schemas when automating

Agents and CI jobs should fetch the runtime schema before creating payloads.

```bash theme={null}
curl https://dash.getopenrails.com/api/agent/schema/checkout.create
```

Use the returned JSON Schema as the source of truth for required fields, enums, and limits.
