Authenticate with Authorization: Bearer <api_key>. Responses use a status + data envelope. Base URL in development: http://127.0.0.1:3400.
| Method | Path | Description |
|---|---|---|
| POST | /v1/invoices | Create invoice for a linked account |
| GET | /v1/invoices/:id | Invoice status |
| POST | /v1/link-sessions | Start ShamCash link (sandbox QR) |
| GET | /v1/accounts | Linked receiver accounts |
| PUT | /v1/webhook | Set webhook URL (returns signing secret once) |
| POST | /v1/api-keys | Issue API key (secret shown once) |
const res = await fetch('https://api.cashrelay.example/v1/invoices', {
method: 'POST',
headers: {
Authorization: 'Bearer cr_test_…',
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
linked_account_id: 'acc_…',
expected_amount: '50000',
currency: 'SYP',
payment_note: 'order-1042',
}),
});
const { data } = await res.json();Header: X-CashRelay-Signature: t=<unix>,v1=<hex>
import { createHmac, timingSafeEqual } from 'node:crypto';
function verifyWebhook(rawBody, header, secret) {
const parts = Object.fromEntries(
header.split(',').map((p) => {
const i = p.indexOf('=');
return [p.slice(0, i), p.slice(i + 1)];
}),
);
const t = Number(parts.t);
const expected = createHmac('sha256', secret)
.update(`${t}.${rawBody}`)
.digest('hex');
return timingSafeEqual(Buffer.from(parts.v1, 'hex'), Buffer.from(expected, 'hex'));
}