# Merchant API

The merchant API is what your shop or backend calls: create a payment, send the customer to the hosted checkout,
and get a signed webhook when it's paid. Payouts from the hot wallet need a full-access key.

The machine-readable reference is [`openapi.yaml`](https://coldtill.com/openapi.yaml) (OpenAPI 3.1), rendered at
[coldtill.com/docs/api](https://coldtill.com/docs/api). Import it into Postman, Insomnia or a client generator.
New here? Start with the guide [Accept a payment from your shop](https://coldtill.com/docs/guides/accept-payments.md).

- **Base URL:** your site URL (`COLDTILL_SITE_URL`), for example `https://pay.example.com`. If the site URL
  has a path, it is part of the base URL; see [Base URL and paths](#base-url-and-paths).
- **Authentication:** an `API-Key` header with a project API key. Create keys under **API keys** (project
  admin, with two-factor). Keys are shown once and stored hashed. Each key has a [scope](#api-key-scopes).
- **Format:** JSON request and response bodies. Amounts are decimal strings.
- **Errors:** a non-2xx status with `{"error": "message"}` and sometimes a `code`.
- **Rate limit:** 600 requests per minute per client IP. Exceeding it returns `429`.

An API key belongs to one project. A full-access key can create payments and payouts, but payouts can only go
to that project's address book, and large ones wait for an admin. See [Payouts](https://coldtill.com/docs/payouts.md).

## API key scopes

Each key is either **payments only** or **full access**. You choose when you create it, and it can't be changed
later: make a new key and revoke the old one instead.

| Endpoint | Payments only | Full access |
|---|---|---|
| `POST /api/v1/payment` | yes | yes |
| `GET /api/v1/payment/reference/{reference_id}` | yes | yes |
| `GET /api/v1/blockchain-currency/reference/{reference_id}` | yes | yes |
| `POST /api/v1/deposit-address/reference/{reference_id}` | yes | yes |
| `GET /api/v1/ticker` | yes (needs no key) | yes (needs no key) |
| `POST /api/v1/withdrawal/merchant` | no | yes |
| `GET /api/v1/withdrawal/merchant` | no | yes |
| `GET /api/v1/withdrawal/{id}/merchant` | no | yes |

- **Use payments-only keys for shop plugins and tills.** They hold the key on a web server or a device, and a
  leaked payments key can't see or send payouts.
- **New endpoints need full access** unless this table says otherwise.
- **Refusals:** a payments-only key calling any other endpoint gets `403` with
  `{"error": "this API key can only create and read payments", "code": "api_key_scope"}`.
- **Older keys:** keys created before scopes existed are full access. The dashboard shows each key's scope.
- **Dashboard API:** `POST /api/dash/projects/{projectID}/api-keys` takes `"scope": "payments"` or `"full"` and
  defaults to `payments`. Any other value is refused with `400`.

## Base URL and paths

Every endpoint path in this reference goes after your site URL. Coldtill can have a host to itself, or run under
a path of another site behind your own reverse proxy
([Run Coldtill under a path](https://coldtill.com/docs/guides/domains-and-dashboard.md#run-coldtill-under-a-path-of-another-site)):

| `COLDTILL_SITE_URL` | Create a payment at | Checkout links returned |
|---|---|---|
| `https://pay.example.com` | `https://pay.example.com/api/v1/payment` | `https://pay.example.com/pay/{reference_id}` |
| `https://example.com/coldtill` | `https://example.com/coldtill/api/v1/payment` | `https://example.com/coldtill/pay/{reference_id}` |

With a path in the site URL:

- **Everything is served under it:** the merchant API (`/coldtill/api/v1/…`), the checkout page and its API
  (`/coldtill/pay/…`, `/coldtill/api/checkout/…`), scripts and logos (`/coldtill/assets/…`,
  `/coldtill/branding/…`), and the dashboard. The `url` and `host` in responses include the path.
- **The proxy must pass the path through.** Coldtill removes the prefix itself. A request without it is served
  at the root, as if there were no path, so a proxy that strips the prefix breaks the checkout and dashboard.
- **What stays at the root:** a project's [checkout domain](https://coldtill.com/docs/guides/domains-and-dashboard.md#give-a-project-its-own-domain)
  serves its checkout and merchant API at the root of its own host (`https://pay.shop.com/api/v1/payment`), and
  its checkout links are `https://pay.shop.com/pay/{reference_id}`. The container health check calls
  `/healthz` at the root.
- **Webhooks don't change.** Coldtill sends them to the URL you set for the project, wherever Coldtill runs.

## Payments

### Create a payment

`POST /api/v1/payment`

```bash
curl -X POST https://pay.example.com/api/v1/payment \
  -H "API-Key: $COLDTILL_API_KEY" -H 'Content-Type: application/json' \
  -d '{"customerID":"42","customerEmail":"jane@example.com","amountInUSD":25.00,"invoiceID":"INV-1001"}'
```

| Field | Required | Description |
|---|---|---|
| `customerID` | yes | Your ID for the customer. The same ID always gets the same deposit addresses |
| `amountInUSD` | yes | Amount owed, greater than 0 and at most 10,000,000 |
| `customerEmail` | no | Stored with the customer |
| `invoiceID` | no | Your order reference, echoed in webhooks |
| `network` | no | Restrict the checkout to one network code (see [Network codes](#network-codes)) |
| `currency` | no | With `network`, restrict to one currency, for example `USDC` |
| `expire` | no | RFC 3339 expiry time, at least a minute ahead. Defaults to the project's payment expiry (24 hours) |
| `returnURL` | no | Where this payment's **Return to {store}** button goes once it's paid, for example your own saved checkout. Defaults to the project's Return URL. See [Return URL](#return-url) |

Response:

```json
{
  "host": "https://pay.example.com",
  "reference_id": "fd09c7e5-d661-4355-9b04-7b3749b41e2e",
  "url": "https://pay.example.com/pay/fd09c7e5-d661-4355-9b04-7b3749b41e2e"
}
```

Send the customer to `url`. A customer has at most one open payment: creating a new one replaces the previous
one (`REPLACED`). If the previous payment has a deposit that is still confirming, the request fails with `409`
so that deposit isn't stranded; retry after it confirms.

### Return URL

When a payment is paid, the checkout shows a **Return to {store}** button. Each payment stores where it goes
when it's created:

```json
{
  "customerID": "customer-123",
  "invoiceID": "top-up-456",
  "amountInUSD": 89.00,
  "returnURL": "https://shop.example.com/app/payment/return?state=your-token"
}
```

- **With `returnURL`**, the button opens that URL for this payment only.
- **Without it**, the payment takes the project's **Return URL** (Project settings) as it is at that moment.
  Without either, the checkout tells the customer they can close the page.
- **Stored per payment.** Changing the project's Return URL later doesn't change payments already created.
  [Get a payment](#get-a-payment) returns the stored `returnURL`.
- **Rules:** an absolute `https://` URL of at most 2,048 characters, with no username or password. Anything
  else is refused with `400`. A project admin can list **Allowed return hosts** in Project settings (for example
  `shop.example.com`); then a `returnURL` on any other host is refused with `400`. Host names must match
  exactly; list each subdomain you use. With no list, any valid `https://` URL is accepted.
- **Only a button.** Coldtill never redirects the customer by itself, and opening the URL tells Coldtill
  nothing: it doesn't mark the payment paid. Fulfil orders from the [webhook](https://coldtill.com/docs/webhooks.md) or
  [Get a payment](#get-a-payment), never from the visit to your return page, which anyone can open.

### Get a payment

`GET /api/v1/payment/reference/{reference_id}`

```json
{
  "invoiceID": "INV-1001",
  "customerID": "42",
  "amountInUSD": "25",
  "filledAmountInUSD": "25.00000000",
  "pendingAmountInUSD": "0",
  "paymentState": "FILLED",
  "referenceID": "fd09c7e5-…",
  "url": "https://pay.example.com/pay/fd09c7e5-…",
  "returnURL": "https://shop.example.com/thanks",
  "createdAt": "2026-10-10T15:58:23Z",
  "expiresAt": "2026-10-11T15:58:23Z",
  "deposits": [
    {
      "network": "BASE", "currency": "USDC", "amount": "25", "amountInUSD": "25",
      "transactionHash": "0x…", "status": "confirmed", "confirmations": 12, "requiredConfirmations": 10
    }
  ]
}
```

Payment states:

| State | Meaning | Final |
|---|---|---|
| `OPEN` | Nothing confirmed yet | no |
| `PARTIALLY_FILLED` | Confirmed amount is below 99% of the amount owed | no |
| `FILLED` | Confirmed amount is within 1% of the amount owed | yes |
| `OVER_FILLED` | Confirmed amount is more than 1% above the amount owed | yes |
| `CANCELLED` | Expired before being filled | yes |
| `REPLACED` | Superseded by a newer payment for the same customer | yes |

Ship the order on `FILLED` or `OVER_FILLED`. Prefer webhooks to polling.

### Payable currencies

`GET /api/v1/blockchain-currency/reference/{reference_id}` lists what the customer can pay with for this
payment: `blockchainCode`, `network`, `currencyCode`, `customerAddress` (empty until an address is assigned),
`tokenAddress`, `standard`, `walletPrecision`, `family` and `confirmations`. It carries no prices; use the
[ticker](#ticker) for USD prices.

### Deposit address

`POST /api/v1/deposit-address/reference/{reference_id}` with `{"blockchain_code": "BASE"}` returns the
customer's permanent address for that network's family. Use it to build your own checkout instead of the
hosted one.

### Ticker

`GET /api/v1/ticker` (no API key) lists enabled networks and tokens with USD prices:
`blockchainCode`, `currencyCode`, `tokenAddress`, `standard`, `walletPrecision`, `family`, `price`.

## Payouts

### Create a payout

`POST /api/v1/withdrawal/merchant` with an `Idempotency-Key` header:

```bash
curl -X POST https://pay.example.com/api/v1/withdrawal/merchant \
  -H "API-Key: $COLDTILL_API_KEY" -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: refund-INV-1001' \
  -d '{"blockchainCode":"BASE","currencyCode":"USDC","amount":"12.50","toAddress":"0xAbC…"}'
```

| Field | Description |
|---|---|
| `blockchainCode` | Network code: an EVM network or `SOL` |
| `currencyCode` | `ETH`, `USDC`, `USDT`, `SOL`… as enabled on that network |
| `amount` | Decimal amount in the currency, at most the token's decimals |
| `toAddress` or `addressBookId` | Destination. Through the API it must be in the project's address book |

Retrying with the same `Idempotency-Key` and the same parameters returns the original payout. Reusing a key
with different parameters returns `409`.

The response is the payout (see [Payout object](#payout-object)) with status `pending` or `pending-approval`.

### List and get payouts

- `GET /api/v1/withdrawal/merchant?limit=50&offset=0` lists payouts created through the API.
- `GET /api/v1/withdrawal/{id}/merchant` returns one payout.

### Payout object

```json
{
  "id": "5d1c…", "status": "sent", "network": "BASE", "currency": "USDC",
  "tokenContract": "0x8335…", "amount": "12.5", "amountInUSD": "12.50", "toAddress": "0xAbC…",
  "transactionHash": "0x…", "blockNumber": 21234567, "idempotencyKey": "refund-INV-1001",
  "createdBy": "system", "createdAt": "…", "updatedAt": "…"
}
```

`approvalReason` explains why a payout is held; `failureReason` explains a failure. Statuses are listed in
[Payouts](https://coldtill.com/docs/payouts.md#statuses).

## Network codes

| Code | Mainnet | Testnet mode |
|---|---|---|
| `ETH` | Ethereum | Sepolia |
| `BASE` | Base | Base Sepolia |
| `POLYGON` | Polygon | Amoy |
| `BSC` | BNB Smart Chain | BSC testnet |
| `TRON` | Tron | Nile |
| `SOL` | Solana | Devnet |
| `BTC` | Bitcoin | Signet |

## SDK

`sdk/typescript` wraps these endpoints and verifies webhooks, with no dependencies:

```ts
import { Coldtill, verifyWebhookRequest, isPaid } from '@coldtill/sdk'

const kh = new Coldtill({ baseUrl: 'https://pay.example.com', apiKey: process.env.COLDTILL_API_KEY! })
const { url } = await kh.createPayment({ customerID: '42', amountInUSD: 25, invoiceID: 'INV-1001' })
```

The [WooCommerce plugin](https://github.com/Coldtill/woocommerce-crypto-payment-gateway) adds Coldtill as a payment
method for USD stores. [Download `coldtill-woocommerce.zip`](https://github.com/Coldtill/woocommerce-crypto-payment-gateway/releases/latest/download/coldtill-woocommerce.zip),
then upload it under Plugins → Add New → Upload Plugin and follow the setup steps in its README.

The [DashCommerce plugin](https://github.com/Coldtill/dashcommerce-crypto-payment-gateway) adds Coldtill as a payment
provider to [DashCommerce](https://github.com/emdashCommerce/dashcommerce) shops on EmDash. Install it with
`npm install @coldtill/dashcommerce` and follow its README. Modules for [PrestaShop](https://github.com/Coldtill/prestashop-crypto-payment-gateway),
[Magento 2](https://github.com/Coldtill/magento-crypto-payment-gateway) and
[WHMCS](https://github.com/Coldtill/whmcs-crypto-payment-gateway) work the same way. The [EmDash plugin](https://plugins.emdashcms.com/plugins/@coldtill.com/coldtill) sells products straight from an EmDash site. All integrations are listed at
[coldtill.com/integrations](https://coldtill.com/integrations/).

---

Source: https://coldtill.com/docs/api/ · All Coldtill docs: https://coldtill.com/llms.txt
