RCTPReceiver-Consent Transaction Protocol

RCTP API, version 1

A small JSON API for driving an organisation sandbox from your own systems: a USSD gateway, a core banking test harness, or a regulator's evaluation scripts. Every call acts on the organisation that owns the key and nothing else.

Basics

What the API cannot do

By design, and for every organisation: there is no endpoint that confirms without the receiver's PIN, no auto-confirm, no trusted-sender bypass, no amount threshold that skips consent, no balance editing, and no way to edit or delete audit records. The only path to a credit is a correct-PIN CONFIRM from the certified number.

Initiate a transfer

POST /api/v1/transfers (full key). The destination is logged as evidence before anything else, then funds move into escrow and a challenge goes to the certified number.

curl -X POST https://rctp-platform-production.up.railway.app/api/v1/transfers \
  -H "Authorization: Bearer $RCTP_KEY" -H "Content-Type: application/json" \
  -d '{"sender":"+233200000001","certified":"+233200000002",
       "destination":"+233209999999","amount_pesewas":5000,"sender_pin":"1234"}'

201 response:

{"transfer":{"ref":"RC1A2B3C","state":"ESCROW","sender":"+233200000001","certified":"+233200000002",
 "destination":"+233209999999","mismatch":true,"amount_pesewas":5000,
 "created_at":1790000000000,"expires_at":1790000300000,"resolved_at":null}}

A refused initiation (wrong PIN, unknown certified number, insufficient funds, a pending transfer to the same certified number) returns 422 initiation_refused. It is still audited, including the destination.

Pending challenges

GET /api/v1/challenges?msisdn=+233200000002. When nothing is pending, the response carries the Universal Trust Rule, for display on your receiver-facing surface:

{"msisdn":"+233200000002","challenges":[],
 "trust_rule":"No RCTP challenge means no legitimate incoming credit."}

Resolve a challenge

POST /api/v1/transfers/{ref}/resolve (full key). msisdn is the SIM the reply came from, as attested by your channel (the same trust model as Africa's Talking's phoneNumber). If it is not the certified number the attempt is rejected and audited as NON_CERTIFIED_REJECTED, whatever the PIN.

curl -X POST https://rctp-platform-production.up.railway.app/api/v1/transfers/RC1A2B3C/resolve \
  -H "Authorization: Bearer $RCTP_KEY" -H "Content-Type: application/json" \
  -d '{"msisdn":"+233200000002","pin":"5678","action":"DENY"}'
{"outcome":"DENIED","transfer":{"ref":"RC1A2B3C","state":"DENIED", …}}

Read a transfer

GET /api/v1/transfers/{ref} returns {"transfer": …} or 404. States: ESCROW, CONFIRMED, DENIED, EXPIRED.

Wallets

GET /api/v1/wallets returns balances and total_pesewas (wallets plus escrow), which stays constant between resets: the reconciliation figure for invariant 2.

Audit log

GET /api/v1/audit?after=0&limit=100 pages the organisation's hash chain in order (limit up to 500; continue with after=next_after). GET /api/v1/audit/verify re-walks the whole chain now:

{"valid":true,"broken_at":null,"event_count":42,"genesis_hash":"…","head_hash":"…","verified_at":1790000000000}

Each record's hash is SHA-256 over prev_hash|ts|event|tx_ref|actor|details (null tx_ref/actor as empty strings, details as the stored JSON string). An organisation's genesis hash is SHA-256 of RCTP|genesis|<organisation id>. The console's evidence pack bundles the chain with this recipe for independent verification.

Webhooks

Set an HTTPS endpoint in the console. Events are delivered after the ledger commits (one retry), so a slow endpoint never delays a transfer. Types: transfer.escrowed, transfer.confirmed, transfer.denied, transfer.expired, resolution.rejected, ping.

{"id":"evt_…","type":"transfer.confirmed","created_at":1790000000000,
 "organisation_id":"t_…","data":{"ref":"RC1A2B3C","amount_pesewas":5000, …}}

Verify the RCTP-Signature: t=<unix seconds>,v1=<hex> header: HMAC-SHA256 with your signing secret over t + "." + raw request body. Compare in constant time and reject old timestamps.

const crypto = require('node:crypto');
function verify(secret, header, rawBody, toleranceSec = 300) {
  const p = Object.fromEntries(header.split(',').map((kv) => kv.split('=')));
  const t = Number(p.t);
  if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;
  const expect = crypto.createHmac('sha256', secret).update(t + '.' + rawBody).digest();
  const got = Buffer.from(p.v1 || '', 'hex');
  return got.length === expect.length && crypto.timingSafeEqual(got, expect);
}

Sandbox notes