Start
Sandbox
The sandbox API is https://api.sandbox.afripei.co.tz. It uses the same routes as production and moves no shillings. A test key starts with sk_test_. Production rejects that key.
Open an account
In the merchant portal, open Developers and choose Create a test key. The key is shown once. It belongs to the same business email and moves no shillings. You can also register on the sandbox API directly. That account is active immediately.
curl https://api.sandbox.afripei.co.tz/v1/portal/register \
-H "Content-Type: application/json" \
-d '{
"email": "amina@example.com",
"password": "correct-horse-battery",
"full_name": "Amina Juma",
"organization_name": "Amina Shop"
}'Create a collection
Send the same body you will send in production. The last two digits of the phone choose the result. A phone ending in 00 stays pending for a short time, then the worker marks it success and posts the ledger. No wallet prompt is sent.
| Phone ends with | Result |
|---|---|
00 | Success after a short pending period |
01 | Stays pending until you advance it |
02 | Failed |
03 | Expired |
04 | Cancelled |
05 | Success, then you can advance it to reversed |
A payout ending in 11 fails. Any other payout phone succeeds. 10 is the success suffix.
curl https://api.sandbox.afripei.co.tz/v1/payments \
-H "Authorization: Bearer sk_test_..." \
-H "Idempotency-Key: order-1001" \
-H "Content-Type: application/json" \
-d '{
"amount": "500.00",
"currency": "TZS",
"payment_method": "mobile_money",
"merchant_reference": "order-1001",
"customer": { "phone": "+255700000000", "name": "Amina Juma" }
}'Advance a payment
POST /v1/sandbox/payments/:id/advance with { "status": "success" } moves that payment through the same state machine as a provider callback. The status may be success, pending, failed, expired, cancelled, or reversed. This route is absent on https://api.afripei.co.tz.
What stays the same
Amounts are decimal strings. Currency is TZS. Idempotency keys, webhook signatures, and the ledger rules match production. Fulfill on payment.success. A sandbox balance cannot be paid out on the live API, and a live key cannot call the sandbox.