Account numbers

An account number is what a customer types after your paybill number. Issue one per customer, invoice or device and every C2B payment arrives already attributed.

Scope numbers:manage. Numbers work on paybills (a till has no account number field). On your own paybill they are optional; on a shared Mypayments paybill they are the only way a payment reaches you.

Issue a number

POST/api/v1/accounts/{account_id}/numbers

Your own paybill: choose the number

# Paste your API key once (it starts with mpk_):
export MYPAYMENTS_KEY="mpk_your_key_here"

curl -X POST https://api.mypayments.co.ke/api/v1/accounts/5e2989df-905b-40e9-a056-8251c2e34a37/numbers \
  -H "Authorization: Bearer $MYPAYMENTS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "number": "HS-0042",
    "label": "Hotspot router 42",
    "external_ref": "router-42"
  }'
json
{
  "success": true,
  "data": {
    "uuid": "6c988a31-f497-40cd-8ef6-943ca6e75501",
    "account_uuid": "5e2989df-905b-40e9-a056-8251c2e34a37",
    "number": "HS-0042",
    "label": "Hotspot router 42",
    "external_ref": "router-42",
    "single_use": false,
    "status": "active",
    "created_at": "2026-12-03T19:29:11.083957Z",
    "paybill": "4123456"
  }
}

A shared paybill: we generate it

Leave number out. We generate eight characters that are hard to mistype (no 0/O, 1/I, 5/S):

# Paste your API key once (it starts with mpk_):
export MYPAYMENTS_KEY="mpk_your_key_here"

curl -X POST https://api.mypayments.co.ke/api/v1/accounts/4b3d2437-6fc3-4b9b-b3b4-2365b2404f6d/numbers \
  -H "Authorization: Bearer $MYPAYMENTS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "Invoice 1001",
    "external_ref": "inv-1001",
    "expected_amount": 1500,
    "single_use": true,
    "expires_at": "2026-12-31T23:59:59Z"
  }'
json
{
  "success": true,
  "data": {
    "uuid": "b22debdc-dbfb-4e8e-aa10-f39cb77906b8",
    "account_uuid": "4b3d2437-6fc3-4b9b-b3b4-2365b2404f6d",
    "number": "HV3R9C4E",
    "label": "Invoice 1001",
    "external_ref": "inv-1001",
    "expected_amount": "1500.00",
    "single_use": true,
    "status": "active",
    "expires_at": "2026-12-31T23:59:59Z",
    "created_at": "2026-12-03T19:29:11.099587Z",
    "paybill": "4000001"
  }
}

Tell the customer: Paybill 4000001, account HV3R9C4E, KES 1,500.

Body

FieldTypeRequiredDescription
numberstringNoOwn paybills only: 3–20 characters, A–Z, 0–9 and -. Uppercased. Omit to have one generated. On a shared paybill, sending it is a 400.
labelstringNoYour description, for the dashboard.
external_refstringNoYour id for whatever the number stands for (customer, invoice, device). Comes back on every payment to it.
expected_amountnumber | stringNoThe amount it should be paid with. Becomes the payment's amount; a different payment is flagged amount_mismatch, and declined when Safaricom runs validation.
single_usebooleanNoTakes one payment, then becomes used.
expires_atstringNoRFC 3339. Not accepted after this.

A number is unique on its paybill while it is open; a closed number can be issued again.

List numbers

GET/api/v1/accounts/{account_id}/numbers
# Paste your API key once (it starts with mpk_):
export MYPAYMENTS_KEY="mpk_your_key_here"

curl "https://api.mypayments.co.ke/api/v1/accounts/5e2989df-905b-40e9-a056-8251c2e34a37/numbers?status=active&q=HS-" \
  -H "Authorization: Bearer $MYPAYMENTS_KEY"

Query

FieldTypeRequiredDescription
statusstringNoactive, used or closed.
qstringNoPart of the number, label or external_ref.
page, per_pageintegerNoPagination.

Get a number

GET/api/v1/numbers/{number_id}
# Paste your API key once (it starts with mpk_):
export MYPAYMENTS_KEY="mpk_your_key_here"

curl "https://api.mypayments.co.ke/api/v1/numbers/6c988a31-f497-40cd-8ef6-943ca6e75501" \
  -H "Authorization: Bearer $MYPAYMENTS_KEY"

Close a number

DELETE/api/v1/numbers/{number_id}
# Paste your API key once (it starts with mpk_):
export MYPAYMENTS_KEY="mpk_your_key_here"

curl -X DELETE "https://api.mypayments.co.ke/api/v1/numbers/6c988a31-f497-40cd-8ef6-943ca6e75501" \
  -H "Authorization: Bearer $MYPAYMENTS_KEY"

A closed number takes no more payments (declined when Safaricom validates). Its past payments are kept.

The number object

Fields

FieldTypeRequiredDescription
uuidstringNoThe number's id.
account_uuidstringNoThe paybill account it belongs to.
paybillstringNoThe paybill number to show the customer.
numberstringNoThe account number to show the customer.
label, external_refstringNoYours.
expected_amountstringNoIf set.
single_usebooleanNoTakes one payment.
statusstringNoactive, used (a single-use number that was paid) or closed.
expires_at, used_at, created_atstringNoTimes.

Payments to a number

Payments to a number arrive as C2B webhooks with account_number and external_ref. List them with GET /transactions?q=HS-0042, or route them to their own endpoint with a reference prefix filter (HS-).