Complete API Reference
These endpoints don't require authentication.
Register a new M-Pesa client account.
curl -X POST https://payments.navipos.co.ke/api/v1/clients \
-H "Content-Type: application/json" \
-d '{
"name": "My Business",
"email": "admin@mybusiness.com",
"phone": "254712345678"
}'
Receive M-Pesa payment notifications (POST from M-Pesa servers).
// M-Pesa will POST to your webhook with payment results
POST /api/v1/webhooks/mpesa HTTP/1.1
Host: payments.navipos.co.keContent-Type: application/json
{
"Body": {
"stkCallback": {
"MerchantRequestID": "...",
"CheckoutRequestID": "...",
"ResultCode": 0,
"ResultDesc": "The service request has been processed successfully."
}
}
}
Check API health and status (GET request).
curl -X GET https://payments.navipos.co.ke/api/v1/health
Receive C2B validation requests from M-Pesa (Safaricom will POST to this URL).
// M-Pesa will POST validation data
POST /api/v1/c2b-validation HTTP/1.1
Host: payments.navipos.co.keContent-Type: application/json
{
"TransactionType": "C2B",
"TransID": "R3G3W12345",
"TransTime": "20240314000000",
"TransAmount": "100",
"BusinessShortCode": "123456",
"BillRefNumber": "ORDER-123",
"InvoiceNumber": "",
"OrgAccountBalance": "",
"ThirdPartyTransID": "",
"MSISDN": "254712345678",
"FirstName": "John",
"MiddleName": "Doe",
"LastName": ""
}
Receive C2B confirmation requests from M-Pesa (Safaricom will POST to this URL).
// M-Pesa will POST confirmation data
POST /api/v1/c2b-confirmation HTTP/1.1
Host: payments.navipos.co.keContent-Type: application/json
{
"TransactionType": "C2B",
"TransID": "R3G3W12345",
"TransTime": "20240314000000",
"TransAmount": "100",
"BusinessShortCode": "123456",
"BillRefNumber": "ORDER-123",
"InvoiceNumber": "",
"OrgAccountBalance": "",
"ThirdPartyTransID": "",
"MSISDN": "254712345678",
"FirstName": "John",
"MiddleName": "Doe",
"LastName": ""
}
These endpoints require API Key authentication via X-API-Key header or Bearer token.
Retrieve client account details.
curl -X GET https://payments.navipos.co.ke/api/v1/clients \
-H "X-API-Key: your_api_key"
Store M-Pesa Daraja credentials (encrypted in database) with environment.
curl -X POST https://payments.navipos.co.ke/api/v1/clients/CLIENT_ID/credentials \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"consumerKey": "your_daraja_consumer_key",
"consumerSecret": "your_daraja_consumer_secret",
"shortcode": "174379",
"passkey": "bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919",
"initiatorName": "testapi",
"initiatorPassword": "your_initiator_password",
"environment": "production"
}'
Initiate M-Pesa STK Push payment request.
curl -X POST https://payments.navipos.co.ke/api/v1/stk-push \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"clientId": "your_client_id",
"phoneNumber": "254712345678",
"amount": 1000,
"accountReference": "ORDER-123",
"transactionDesc": "Payment for order"
}'
Register C2B validation and confirmation URLs with Safaricom.
curl -X POST https://payments.navipos.co.ke/api/v1/c2b-register \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"shortCode": "123456",
"validationUrl": "https://yourapp.com/api/v1/c2b-validation",
"confirmationUrl": "https://yourapp.com/api/v1/c2b-confirmation"
}'
Simulate C2B payment (sandbox only).
curl -X POST https://payments.navipos.co.ke/api/v1/c2b-simulate \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"shortCode": "123456",
"phoneNumber": "254712345678",
"amount": 100,
"billRefNumber": "ORDER-123"
}'
List all transactions for your client account.
curl -X GET "https://payments.navipos.co.ke/api/v1/transactions?status=completed&limit=50" \
-H "X-API-Key: your_api_key"
Get details for a specific transaction.
curl -X GET https://payments.navipos.co.ke/api/v1/transactions/TRANSACTION_ID \
-H "X-API-Key: your_api_key"
All error responses include a standard error object:
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid phone number",
"details": {
"phone": "Must be 12 digits starting with 254"
}
}
}
All successful responses follow this format:
{
"success": true,
"data": {
// Response data here
},
"meta": {
"timestamp": 1704067200,
"version": "v1"
}
}