PesaRail Developers
Money in. Money out. One API.
PesaRail exposes the same rails the platform runs on to your software: a universal disburser for single and bulk payouts (large and bulk money), and a universal receiver that accepts money from EVM wallets and non-EVM chains. Every movement is journaled first, hash-chained in the audit log, and traceable end-to-end for compliance.
1. Authentication
All Developers endpoints use Authorization: Bearer API keys shaped pesarail_<keyId>_<secret>. Keys are issued by the platform admin (the plaintext secret is shown once and stored only as a SHA-256 hash). Rate limit: 60 calls per minute per key — HTTP 429 with retryAfterMs beyond that.
curl https://<host>/api/developers/v1/payouts \ -H "Authorization: Bearer pesarail_<keyId>_<secret>"
2. Payouts — money out
POST /api/developers/v1/payouts — one payout, journal-first. Mode kes pays whole KES shillings to a saved payout ID through the Cyzora credential rail, backed by the KES hub pot (the pot is debited before the rail call; a refused rail call auto-returns the shillings). Mode onchain creates a custody withdrawal request to a whitelisted address — it stays PENDING_APPROVAL until the platform operator approves and broadcasts; an API key never self-approves a custody send.
curl -X POST https://<host>/api/developers/v1/payouts \
-H "Authorization: Bearer pesarail_<keyId>_<secret>" \
-H "Content-Type: application/json" \
-d '{
"idempotencyKey": "order-8841",
"mode": "kes",
"amountKes": 45000,
"payoutId": "254712345678",
"note": "merchant settlement"
}'
# 200 { "ok": true, "reference": "CORRIDOR-20261127-…", "payoutRef": "…",
# "state": "SETTLED", "amountKes": 45000, "balanceAfterKes": 10362000 }
# status poll
curl "https://<host>/api/developers/v1/payouts?reference=order-8841" \
-H "Authorization: Bearer pesarail_<keyId>_<secret>"3. Bulk disbursement
POST /api/developers/v1/payouts/batch — up to 100 items per batch, every item idempotent and individually adjudicated. The response carries a per-item state plus a batch summary, so payroll-style runs can reconcile exactly which lines settled.
curl -X POST https://<host>/api/developers/v1/payouts/batch \
-H "Authorization: Bearer pesarail_<keyId>_<secret>" \
-H "Content-Type: application/json" \
-d '{ "items": [
{ "idempotencyKey": "pay-001", "mode": "kes", "amountKes": 5000, "payoutId": "254712000001" },
{ "idempotencyKey": "pay-002", "mode": "kes", "amountKes": 12500, "payoutId": "254733000002" }
] }'
# 200 { "ok": true, "batchId": "BATCH-…",
# "summary": { "total": 2, "settled": 2, "pending": 0, "failed": 0, "refused": 0 },
# "results": [ ... ] }4. Receive addresses — money in
POST /api/developers/v1/receive/addresses — chain stellar issues a dedicated custody wallet (layered key ceremony; the private key never leaves the custody envelope — you only ever get the public address and an attribution memo). Chain evm registers watch-mode for an address you control: the EVM inventory watcher attributes observed deposits into the same books. PesaRail is non-custodial for EVM keys by design.
# non-EVM (Stellar): dedicated custody receive wallet
curl -X POST https://<host>/api/developers/v1/receive/addresses \
-H "Authorization: Bearer pesarail_<keyId>_<secret>" \
-H "Content-Type: application/json" \
-d '{ "chain": "stellar", "label": "Checkout deposits" }'
# 201 { "ok": true, "receiveId": "RCV-…", "chain": "stellar",
# "address": "G…", "memo": "PR-…", "state": "ACTIVE" }
# EVM: watch-mode registration
curl -X POST https://<host>/api/developers/v1/receive/addresses \
-H "Authorization: Bearer pesarail_<keyId>_<secret>" \
-H "Content-Type: application/json" \
-d '{ "chain": "evm", "evmAddress": "0xYourAddress…", "label": "USDT inflows" }'
# deposits observed for an address
curl "https://<host>/api/developers/v1/receive/addresses?address=G…&limit=25" \
-H "Authorization: Bearer pesarail_<keyId>_<secret>"5. Idempotency, limits & statuses
- Idempotency — every payout item carries your
idempotencyKey; replays return the original result instead of double-paying. Batch keys must be unique within the batch. - Whole shillings — KES amounts are integers; the corridor never rounds (10.5 is refused, not floored).
- Per-item cap — KES 100,000,000; per-batch — 100 items; rate — 60 calls/min/key.
- States —
SETTLED·PENDING_APPROVAL(onchain custody sends awaiting operator dual control) ·FAILED(rail refused after commit — shillings auto-returned to the pot) ·REFUSED(validation/balance gate, nothing moved) ·REPLAYED(idempotent re-read of an earlier call).
6. Compliance & audit
Every API movement lands in the same journals the dashboard runs on (KES hub pot journal, KesPayout dual-control rows, custody withdrawal pipeline) and in the hash-chained audit log — the trail is verifiable and CSV-exportable from the regulator surface (/api/audit/moneyflow). Authorities can replay any shilling end-to-end: float → pot → payout → channel, leg by leg.