Skip to main content
POST
/
v1
/
mpesa
/
b2b
JavaScript
import FingoPay from '@fingoafrica/fingo-pay';

const client = new FingoPay({
  apiKey: process.env['FINGO_PAY_API_KEY'], // This is the default and can be omitted
});

const acceptedResponse = await client.mpesa.createB2bTransfer({
  accountNumber: '1234567',
  accountNumberType: 'paybill',
  amount: 2500000,
  merchantTransactionId: 'b2b_4521',
});

console.log(acceptedResponse.data);
{
  "status": "success",
  "message": "Transaction initiated successfully",
  "data": {
    "merchantTransactionId": "mtx_123",
    "transactionId": "txn_01j7b6f9p5y9h"
  }
}

Authorizations

Authorization
string
header
required

Use your API key as a Bearer token. Example: Authorization: Bearer sk_live_...

Headers

Idempotency-Key
string<uuid>

Unique key to safely retry POST without duplicates. Required in live environment.

Body

application/json
merchantTransactionId
string
required

Merchant-side reference used for reconciliation. Accepts 1-64 characters (letters, numbers, dot, underscore, or hyphen).

Required string length: 1 - 64
Example:

"b2b_4521"

amount
integer
required

Amount in smallest currency unit (cents). Range 1-5,000,000 (KES 0.01-50,000.00).

Required range: 1 <= x <= 5000000
Example:

2500000

accountNumber
string
required

Destination till or paybill number.

Example:

"1234567"

accountNumberType
enum<string>
required

Destination M-Pesa account type.

Available options:
till,
paybill
Example:

"paybill"

beneficiary
string

Account reference required when accountNumberType is paybill. Can be blank for till transfers.

Example:

"INV-12345"

narration
string

Optional narration displayed to the beneficiary. Maximum 140 characters.

Maximum string length: 140
Example:

"Restock float"

webhookUrl
string<uri>

Override webhook destination for this transfer.

Example:

"https://merchant.example/webhooks/fingo"

metadata
object

Custom metadata key-value pairs. Up to 20 entries. Keys 1-64 characters (letters, numbers, dot, underscore, or hyphen). Values up to 500 characters.

debitAccountNumber
string

Optional partner account number to debit instead of the default payout account.

Example:

"ACC-88921"

Response

Accepted — final result will be delivered via webhook.

status
string
required
Example:

"success"

message
string
required
Example:

"Transaction initiated successfully"

data
object
required