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).

Personal API v1

Bearer token: pk_live_-

https://pay.bitnova.co.ke/api/v1/
Business API v2

Bearer token: bsk_live_-

https://pay.bitnova.co.ke/api/v2/
All requests must be made over HTTPS. HTTP is rejected.

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"}'
Never expose your API key in client-side JavaScript or public repositories.

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 StatusMeaning
400Bad request - missing or invalid parameter
401Unauthorized - invalid or missing API key
403Forbidden - insufficient permissions
404Resource not found
429Rate limit exceeded
500Server error - try again

Channels - Direct Pay

Channels are your own paybill, till, or bank shortcodes. STK pushes go directly to these destinations.

GET /api/v1/channels List all your channels
{ "data": [{ "id": 1, "label": "Equity Bank", "type": "paybill", "shortcode": "247247", "is_active": true }], "count": 1 }
POST /api/v1/channels Create a channel
ParameterTypeDescription
labelstringrequirede.g. "Equity Bank"
typestringrequiredpaybill | till | bank
shortcodestringrequiredM-Pesa paybill or till number
account_referencestringoptionalPrefix on M-Pesa prompt

STK Push - Direct Pay

Money goes directly to your paybill. Bitnova never holds transaction funds.
POST /api/v1/stk-push Non-custodial STK to your channel
ParameterTypeDescription
channel_idintegerrequiredID from GET /channels — this is the bank/till shortcode (PartyB)
amountfloatrequiredAmount in KES (min 1)
phonestringrequired07XXXXXXXX or 2547XXXXXXXX — customer's M-Pesa (PartyA)
descriptionstringoptionalMax 20 chars (shown on M-Pesa prompt)
payer_namestringoptionalCustomer name for receipt
payer_emailstringoptionalSend 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.

POST /api/v1/charges Custodial payment - all methods
ParameterTypeDescription
methodstringrequiredmpesa | card | paypal | crypto
amountfloatrequiredAmount in KES
phonestringif mpesa07XXXXXXXX or 2547XXXXXXXX
descriptionstringoptionalOrder description
payer_emailstringoptionalReceipt 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

GET /api/v1/charges/{reference} Poll for completion
{ "reference":"BNP-XXXXXXXXXX","status":"completed","amount":1500,"fee":15,"net_amount":1485,"method":"mpesa" }
Poll every 4 seconds for M-Pesa, 3 seconds for cards. Max 5 minutes then show timeout. Or use webhooks for server-to-server notification.

Transactions

GET /api/v1/transactions List with filters
Query paramTypeDefaultDescription
statusstringallpending | completed | failed
modulestringallA (Direct Pay) | B (Smart Gateway)
methodstringallmpesa | card | crypto
pageinteger1Pagination
per_pageinteger15Max 100

Wallet Balance

GET /api/v1/balance Current 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.

Moves money out of your wallet. Call it from your server with your secret key (sk_live_…), never from a browser or mobile app.
  • amount is 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.
  • phone accepts 07XXXXXXXX, 01XXXXXXXX or 2547XXXXXXXX.
  • Who pays the fee (fee_payer): sender (default) debits your wallet amount + fee and the recipient gets the full amount. recipient debits your wallet exactly amount and the recipient receives amount − fee (fee rounded up to a whole shilling), so you never absorb the fee. Use recipient when your own customers are withdrawing. The recipient must still receive at least KES 10.
  • Idempotency: send an Idempotency-Key header (or idempotency_key in the body; 1–64 chars of letters, digits, _ . : -) on every payout request. Retrying with the same key returns the original disbursement with "idempotent_replay": true instead 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 as disbursement.sent or disbursement.failed, and can be polled with the GET endpoints below.
POST /api/v1/disbursements Send money to one M-Pesa number
ParameterTypeDescription
recipient_namestringrequiredRecipient's name (for your records)
phonestringrequired07XXXXXXXX or 2547XXXXXXXX
amountintegerrequiredWhole KES, min 10
methodstringoptionalOnly mpesa (default)
fee_payerstringoptionalsender (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"
}
POST /api/v1/disbursements/bulk Pay up to 100 recipients at once

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.

ParameterTypeDescription
titlestringoptionalLabel for the batch, e.g. "July Payroll"
recipientsarrayrequired1–100 objects: name, phone, amount
methodstringoptionalOnly 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}
  ]
}
If M-Pesa rejects some payouts, those items return "status":"failed" with an error and only those recipients are refunded. If every payout is rejected you get HTTP 502 and a full refund.
GET /api/v1/disbursements/quote Show the fee before confirming

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" }
GET /api/v1/disbursements/{reference} Status of one payout
{
  "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"
}
StatusMeaning
processingAccepted, awaiting M-Pesa's result
completedDelivered; mpesa_receipt is set
failedNot delivered and refunded; failure_reason is set
pending_reviewM-Pesa timed out. The amount stays held until we confirm the outcome with Safaricom, then it is settled or refunded. Do not re-send.
GET /api/v1/disbursements/batch/{batch_id} Batch status with all items

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

CodeMeaning
400 / 422Invalid recipient, phone or amount (bulk errors name the recipient index)
402Insufficient available balance (balance minus locked funds, including fees)
403Account inactive, or identity verification (KYC) not completed
409A request with the same idempotency key is still being processed; retry shortly
502M-Pesa rejected the payout; balance restored
503Payouts 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.

POST /api/v1/webhooks Register a webhook endpoint
ParameterTypeDescription
urlstringrequiredHTTPS URL to receive events
eventsarrayrequiredpayment.success | payment.failed | withdrawal.success | withdrawal.failed | disbursement.sent | disbursement.failed
sourcestringoptionalapi | woocommerce | shopify

Response

{ "id": 1, "secret": "whsec_xxxxxxxxxxxxxxxx", "url": "https://yoursite.com/webhooks", "events": ["payment.success","payment.failed"] }
Store the secret securely — it is only returned once. Use it to verify incoming webhook signatures.
GET /api/v1/webhooks List registered webhooks
{ "data": [{ "id": 1, "url": "https://...", "events": ["payment.success"], "is_active": true }], "count": 1 }
DELETE /api/v1/webhooks/{id} Remove a webhook
{ "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.

payment.success
Direct Pay (Module A) or Smart Gateway (Module B) payment completed
payment.failed
STK cancelled, card declined, or expired
payment.refunded
Card or PayPal refund processed
disbursement.sent
M-Pesa payout delivered to the recipient
disbursement.failed
Payout failed and was refunded to your wallet
withdrawal.completed
Admin marked withdrawal as sent
invoice.paid
Invoice fully paid

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');