Build

API reference

Base URL https://api.afripei.co.tz. Send Authorization: Bearer sk_live_... and Content-Type: application/json. Amounts are decimal strings with two places. Currency is TZS.

RoutePurpose
POST /v1/paymentsCreate a collection. Requires Idempotency-Key and payments.create.
GET /v1/paymentsList collections. Filters: status, merchant_reference, created_gte, created_lte.
GET /v1/payments/:idRead one collection.
POST /v1/payments/:id/cancelCancel a pending prompt or close a control number.
POST /v1/checkout_sessionsCreate a hosted pay page. A publishable key may call this.
GET /v1/checkout_sessions/:idRead a pay page. No key required. The id is the capability.
POST /v1/checkout_sessions/:id/submitSend the prompt for a pay page. Body is { phone }.
POST /v1/payoutsSend to mobile money or a bank. Requires Idempotency-Key.
POST /v1/payouts/bulkSend many mobile-money payouts. One reservation for the batch.
GET /v1/payoutsList payouts.
GET /v1/payouts/:idRead one payout.
GET /v1/banksList banks for a bank payout.
GET /v1/balanceAvailable, pending, and reserved balances.
GET /v1/balance/transactionsLedger lines. Query currency, default TZS.
POST /v1/customersSave a customer.
GET /v1/customersList customers.
GET /v1/customers/:idRead one customer.
POST /v1/webhook_endpointsRegister an endpoint. Returns the signing secret once.
GET /v1/webhook_endpointsList endpoints.
POST /v1/webhook_endpoints/:id/rotate_secretReplace the signing secret.
POST /v1/webhook_endpoints/:id/testSend a signed test event.
POST /v1/webhook_endpoints/:id/disableStop deliveries.
GET /v1/eventsList stored events.
POST /v1/events/:id/replayDeliver one stored event again.
GET /v1/statusPublic component status.

Object

A payment includes id, amount, currency, status, payment_method, merchant_reference, failure_message, and control_number when the method is billpay. A payout includes id, amount, currency, status, and method.

Headers on every call

  • Authorization: Bearer with a secret key, except the public checkout read.
  • Content-Type: application/json when you send a body.
  • Idempotency-Key on every create that can move money or open a payment.

Amounts

Decimal strings with two places. Currency TZS. Mobile-money collections run from 500.00 to 3000000.00. Phones are Tanzania numbers in E.164, beginning with +255. Customers and recipients use M-Pesa, Airtel Money, Mixx by Yas, or Halopesa. You send the number, not a network code.

Errors

Failures are a JSON error object with code, message, and request_id. A 201 that later fails on the wallet is not this object. That outcome is the payment or payout status. The codes are listed on the errors page.

Versions

The API version on events is 2026-09-29. Objects keep the field names on this page. A field you do not recognize should be ignored, not rejected, so a later addition does not break a reader.