> ## 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.

# Build your own checkout

> Show the address and amount in your own site or app instead of the checkout page.

The checkout page is the quickest way to accept a payment. If you want the customer to stay inside your own interface, you can ask the API for the payment details and show them yourself.

The flow has four parts: create a checkout, let the customer pick a token and network, create a quote for that choice, and track the payment.

> [!NOTE]
>
> All of these requests need your API key, so make them from your server and pass the results to your front end.

## 1. Create a checkout

Create the checkout as usual. You do not need `success_url` or `cancel_url`, because the customer never sees the checkout page.

```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", "reference": "order-1042"}'
```

## 2. Offer tokens and networks

[List tokens](https://docs.coinstack.net/api-reference/tokens/list-tokens.md) returns every token and network that can be used right now.

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

```json theme={null}
{
  "success": true,
  "response": {
    "tokens": [
      {
        "network": "base",
        "token": "USDC",
        "chain_id": 8453,
        "contract": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
        "decimals": 6,
        "price": "0.99975000",
        "cost": "0.02356800",
        "minimum": "1.00000000",
        "stable": true,
        "active": true,
        "created_at": "2026-11-17T03:12:44.190233Z",
        "updated_at": "2026-12-02T16:19:48.557120Z"
      }
    ]
  }
}
```

Before you show an option, check two things:

* **The minimum.** Leave out any token whose `minimum` is higher than the checkout's `value`. Networks with a high network cost, such as Bitcoin, have a higher minimum.
* **Your own settings.** If you have turned off some tokens or networks under **Settings**, then **Payment methods**, in the dashboard, they still appear in this list. Creating a quote for one of them returns `Invalid token`.

Keep `decimals` for each option. You need it to display amounts.

## 3. Create a quote

When the customer has chosen, [create a quote](https://docs.coinstack.net/api-reference/quotes/create-a-quote.md) for that token and network.

```bash theme={null}
curl https://coinstack.net/api/v1/checkouts/8f3b2c1e-5d47-4a9b-b6e0-2c7f1a9d4e53/quotes \
  -H "Authorization: Bearer $COINSTACK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"network": "base", "token": "USDC"}'
```

```json theme={null}
{
  "success": true,
  "response": {
    "quote": {
      "checkout_id": "8f3b2c1e-5d47-4a9b-b6e0-2c7f1a9d4e53",
      "quote_id": "0x5c1d9a7e3b6f48021e9d7c4a5b3f6e8d1a2c4b6e8f0a1c3e5d7f9b2a4c6e8d0f",
      "network": "base",
      "token": "USDC",
      "address": "0x7a3e9c5d1b4f8026e9a1c3d5b7f9e2a4c6d8b0f1",
      "settlement": "base",
      "recipient": "0x91C4e7B2a6D83f05E2b7A9c4D6f8E1a3B5c7D9F0",
      "amount": "25000000",
      "received": "0",
      "expected": "24.77643200",
      "rate": "1.00000000",
      "cost": "0.02356800",
      "created_at": "2026-12-02T16:21:03.220145Z",
      "updated_at": "2026-12-02T16:21:03.220145Z",
      "expires_at": "2026-12-02T17:21:02.981377Z",
      "remaining": "25000000",
      "uri": "ethereum:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913@8453/transfer?address=0x7a3e9c5d1b4f8026e9a1c3d5b7f9e2a4c6d8b0f1&uint256=25000000"
    }
  }
}
```

Show the customer three things from the quote:

| Field | What to show |
| - | - |
| `address` | The address to send to. |
| `remaining` | The amount to send. Divide it by 10 to the power of the token's `decimals`. Here `25000000` with 6 decimals is 25 USDC. |
| `uri` | A QR code of this value. Wallets that scan it fill in the address and amount. On TRON it is the plain address. |

Also show the network name clearly, so the customer sends on the right one.

Each quote has its own address, and that address belongs to one checkout. A checkout can have up to 10 quotes. Asking again for the same token and network returns the quote you already have.

### When a quote expires

For tokens that are not stablecoins, the amount is based on the price when the quote was made. `expires_at` is when that amount stops being guaranteed: 20 minutes for most tokens and 60 minutes for BTC.

After `expires_at`, [refresh the quote](https://docs.coinstack.net/api-reference/quotes/refresh-a-quote.md) to get an amount at the current price. The address stays the same.

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

Show the customer a countdown to `expires_at` and refresh when it runs out. A payment sent after the quote has expired is counted at the market price when it arrived, which can leave the checkout [underpaid](https://docs.coinstack.net/guides/underpayments.md#payments-after-the-price-lock).

## 4. Track the payment

Use [webhooks](https://docs.coinstack.net/guides/webhooks.md) to follow the payment from your server.

| Event | What to show the customer |
| - | - |
| `payment.pending` or `checkout.confirming` | The payment was detected and is confirming. |
| `checkout.partial` | Part of the amount arrived. Get the checkout and show the new `remaining`. |
| `checkout.completed` | The payment is complete. |
| `checkout.expired` | The checkout closed. |

To get the current state at any time, for example when the customer reloads the page, [get the checkout](https://docs.coinstack.net/api-reference/checkouts/get-a-checkout.md). The response includes every quote with its current `remaining`, and every payment.

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

After a partial payment, `remaining` on each quote drops to what is still owed. Show the customer the new amount and the same address.


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