Reference
BitnovaPay API
REST API for Direct Pay (non-custodial STK orchestration) and Smart Gateway (custodial M-Pesa, cards, PayPal, crypto). JSON in, JSON out. HTTPS only.
Overview
The API has two namespaces - personal (individual user keys) and business (scoped to a business).
Bearer token: pk_live_-
https://pay.bitnova.co.ke/api/v1/
Bearer token: bsk_live_-
https://pay.bitnova.co.ke/api/v2/
Authentication
Pass your API key as a Bearer token in the Authorization header.
# Direct Pay - personal key curl -X GET https://pay.bitnova.co.ke/api/v1/balance \ -H "Authorization: Bearer pk_live_xxxxxxxxxxxx" # Smart Gateway - business key curl -X POST https://pay.bitnova.co.ke/api/v2/payment \ -H "Authorization: Bearer bsk_live_xxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{"method":"mpesa","amount":1000,"phone":"0712345678"}'
Quick Start
Direct Pay - Non-Custodial STK
Money goes straight to your paybill. Bitnova deducts a flat fee from your service wallet.
// 1. Create a channel (your paybill or till) curl -X POST https://pay.bitnova.co.ke/api/v1/channels \ -H "Authorization: Bearer pk_live_xxx" \ -H "Content-Type: application/json" \ -d '{"label":"Equity Bank","type":"paybill","shortcode":"247247"}' // 2. Fire STK push directly to that channel curl -X POST https://pay.bitnova.co.ke/api/v1/stk-push \ -H "Authorization: Bearer pk_live_xxx" \ -H "Content-Type: application/json" \ -d '{"channel_id":1,"amount":500,"phone":"0712345678"}'
Smart Gateway - Custodial M-Pesa
Funds collected by Bitnova, credited to your wallet after fees.
curl -X POST https://pay.bitnova.co.ke/api/v1/charges \
-H "Authorization: Bearer pk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"method": "mpesa",
"amount": 1500,
"phone": "0712345678",
"description": "Order #1234"
}'Error Handling
All errors return a JSON body with an error field. HTTP status follows REST conventions.
{
"error": "Phone number required for M-Pesa.",
"code": 400
}| HTTP Status | Meaning |
|---|---|
400 | Bad request - missing or invalid parameter |
401 | Unauthorized - invalid or missing API key |
403 | Forbidden - insufficient permissions |
404 | Resource not found |
429 | Rate limit exceeded |
500 | Server error - try again |
Channels - Direct Pay
Channels are your own paybill, till, or bank shortcodes. STK pushes go directly to these destinations.
{ "data": [{ "id": 1, "label": "Equity Bank", "type": "paybill", "shortcode": "247247", "is_active": true }], "count": 1 }| Parameter | Type | Description | |
|---|---|---|---|
| label | string | required | e.g. "Equity Bank" |
| type | string | required | paybill | till | bank |
| shortcode | string | required | M-Pesa paybill or till number |
| account_reference | string | optional | Prefix on M-Pesa prompt |
STK Push - Direct Pay
| Parameter | Type | Description | |
|---|---|---|---|
| channel_id | integer | required | ID from GET /channels — this is the bank/till shortcode (PartyB) |
| amount | float | required | Amount in KES (min 1) |
| phone | string | required | 07XXXXXXXX or 2547XXXXXXXX — customer's M-Pesa (PartyA) |
| description | string | optional | Max 20 chars (shown on M-Pesa prompt) |
| payer_name | string | optional | Customer name for receipt |
| payer_email | string | optional | Send receipt to this address |
Response
{ "status":"pending","module":"A","reference":"MDA-XXXXXXXXXX","fee":5.00,"message":"STK sent to 0712345678. Complete on your phone." }Create Payment - Smart Gateway
Initiate a custodial payment. Funds collected by Bitnova, credited to your wallet after fees.
| Parameter | Type | Description | |
|---|---|---|---|
| method | string | required | mpesa | card | paypal | crypto |
| amount | float | required | Amount in KES |
| phone | string | if mpesa | 07XXXXXXXX or 2547XXXXXXXX |
| description | string | optional | Order description |
| payer_email | string | optional | Receipt email |
PayPal / Card response
{ "gateway":"paypal","redirect":"https://www.paypal.com/checkoutnow?token=xxx","reference":"BNP-XXXXXXXXXX" }Crypto response (NOWPayments)
{ "gateway":"nowpayments","redirect":"https://nowpayments.io/payment/?iid=xxxx","invoice_id":"xxxx" }Payment Status
{ "reference":"BNP-XXXXXXXXXX","status":"completed","amount":1500,"fee":15,"net_amount":1485,"method":"mpesa" }Transactions
| Query param | Type | Default | Description |
|---|---|---|---|
| status | string | all | pending | completed | failed |
| module | string | all | A (Direct Pay) | B (Smart Gateway) |
| method | string | all | mpesa | card | crypto |
| page | integer | 1 | Pagination |
| per_page | integer | 15 | Max 100 |
Wallet Balance
{ "balance":12500.00,"locked_balance":15.00,"available":12485.00,"currency":"KES" }locked_balance is reserved for pending Direct Pay service fees. Released automatically on completion or failure.Disbursements
Pay M-Pesa numbers straight from your wallet (M-Pesa B2C). Your wallet is debited amount + fee when the request is accepted and each payout is sent immediately. If M-Pesa rejects a payout, that recipient's debit is refunded automatically.
sk_live_…), never from a browser or mobile app.amountis a whole number of KES, minimum 10.- The fee is the standard withdrawal fee, a flat amount set by the transfer size (see the fee schedule in your dashboard), charged per recipient on top of the amount.
phoneaccepts07XXXXXXXX,01XXXXXXXXor2547XXXXXXXX.- Who pays the fee (
fee_payer):sender(default) debits your wallet amount + fee and the recipient gets the full amount.recipientdebits your wallet exactly amount and the recipient receives amount − fee (fee rounded up to a whole shilling), so you never absorb the fee. Userecipientwhen your own customers are withdrawing. The recipient must still receive at least KES 10. - Idempotency: send an
Idempotency-Keyheader (oridempotency_keyin the body; 1–64 chars of letters, digits,_ . : -) on every payout request. Retrying with the same key returns the original disbursement with"idempotent_replay": trueinstead of paying twice. Use a fresh key for each new payout. - A successful response means the payout was accepted (
processing). The final result is sent to your webhook asdisbursement.sentordisbursement.failed, and can be polled with the GET endpoints below.
| Parameter | Type | Description | |
|---|---|---|---|
| recipient_name | string | required | Recipient's name (for your records) |
| phone | string | required | 07XXXXXXXX or 2547XXXXXXXX |
| amount | integer | required | Whole KES, min 10 |
| method | string | optional | Only mpesa (default) |
| fee_payer | string | optional | sender (default) or recipient |
curl -X POST https://pay.bitnova.co.ke/api/v1/disbursements \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: payout-1042" \
-d '{"recipient_name":"Jane Doe","phone":"0712345678","amount":5000}'Response 201
{
"status": "processing",
"reference": "DSB-3F9A1C2B7D",
"batch_id": 118,
"recipient": "Jane Doe",
"phone": "254712345678",
"amount": 5000,
"fee": 65,
"fee_payer": "sender",
"total_debited": 5065,
"currency": "KES"
}The whole request is validated first. If any recipient is invalid (HTTP 422) or your balance can't cover the total (HTTP 402), nothing is debited. Each recipient is paid and tracked separately.
| Parameter | Type | Description | |
|---|---|---|---|
| title | string | optional | Label for the batch, e.g. "July Payroll" |
| recipients | array | required | 1–100 objects: name, phone, amount |
| method | string | optional | Only mpesa (default) |
curl -X POST https://pay.bitnova.co.ke/api/v1/disbursements/bulk \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"title": "July Payroll",
"recipients": [
{"name":"John Doe", "phone":"0712345678","amount":50000},
{"name":"Jane Smith","phone":"0756789012","amount":45000}
]
}'Response 201
{
"status": "processing",
"batch_id": 119,
"recipients": 2, "accepted": 2, "failed": 0,
"total_amount": 95000, "total_fee": 980,
"items": [
{"reference":"DSB-91B0E4A2C6","recipient":"John Doe","phone":"254712345678","amount":50000,"fee":515,"status":"processing","error":null},
{"reference":"DSB-5D27F8A913","recipient":"Jane Smith","phone":"254756789012","amount":45000,"fee":465,"status":"processing","error":null}
]
}"status":"failed" with an error and only those recipients are refunded. If every payout is rejected you get HTTP 502 and a full refund.Query: amount (whole KES, min 10) and fee_payer (sender | recipient). Nothing is debited.
GET /api/v1/disbursements/quote?amount=100&fee_payer=recipient
{ "amount":100, "fee_payer":"recipient", "fee":16, "recipient_receives":84, "total_debited":100, "currency":"KES" }{
"reference": "DSB-3F9A1C2B7D",
"status": "completed",
"recipient": "Jane Doe", "phone": "254712345678",
"amount": 5000, "fee": 65, "currency": "KES",
"mpesa_receipt": "SGL1A2B3C4",
"failure_reason": null,
"batch_id": 118,
"created_at": "2026-10-27T21:30:00+03:00",
"completed_at": "2026-10-27T21:30:12+03:00"
}| Status | Meaning | |
|---|---|---|
| processing | Accepted, awaiting M-Pesa's result | |
| completed | Delivered; mpesa_receipt is set | |
| failed | Not delivered and refunded; failure_reason is set | |
| pending_review | M-Pesa timed out. The amount stays held until we confirm the outcome with Safaricom, then it is settled or refunded. Do not re-send. |
Returns batch_id, title, status, recipients, completed, failed, total_amount, total_fee and items[] (same shape as the single status above). Batch status is processing until every item settles, then completed, partial (some failed) or failed.
Errors
| Code | Meaning | |
|---|---|---|
| 400 / 422 | Invalid recipient, phone or amount (bulk errors name the recipient index) | |
| 402 | Insufficient available balance (balance minus locked funds, including fees) | |
| 403 | Account inactive, or identity verification (KYC) not completed | |
| 409 | A request with the same idempotency key is still being processed; retry shortly | |
| 502 | M-Pesa rejected the payout; balance restored | |
| 503 | Payouts temporarily unavailable; nothing was debited |
Register Webhook
Webhooks can be registered via the API — useful for plugins and integrations that auto-configure on install. Registrations are idempotent: registering the same URL twice returns the existing secret.
| Parameter | Type | Description | |
|---|---|---|---|
| url | string | required | HTTPS URL to receive events |
| events | array | required | payment.success | payment.failed | withdrawal.success | withdrawal.failed | disbursement.sent | disbursement.failed |
| source | string | optional | api | woocommerce | shopify |
Response
{ "id": 1, "secret": "whsec_xxxxxxxxxxxxxxxx", "url": "https://yoursite.com/webhooks", "events": ["payment.success","payment.failed"] }secret securely — it is only returned once. Use it to verify incoming webhook signatures.{ "data": [{ "id": 1, "url": "https://...", "events": ["payment.success"], "is_active": true }], "count": 1 }{ "deleted": true, "id": 1 }Webhook Events
Configure endpoints in your dashboard under Settings → Webhooks. Bitnova sends signed JSON to your URL on every payment event.
Payload structure
{
"event": "payment.success",
"timestamp": 1735689600,
"data": {
"reference": "MDA-XXXXXXXXXX",
"module": "A",
"amount": 2500,
"fee": 5,
"method": "mpesa",
"status": "completed"
}
}Signature Verification
Every webhook includes an X-BitnovaPay-Signature header formatted as sha256=HMAC. Always verify before processing.
PHP
$payload = file_get_contents('php://input'); $sig = $_SERVER['HTTP_X_BITNOVAPAY_SIGNATURE']; $expected = 'sha256=' . hash_hmac('sha256', $payload, 'your_secret'); if (!hash_equals($expected, $sig)) { http_response_code(401); die('Unauthorized'); } $event = json_decode($payload, true);
Node.js
const sig = req.headers['x-bitnovapay-signature']; const expected = 'sha256=' + require('crypto') .createHmac('sha256', process.env.WEBHOOK_SECRET) .update(req.body, 'utf8').digest('hex'); if (!require('crypto').timingSafeEqual(Buffer.from(sig), Buffer.from(expected))) return res.status(401).send('Unauthorized');