Getting started
Every call goes to https://cryptora.dev/api/pay/v1 over HTTPS, sends and returns JSON, and is made from your server with a secret key from Merchant → Developers. The flow of a payment:
- Your server creates an invoice for the order and gets its
checkoutUrl. - You send the customer to that address. They pick a coin and pay, or pay from their Cryptora account.
- Cryptora sends
invoice.paidto your webhook once the payment is confirmed, and the customer returns to yoursuccessUrl. - Your server checks the webhook signature and fulfils the order.
Authentication
Send your secret key as a bearer token. Keys start with sk_live_ (real payments) or sk_test_ (test mode); a key sees only invoices of its own mode. Keep keys on your server: never in a browser, an app or a repository.
curl https://cryptora.dev/api/pay/v1/invoices \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042" \
-d '{"amount": "49.90", "currency": "USD", "orderId": "1042", "description": "Order 1042"}'Idempotency. Send an Idempotency-Key header (up to 80 characters, your order id works) when creating an invoice. A retry with the same key returns the invoice the first call made, so a timeout never makes two invoices.
Errors and limits
A refused call answers with a 4xx status and an error object. 5xx means a fault on our side: retry with the same idempotency key.
HTTP/1.1 400 Bad Request
{ "error": { "code": "invalid_amount", "message": "Enter an amount above zero.", "field": "amount" } }| Field | Type | Meaning |
|---|---|---|
| 401 invalid_key | auth | The key is missing, wrong or revoked. |
| 400 invalid_* | input | A field does not pass; field names it. |
| 404 not_found | lookup | No such object for this key and mode. |
| 409 invoice_closed | state | The invoice can no longer change that way. |
| 429 rate_limited | rate | Up to 300 calls a minute per key. Wait and retry. |
| 503 no_rate | pricing | The currency cannot be priced right now. Retry shortly. |
Create an invoice
POST /invoices returns 201 with the invoice. Send the customer to its checkoutUrl.
| Field | Type | Meaning |
|---|---|---|
| amount | string | Required. The price, like "49.90". Money: up to 2 places; a coin: up to 8. |
| currency | string | Required. A money currency (USD, EUR...) or a coin (USDT, BTC...). See /currencies. |
| orderId | string | Your order number, up to 128 characters; searchable. |
| description | string | Shown to the customer at checkout, up to 500 characters. |
| customerEmail | string | The customer’s email, kept with the invoice. |
| metadata | object | Up to 50 keys and 4 KB, returned as given in the invoice and its webhooks. |
| successUrl | string | Where the customer returns after paying. |
| cancelUrl | string | Where the customer returns if they do not pay. |
| expiresInMinutes | integer | 15 to 10080. Defaults to your account’s setting. |
| network | string | CHAIN:COIN, like "TRX:USDT", to skip the coin choice and quote at once. |
The invoice object
{
"id": "inv_8KqZ2xD3vY7TmPQaWb1c",
"mode": "live",
"status": "paid",
"exception": "none",
"price": { "amount": "49.9", "currency": "USD", "isMoney": true },
"orderId": "1042",
"description": "Order 1042",
"metadata": { "cart": "8812" },
"checkoutUrl": "https://cryptora.dev/pay/inv_8KqZ2xD3vY7TmPQaWb1c",
"method": "onchain",
"pay": { "currency": "USDT", "chain": "TRX", "amount": "49.9", "rate": "1", "address": "T...", "quoteExpiresAt": "..." },
"received": "49.9",
"paidValue": "49.9",
"fee": "0.499",
"settleCurrency": "USDT",
"settled": "49.401",
"refunded": "0",
"expiresAt": "...", "paidAt": "...", "createdAt": "...",
"payments": [ { "currency": "USDT", "amount": "49.9", "txHash": "...", "confirmations": 20, "status": "confirmed" } ],
"refunds": []
}Amounts are decimal strings; read them as decimals, never floats. received is what arrived in the coin asked for, paidValue what it is worth in the price currency, settled what reached your wallet after the fee.
Statuses
| Field | Type | Meaning |
|---|---|---|
| new | status | Created; the customer has not picked how to pay. |
| pending | status | A coin is picked and quoted; waiting for the payment. |
| confirming | status | Enough arrived; waiting for network confirmations. |
| paid | status | Paid and confirmed. Fulfil the order. |
| expired | status | Time ran out. With exception underpaid, part was paid. |
| cancelled | status | You cancelled it before anything arrived. |
| refunded | status | Everything received was refunded. |
| underpaid | exception | Less than the price arrived (beyond your tolerance). |
| overpaid | exception | More than the price arrived; the invoice is paid. |
| paid_late | exception | Paid after it expired (or after you cancelled it). |
| wrong_coin | exception | Another coin arrived at the address; credited to you as it is. |
A rate is held for a short window. If it runs out before the customer pays, they get a new one while the invoice is open. A payment that arrives after expiry is still found for a while, credited to you and marked paid_late.
Read and list invoices
GET /invoices/{id}
GET /invoices?status=paid&q=1042&page=1&limit=25status also takes open (new, pending, confirming) and exception; q matches an invoice id, order id, customer email or address. Lists answer { data, total, page, limit }.
Cancel an invoice
POST /invoices/{id}/cancelOnly an open invoice nothing has been paid on can be cancelled.
Refunds
POST /invoices/{id}/refunds
{ "amount": "10", "method": "account" }
{ "amount": "10", "method": "onchain", "address": "T...", "memo": null, "reason": "Returned item" }Refunds are paid in the coin the customer paid, from your balance. account returns it at once to the account that paid. onchain is created as pending: you confirm it in your dashboard with your verification code, so a key alone can never send money off the site. You hear refund.completed or refund.failed.
Payment links
POST /links
{ "title": "Consulting hour", "currency": "USD", "amount": "120" }
{ "title": "Donation", "currency": "USD", "amount": null, "minAmount": "5", "askEmail": true }
GET /linksA link is a page anyone can pay; each payment on it is its own invoice, with its own webhooks.
Currencies and rates
GET /currencies { priceCurrencies, networks, accountCoins }
GET /rates?currency=USD { currency, at, rates: [{ coin, rate }] }Rates are a guide; an invoice’s own quote is what a customer pays at.
Webhooks
Add an endpoint in Developers → Webhooks. Each event is POSTed as JSON; answer with any 2xx within 10 seconds. A delivery that fails is sent again after 1, 5, 15 and 30 minutes, then 1, 2, 4, 8, 12 and 24 hours, until it is answered or its attempts run out. Events can arrive more than once and out of order: use the event id to skip repeats, and read the invoice’s status rather than the order of events.
{
"id": "evt_...",
"type": "invoice.paid",
"created": 1767225600,
"livemode": true,
"data": { "object": { "id": "inv_...", "status": "paid", ... } }
}invoice.createdinvoice.pendinginvoice.payment_detectedinvoice.paidinvoice.underpaidinvoice.overpaidinvoice.paid_lateinvoice.expiredinvoice.cancelledinvoice.refundedrefund.completedrefund.failedVerify a webhook
Each delivery carries X-Webhook-Signature: t=<unix seconds>,v1=<hex>. Compute HMAC-SHA256 of "<t>.<raw body>" with your endpoint’s signing secret, compare in constant time, and refuse a timestamp more than five minutes old.
// Node.js (Express): use the raw body, not the parsed JSON
const crypto = require('crypto');
app.post('/webhooks/crypto', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('X-Webhook-Signature') || '';
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const expected = crypto.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(parts.t + '.' + req.body).digest('hex');
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
const ok = parts.v1 && fresh &&
crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
if (!ok) return res.sendStatus(400);
const event = JSON.parse(req.body);
if (event.type === 'invoice.paid') { /* fulfil event.data.object.orderId */ }
res.sendStatus(200);
});<?php // PHP
$body = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? ''), $sig);
$expected = hash_hmac('sha256', $sig['t'] . '.' . $body, getenv('WEBHOOK_SECRET'));
if (!hash_equals($expected, $sig['v1'] ?? '') || abs(time() - (int) $sig['t']) > 300) {
http_response_code(400); exit;
}
$event = json_decode($body, true);
if ($event['type'] === 'invoice.paid') { /* fulfil $event['data']['object']['orderId'] */ }
http_response_code(200);Test mode
Calls made with an sk_test_ key make test invoices: their checkout has buttons that act out a payment in full, in part or over the price, and its confirmation. Test webhooks go to your test endpoints. No money moves and nothing reaches your wallet. Switch the dashboard to Test to see them.