API documentation

Authenticate with Authorization: Bearer <api_key>. Responses use a status + data envelope. Base URL in development: http://127.0.0.1:3400.

OpenAPI spec (YAML)

Endpoints

MethodPathDescription
POST/v1/invoicesCreate invoice for a linked account
GET/v1/invoices/:idInvoice status
POST/v1/link-sessionsStart ShamCash link (sandbox QR)
GET/v1/accountsLinked receiver accounts
PUT/v1/webhookSet webhook URL (returns signing secret once)
POST/v1/api-keysIssue API key (secret shown once)

Create invoice (Node)

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();

Verify webhook (Node)

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'));
}