BluePayAPI
Ask AI
BluePay
API Keys Support Dashboard

B2C payouts

Send a B2C payout and check its status.

B2C payouts

Send money to a customer’s M-Pesa number from your B2C wallet. Requires an active merchant account (KYC verified). Top up from the dashboard wallet card or via STK (B2CTOPUP- references). View sends on Payouts.

Two balances: B2C wallet = payout principal. Service tokens = platform fee per payout (debited on initiation, not refunded if M-Pesa fails). On failure, the B2C wallet amount is automatically reversed.

POSThttps://bluepay.co.ke/api/v1/b2c/payouts

Auth: same as STK — api_secret, account_id, and channel_id.

{
  "api_secret": "YOUR_API_SECRET",
  "account_id": "BP-XXXX-XXXX",
  "channel_id": "BP23356",
  "amount": 500,
  "phone": "0712345678",
  "reference": "WD-2024-001",
  "description": "Commission payout",
  "callbackUrl": "https://yourserver.com/webhooks/b2c"
}

Amount KES 10–1,000,000 per recipient. Platform fee bands are on Pricing (flat fee per band; 2% of amount from KES 250,000 upward). Responses include transaction_fee (service tokens). Terminal status goes to callbackUrl when set, otherwise the Account callback URL.

GEThttps://bluepay.co.ke/api/v1/b2c/wallet/balance

Returns b2c_wallet.balance_kes and service_wallet.balance_kes. Pass api_secret, account_id, and channel_id on the query string.

GEThttps://bluepay.co.ke/api/v1/b2c/payout_status?payout_id={uuid}

Poll payout status after POST /b2c/payouts. Pass api_secret, account_id, and channel_id with payout_id. Response data.payout includes status (PENDING, SUCCESS, FAILED, REVERSED), amounts, and M-Pesa receipt when available.

Dashboard (session): merchants top up or withdraw B2C float from the wallet card via /api/b2c_wallet_topup.php and /api/b2c_wallet_withdraw.php (browser login + CSRF — not for server integrations).

B2C error_code values

Same envelope as STK: ok, success, error, message, error_code. Balance errors include required_kes and balance_kes.

HTTPerror_codeWhen
402INSUFFICIENT_PREPAIDService tokens too low for B2C fee (transaction_fee_kes may be included)
403MERCHANT_INACTIVEMerchant account not active
403B2C_DISABLEDB2C blocked for this account (inactive or admin override)
409INSUFFICIENT_B2C_BALANCEB2C float wallet too low for payout amount
409REFERENCE_IN_USEreference already used (pending or successful payout)
422INVALID_PHONEMSISDN not normalizable to 254… (same as STK)
422B2C_VALIDATION_FAILEDInvalid amount, reference, callback URL, etc.
503B2C_UNAVAILABLESchema or M-Pesa B2C credentials missing
502B2C_GATEWAY_ERRORM-Pesa or unexpected failure after accept

402 — insufficient service tokens (B2C fee)

{
  "ok": false,
  "success": false,
  "error": "402 Insufficient service tokens",
  "message": "402 Insufficient service tokens",
  "error_code": "INSUFFICIENT_PREPAID",
  "required_kes": 25,
  "balance_kes": 10,
  "transaction_fee_kes": 25
}

409 — insufficient B2C float

{
  "ok": false,
  "success": false,
  "error": "409 Insufficient B2C wallet balance",
  "message": "409 Insufficient B2C wallet balance",
  "error_code": "INSUFFICIENT_B2C_BALANCE",
  "required_kes": 500,
  "balance_kes": 120
}

B2C webhook events

mpesa.b2c.success · mpesa.b2c.failed · mpesa.b2c_wallet_topup.received (after B2C wallet STK top-up).

{
  "event": "mpesa.b2c.success",
  "data": {
    "id": "uuid",
    "type": "B2C",
    "status": "SUCCESS",
    "amount": 500,
    "phone_number": "254712345678",
    "external_reference": "WD-2024-001",
    "mpesa_receipt": "RKL1XXXXX0",
    "transaction_fee": 25.00
  }
}