Transactions
Every payment, STK or C2B, is a transaction. Look one up by your reference, or list and filter them. This is the source of truth; webhooks only tell you sooner.
Look up a payment
GET/api/v1/transactions/{reference_or_transaction_uuid}
Scope transactions:read. Pass your reference, or the transaction_uuid the STK response gave you.
# Paste your API key once (it starts with mpk_):
export MYPAYMENTS_KEY="mpk_your_key_here"
curl "https://api.mypayments.co.ke/api/v1/transactions/INV-001" \
-H "Authorization: Bearer $MYPAYMENTS_KEY"json
{
"success": true,
"data": {
"uuid": "1d6aea1c-6911-455b-8300-2d347cc2a6e4",
"account_uuid": "5e2989df-905b-40e9-a056-8251c2e34a37",
"provider": "mpesa",
"direction": "collection",
"kind": "stk",
"amount": "100.00",
"reported_amount": "100.00",
"amount_mismatch": false,
"currency": "KES",
"phone": "254712345678",
"phone_sha256": "7132104d6aae9c3fac82095a42c2817952bca48e09d98d5bf4ac08218982fb90",
"reference": "INV-001",
"tracking_id": "order-8842",
"provider_receipt": "TL3BD2ZK1P",
"status": "settled",
"result_code": "0",
"result_desc": "The service request is processed successfully.",
"verified": true,
"settled_at": "2026-12-03T17:59:20.102059Z",
"created_at": "2026-12-03T17:59:11.806152Z",
"source": "provider"
}
}Why the reference and not the tracking id?
Your
reference is unique in your business, so it names exactly one payment, and it is what we use to refuse a duplicate prompt. tracking_id is free-form and may repeat (one order, several attempts), so it can match many payments: find them with the list filter below.List payments
GET/api/v1/transactions
# Paste your API key once (it starts with mpk_):
export MYPAYMENTS_KEY="mpk_your_key_here"
curl "https://api.mypayments.co.ke/api/v1/transactions?tracking_id=order-8842" \
-H "Authorization: Bearer $MYPAYMENTS_KEY"Query
| Field | Type | Required | Description |
|---|---|---|---|
| tracking_id | string | No | Exact match on the tracking_id you sent. |
| status | string | No | pending, settled, failed or success. |
| kind | string | No | stk or c2b. |
| account | string | No | An account id. |
| q | string | No | Part of a reference, or the last digits of the payer's phone. |
| page, per_page | integer | No | Newest first; pagination. |
json
{
"success": true,
"data": [
{
"uuid": "1d6aea1c-6911-455b-8300-2d347cc2a6e4",
"account_uuid": "5e2989df-905b-40e9-a056-8251c2e34a37",
"provider": "mpesa",
"direction": "collection",
"kind": "stk",
"amount": "100.00",
"reported_amount": "100.00",
"amount_mismatch": false,
"currency": "KES",
"phone": "254712345678",
"phone_sha256": "7132104d6aae9c3fac82095a42c2817952bca48e09d98d5bf4ac08218982fb90",
"reference": "INV-001",
"tracking_id": "order-8842",
"provider_receipt": "TL3BD2ZK1P",
"status": "settled",
"result_code": "0",
"result_desc": "The service request is processed successfully.",
"verified": true,
"settled_at": "2026-12-03T17:59:20.102059Z",
"created_at": "2026-12-03T17:59:11.806152Z",
"source": "provider"
}
],
"meta": {
"page": 1,
"per_page": 25,
"total": 1
}
}Statuses
| pending | An STK prompt is out. Normally settles or fails within two minutes; we keep asking Safaricom for up to 24 hours if its callback never comes. |
| settled | Paid, and confirmed with the provider (verified: true). Fulfil the order. |
| failed | Not paid: cancelled, timed out, insufficient funds, refused. result_code and result_desc say why. |
| success | A forwarded C2B payment your server relayed, not yet confirmed with Safaricom. Don't fulfil yet; it becomes settled once confirmed. |
The transaction object
Fields
| Field | Type | Required | Description |
|---|---|---|---|
| uuid | string | No | The transaction id. |
| account_uuid | string | No | The account it was paid into. |
| provider | string | No | mpesa or kopokopo. |
| direction | string | No | collection. |
| kind | string | No | stk or c2b. |
| amount | string | No | What you asked for: the STK amount, or the expected_amount of the account number paid. For a C2B payment without one, what was paid. |
| reported_amount | string | No | What the provider says was paid. |
| amount_mismatch | boolean | No | amount and reported_amount differ. We flag it and correct neither; decide what to do. |
| currency | string | No | KES. |
| phone | string | No | The payer as 2547XXXXXXXX (no +), when known. |
| masked_phone | string | No | The payer as Safaricom masked it (2547•••678), when that is all we got. |
| phone_sha256 | string | No | SHA-256 hex of the payer's number as 2547XXXXXXXX (no +). Safaricom often sends only this for C2B payers; hash a number you know the same way to match it. |
| payer_names | string | No | Names Safaricom sent for a C2B payer. |
| reference | string | No | Your STK reference, or for C2B the account number the customer typed (BillRef). Falls back to the receipt when they typed none. |
| tracking_id | string | No | Your tracking id, STK only. |
| provider_receipt | string | No | The M-PESA receipt (TL3BD2ZK1P). Unique: one payment, one receipt. |
| status | string | No | See statuses. |
| result_code, result_desc | string | No | The provider's outcome, STK. |
| verified | boolean | No | Confirmed with the provider server to server. |
| settled_at | string | No | When it settled. |
| created_at | string | No | When we recorded it. |
| source | string | No | provider (from Safaricom/KopoKopo) or forward (relayed by your server). |
| account_number, external_ref | string | No | C2B to an issued account number: the number and your external_ref for it. |
Fields without a value are left out of the JSON. List by account: ?account=5e2989df-905b-40e9-a056-8251c2e34a37.