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

> ## Agent Instructions
> The CoinStack API base URL is https://coinstack.net/api/v1. Authenticate with an API key sent as 'Authorization: Bearer sk_...' from a server, never from a browser. Every response is a JSON object with 'success' and 'response'. Amounts are strings; token amounts on quotes and payments are in the token's smallest unit. Fulfil an order when its checkout status is 'completed', not when the customer returns to success_url. Verify the CoinStack-Signature header on every webhook using the raw request body. The OpenAPI file is at https://docs.coinstack.net/openapi.json.

# Checkouts

> What a checkout is, the fields you can set, and the statuses it moves through.

A checkout is a request for one payment. It has an amount, a page where the customer pays, and a status that tells you whether it has been paid.

## Create a checkout

Only `amount` and `currency` are required.

```bash theme={null}
curl https://coinstack.net/api/v1/checkouts \
  -H "Authorization: Bearer $COINSTACK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "25.00",
    "currency": "USD",
    "email": "customer@example.com",
    "reference": "order-1042",
    "description": "Order #1042",
    "success_url": "https://example.com/orders/1042/thanks",
    "cancel_url": "https://example.com/cart",
    "metadata": { "order_id": "1042" }
  }'
```

| Field | Description |
| - | - |
| `amount` | The amount to charge, as a string such as `"25.00"`. |
| `currency` | One of the [supported currencies](https://docs.coinstack.net/reference/currencies.md), such as `USD`. |
| `email` | The customer's email address. |
| `reference` | Your own identifier, such as an order number. Up to 200 characters. |
| `description` | Text shown to the customer on the checkout page. Up to 1,000 characters. |
| `success_url` | A link back to your site, shown once the checkout is completed. |
| `cancel_url` | A link back to your site, shown before the customer pays and if the checkout expires. |
| `metadata` | Up to 50 key-value pairs of your own. Values must be strings. |
| `expires_at` | When the checkout closes. Defaults to 24 hours from now. |

The full rules for each field are in [Create a checkout](https://docs.coinstack.net/api-reference/checkouts/create-a-checkout.md).

### Amount and currency

The amount is converted to US dollars when the checkout is created. The result is the checkout's `value`, and it does not change afterwards. A checkout must be worth between 1 and 1,000,000 US dollars.

Use no more decimal places than the currency has. `"25.00"` is valid for USD, and `"2500"` is valid for JPY, which has none.

### Return links

`success_url` and `cancel_url` are links on the checkout page. They are not redirects, and the customer may close the page without using them, so confirm payment with a [webhook](https://docs.coinstack.net/guides/webhooks.md) and not by waiting for the customer to arrive at `success_url`.

Put `{CHECKOUT_ID}` anywhere in either URL and it is replaced with the checkout's ID:

```
https://example.com/return?checkout={CHECKOUT_ID}
```

### Reference and metadata

`reference` and `metadata` are stored with the checkout and returned whenever you read it, including in webhook events. Use them to tie a checkout to a record in your own system.

You can find checkouts by reference later:

```bash theme={null}
curl "https://coinstack.net/api/v1/checkouts?reference=order-1042" \
  -H "Authorization: Bearer $COINSTACK_API_KEY"
```

References do not have to be unique. If two checkouts share one, both are returned.

## The checkout page

Each checkout has a page at its `url`. On it the customer:

1. Chooses a token and network from the ones you accept.
2. Sees the address and the exact amount to send, with a QR code.
3. Watches the page update as the payment is detected and completed.

To show these details in your own site or app, see [Build your own checkout](https://docs.coinstack.net/guides/custom-checkout.md).

### Settings that change the page

Owners and admins of a merchant account can change how its checkout page behaves under **Settings** in the dashboard.

| Setting | What it changes |
| - | - |
| **Checkout layout** | How the first screen offers payment methods: **Grid** or **List**. |
| **Payment methods** | Which tokens and networks customers can pay with. |
| **Network cost** | Who covers the network cost on each network. Where the customer does, it is added to the amount they pay. See [Fees and settlement](https://docs.coinstack.net/guides/fees-and-settlement.md#network-cost). |
| **Underpayment** | How far short a payment can fall and still complete the checkout. See [Underpayments and late payments](https://docs.coinstack.net/guides/underpayments.md#small-shortfalls). |

## Statuses

| Status | Meaning |
| - | - |
| `pending` | Nothing has been paid yet. |
| `confirming` | A payment was detected and is being processed. |
| `partial` | Less than the full amount has been paid. The checkout is still open for the rest. |
| `completed` | The checkout was paid in full. |
| `expired` | The checkout closed before it was paid in full. |
| `resolved` | You marked an underpaid checkout as settled. |

A checkout starts as `pending` and usually moves to `confirming` and then `completed`. Each change after `pending` sends a [webhook event](https://docs.coinstack.net/guides/webhooks.md#events) named after the new status, such as `checkout.completed`.

Fulfil an order when its checkout is `completed`. Treat `resolved` as paid too if you use it.

Three flags add detail to the status:

| Flag | Meaning |
| - | - |
| `underpaid` | Payments have arrived but add up to less than the full amount. |
| `overpaid` | The customer paid more than 2% over the full amount. |
| `late` | The payment that completed the checkout arrived after `expires_at`. |

[Underpayments and late payments](https://docs.coinstack.net/guides/underpayments.md) explains what to do in each case.

## Expiry

A checkout closes at `expires_at`. If it has not been paid in full by then, its status becomes `expired`.

The default is 24 hours after creation. Set `expires_at` to any time between 10 minutes and 365 days from now:

```json theme={null}
{
  "amount": "25.00",
  "currency": "USD",
  "expires_at": "2026-12-02T18:00:00Z"
}
```

To close a checkout early, for example when the customer cancels the order, [expire it](https://docs.coinstack.net/api-reference/checkouts/expire-a-checkout.md):

```bash theme={null}
curl -X POST https://coinstack.net/api/v1/checkouts/8f3b2c1e-5d47-4a9b-b6e0-2c7f1a9d4e53/expire \
  -H "Authorization: Bearer $COINSTACK_API_KEY"
```

Only a `pending` or `partial` checkout can be expired.

## Read a checkout

[Get a checkout](https://docs.coinstack.net/api-reference/checkouts/get-a-checkout.md) returns the checkout together with its quotes and payments:

```bash theme={null}
curl https://coinstack.net/api/v1/checkouts/8f3b2c1e-5d47-4a9b-b6e0-2c7f1a9d4e53 \
  -H "Authorization: Bearer $COINSTACK_API_KEY"
```

`received` is the USDC that has reached your wallet from this checkout so far. It is lower than `value` on a fully paid checkout because the fee has been taken out. Use `status`, not `received`, to decide whether a checkout is paid. See [Fees and settlement](https://docs.coinstack.net/guides/fees-and-settlement.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.