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

# Create a credit checkout handler

> **Required scope:** billing:write

**Required scope:** `billing:write`

### Request body

`CreateCreditCheckoutRequest`

<ParamField body="amount_dollars" type="number (double)" required>
  Dollar amount of prepaid credits to purchase.
</ParamField>

<ParamField body="cancel_url" type="string" required>
  URL to redirect to if the customer cancels.
</ParamField>

<ParamField body="success_url" type="string" required>
  URL to redirect to after successful checkout.
</ParamField>

### Response

`CreateCreditCheckoutResponse`

<ResponseField name="amount_cents" type="integer (int64)" required>
  Purchased amount in cents.
</ResponseField>

<ResponseField name="checkout_url" type="string" required>
  Full Stripe Checkout URL to redirect the customer to
</ResponseField>

<ResponseField name="estimated_outcomes" type="integer (int64)" required>
  Approximate number of outcomes this credit amount can cover.
</ResponseField>

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `200` | Credit checkout session created                    |
| `401` | Unauthorized — missing or invalid credentials      |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |
| `503` | Billing not configured                             |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.nsr.stateset.com/api/v1/billing/credits/checkout' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "amount_dollars": 1.5,
    "cancel_url": "string",
    "success_url": "string"
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "amount_cents": 4900,
    "checkout_url": "string",
    "estimated_outcomes": 1
  }
  ```
</ResponseExample>
