Lipia lets your business collect mobile money payments by sending a USSD prompt to your customer's phone. You create a payment, the customer approves it on their phone, and you read the final result from the API.
Base URL: https://lipia.co.tz/api/v1 · All requests and responses are JSON over HTTPS · Amounts are whole Tanzanian shillings (TZS), no decimals.
Send your API key as a Bearer token. Keep it on your server only — never put it in a mobile app, web page or public repository. If it leaks, regenerate it in your dashboard; the old key stops working immediately.
Authorization: Bearer lp_live_xxxxxxxxxxxxxxxxxxxxxxxx
Lipia charges an API usage fee of 3.00% of the transaction amount on every successful payment. Who bears the fee depends on your account setting (fee_mode on every payment):
deduct (default): the customer pays amount and the fee is deducted from it.on_top: the customer pays amount + fee and you receive the full amount. The response amount is then what the customer is charged, and net_amount is what you asked to receive.fee = round(amount × 0.03) deduct: customer pays amount, net_amount = amount − fee e.g. 10,000 → fee 300 → net 9,700on_top: customer pays amount + fee, net_amount = amount e.g. 10,000 → fee 300 → customer pays 10,300, you receive 10,000
Payments that fail, are cancelled or expire are not charged. Every payment object shows its fee and net_amount, and your dashboard totals them. Your rate is shown in your dashboard; if we agree a different rate with you, it applies to new payments.
Every POST /payments must include an Idempotency-Key header (max 100 characters) that is unique per checkout attempt, for example your order ID plus an attempt counter. If a request times out, retry with the same key: you will get the original payment back and the customer is never charged twice. Reusing a key with different details returns 409 IDEMPOTENCY_KEY_REUSED.
POST /payments
| Field | Type | Description | |
|---|---|---|---|
amount | integer | required | TZS 100 to 50,000,000. In on_top mode this is the amount you receive; the customer is charged more. |
phone | string | required | Customer's mobile money number, 255XXXXXXXXX or 0XXXXXXXXX (07… and 06… numbers are accepted). |
customer_name | string | required | Max 120 characters. |
customer_email | string | required | Valid email address. |
reference | string | optional | Your own order reference (max 64, unique per account). You can retrieve the payment with it. |
description | string | optional | Max 255 characters. |
curl -X POST https://lipia.co.tz/api/v1/payments \
-H "Authorization: Bearer $LIPIA_API_KEY" \
-H "Idempotency-Key: order-1042-attempt-1" \
-H "Content-Type: application/json" \
-d '{"amount":10000,"phone":"0712345678","customer_name":"Asha Juma",
"customer_email":"asha@example.com","reference":"order-1042"}'
Response 202 Accepted. This means the request was accepted, not that the customer has paid — confirm the final status before delivering goods or services.
{
"data": {
"reference": "LP3F9A1C2B7D4E5F60",
"external_reference": "order-1042",
"status": "pending",
"amount": 10000,
"fee": 300,
"net_amount": 9700,
"fee_mode": "deduct",
"currency": "TZS",
"phone": "25571****678",
"customer_name": "Asha Juma",
"description": null,
"failure_code": null,
"created_at": "2026-11-23T10:15:00+03:00",
"updated_at": "2026-11-23T10:15:00+03:00"
}
}
A repeated request with the same idempotency key returns 200 with the same payment.
GET /payments/{reference} — accepts the Lipia reference or your own reference.
curl https://lipia.co.tz/api/v1/payments/LP3F9A1C2B7D4E5F60 -H "Authorization: Bearer $LIPIA_API_KEY"
Poll until status is final (success, failed, cancelled or expired). Poll every 5–10 seconds at most; customers normally respond within a minute or two.
<?php // PHP
$ch = curl_init('https://lipia.co.tz/api/v1/payments');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('LIPIA_API_KEY'),
'Idempotency-Key: order-1042-attempt-1', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['amount' => 10000, 'phone' => '0712345678',
'customer_name' => 'Asha Juma', 'customer_email' => 'asha@example.com', 'reference' => 'order-1042']),
]);
$payment = json_decode(curl_exec($ch), true)['data'];
// Node.js 18+
const res = await fetch('https://lipia.co.tz/api/v1/payments', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.LIPIA_API_KEY}`, 'Idempotency-Key': 'order-1042-attempt-1', 'Content-Type': 'application/json' },
body: JSON.stringify({ amount: 10000, phone: '0712345678', customer_name: 'Asha Juma', customer_email: 'asha@example.com', reference: 'order-1042' }),
});
const { data, error } = await res.json();
GET /payments
Query parameters: status (pending, processing, success, failed, cancelled, expired), from and to (YYYY-MM-DD), limit (1–100, default 25), page. Newest first.
{ "data": [ { "reference": "LP…", "status": "success", … } ], "meta": { "page": 1, "per_page": 25, "total": 134 } }
A payment link is a hosted page you can share by SMS, WhatsApp, email or print. Your customer opens it, enters their name, mobile money number and optionally an email, then approves the payment on their phone. No integration work is needed: create links in the dashboard (Payment links) or with the API.
link field, and fires the same payment.updated webhook. Your dashboard shows each link, its status, payments, amounts collected and SMS sent.POST /links GET /links GET /links/{id}
curl -X POST https://lipia.co.tz/api/v1/links -H "Authorization: Bearer $LIPIA_API_KEY" -H "Content-Type: application/json" \
-d '{ "title": "School fees – Term 1", "amount": 150000, "reusable": false, "expires_at": "2026-12-31T23:59:00+03:00" }'
201 { "data": { "id": "k3Jx9aQ2mZpL", "url": "https://lipia.co.tz/pay/k3Jx9aQ2mZpL", "status": "active", "amount_type": "fixed", "amount": 150000, … } }
Omit amount for an open link (optionally send min_amount / max_amount). status is active, disabled, expired or completed (single-use link that was paid). GET /links/{id} also lists the link's payments.
Bill a customer with a 12-digit control number. The customer gets an SMS (and email, if given) with a payment link; on the page they choose an amount allowed by the bill type and approve a mobile money prompt. Create the service first in Billing → Services.
bill_type: exact (pay exactly amount), full (amount or more, one payment) or partial (instalments from min_payment, at least TZS 1,000, up to the balance).reference (optional, your own id, max 80 characters) makes creation idempotent: repeating the request returns the same bill (200); reusing it for a different bill is 409.receipt_url; customers with an email also receive it by email.POST /bills GET /bills (status, q, page, per_page) GET /bills/{ref} POST /bills/{ref}/cancel
curl -X POST https://lipia.co.tz/api/v1/bills -H "Authorization: Bearer $LIPIA_API_KEY" -H "Content-Type: application/json" \
-d '{ "customer_name": "Amina Mushi", "customer_phone": "0655123456", "customer_email": "amina@example.com", "service": "Tuition",
"amount": 500000, "bill_type": "partial", "min_payment": 50000, "expiry": "2026-12-31", "reference": "INV-2026-0042", "send_sms": true }'
201 { "data": { "ref": "839581210541", "payment_link": "https://lipia.co.tz/bill/839581210541", "bill_type": "partial", "amount": 500000, "paid_amount": 0, "balance": 500000,
"status": "open", "notices": { "sms_queued": 1, "email_queued": 1, "problem": null }, … } }
status is open, partial, paid, expired or cancelled. Omitted amount, bill_type and min_payment come from the service; omitted expiry uses your default validity. send_sms and send_email default to true.
Lipia can text a payment link to your customers, one at a time or in bulk. The service is available on request: use Request SMS service on the Payment links page; our team approves it.
number, name per request. The message can use {name}, {business} and {link}; each SMS is at most 160 characters after replacement, so one message is one charge.Send free-text SMS to one or many numbers from your servers. Available to every account with the SMS service enabled, and it is the whole product for bulk SMS only accounts (choose that option when you sign up: shorter KYC, and no payments, payouts or links). Messages use your SMS credits (see SMS bundles above); bulk SMS accounts pay for credits by mobile money. Same API key and Authorization header as the rest of the API. Bulk SMS accounts get 403 ACCOUNT_TYPE_NOT_SUPPORTED on the payment endpoints.
POST /sms Headers: Authorization, Idempotency-Key (required)
| Field | Type | |
|---|---|---|
message | string | The text. {name} and {business} are replaced per recipient. At most 160 characters after replacement (one message = one credit). |
recipients | array | 1–1,000 items, each a phone number ("0712345678" or "255712345678") or {"phone": "...", "name": "Asha"}. Duplicate numbers are sent once. |
curl -X POST https://lipia.co.tz/api/v1/sms \
-H "Authorization: Bearer $LIPIA_KEY" -H "Idempotency-Key: campaign-2026-11-23-a" -H "Content-Type: application/json" \
-d '{"message":"Hi {name}, your order is ready.","recipients":[{"phone":"0712345678","name":"Asha"},"0765123456"]}'
202 { "data": { "batch": "a1f3...", "replayed": false, "count": 2, "credits_used": 2, "charged": 0, "credits_remaining": 998,
"messages": [ { "id": "sms_101", "to": "255712345678", "name": "Asha", "status": "queued", "charged": 0, "paid_with": "credit", "created_at": "..." }, ... ] } }
Sending the same Idempotency-Key again returns the original messages (200, replayed: true) and sends nothing twice. Use a new key for every new request.
402 INSUFFICIENT_CREDITS and nothing is sent; payment accounts have the remainder charged to their collections (or 402 INSUFFICIENT_BALANCE).GET /sms?batch=… for progress.queued → sent (accepted by the carrier network) → delivered or undeliverable when the handset reports back; or failed. Failed messages are not charged and return their credit.GET /sms/{id} — one message, including the text. GET /sms?batch=&status=&page=&limit= — your messages, newest first (status: queued, sent, delivered, failed).
GET /sms/balance
{ "data": { "credits": 998, "currency": "TZS", "price_beyond_credits": 30, "max_message_length": 160, "max_recipients_per_request": 1000,
"bundle_prices": [ { "min_qty": 1, "price": 30 }, { "min_qty": 500, "price": 27 } ] } }
A QR payment fixes the amount and the payer's mobile money number in advance. When the payer scans the QR with their phone camera, a payment prompt is sent to that number: they approve it with their PIN. Create QR codes in the dashboard (QR pay), where you can show, print or download them, or with the API and draw the QR yourself from the returned url.
payment.updated webhook.POST /qr Headers: Authorization, Idempotency-Key (required)
curl -X POST https://lipia.co.tz/api/v1/qr -H "Authorization: Bearer $LIPIA_KEY" -H "Idempotency-Key: order-1042" -H "Content-Type: application/json" \
-d '{"amount":5000,"phone":"0712345678","name":"Asha","description":"Order 1042","expires_in_minutes":15}'
201 { "data": { "id": "qr_17", "amount": 5000, "payer_phone": "25571****678", "status": "active", "expires_at": "2026-11-23T11:20:00+00:00",
"attempts": 0, "payment_reference": null, "url": "https://lipia.co.tz/q/3f9a...c1" } }
Encode url in a QR code. GET /qr/{id} returns the status (active, processing while a prompt is open, paid, expired, cancelled, failed) and the payment_reference once a prompt was sent; GET /qr lists your QR codes; POST /qr/{id}/cancel cancels one that has no prompt in progress. The url is returned only while the QR is still usable.
GET /balance
Your collections (after our fee) become available for payout after midnight (Dar es Salaam time) on the day they succeed. Money held by payouts that are pending or in progress is not available.
{ "data": { "currency": "TZS", "available": 480000, "pending_settlement": 120000, "payouts_in_progress": 50000, "payouts_enabled": true,
"limits": { "min_payout": 10000, "approval_threshold": 100000, "daily_limit": 2000000 } } }
GET /payouts/quote?amount=100000
Shows the fee before you commit. Your account is set to one of two fee modes (fee_mode): deduct — the fee comes out of the amount, you are debited amount and the recipient receives recipient_receives; or recipient_full — the recipient receives exactly amount and you are debited total_debit (amount + fee). The fee is a transfer fee that depends on the amount, plus a Lipia service fee.
{ "data": { "amount": 100000, "fee": 5500, "total_debit": 100000, "recipient_receives": 94500, "fee_mode": "deduct", "currency": "TZS", "requires_approval": true } }
POST /payouts Headers: Authorization, Idempotency-Key (required)
| Field | Type | |
|---|---|---|
amount | integer | Whole TZS. In deduct mode this is what you are debited (fees come out of it); in recipient_full mode it is what the recipient receives (fees are added to your debit). |
recipient_id | string | settlement (your KYC settlement wallet) or the id of an approved recipient. Use this, or phone + recipient_name. |
phone, recipient_name | string | Any other number, only if your account allows it and the amount is within your open-number limit. |
reference | string | Optional, your own unique reference (max 64). |
note | string | Optional (max 200). |
curl -X POST https://lipia.co.tz/api/v1/payouts \
-H "Authorization: Bearer lp_live_…" -H "Idempotency-Key: payout-2026-11-23-001" -H "Content-Type: application/json" \
-d '{ "amount": 100000, "recipient_id": "settlement", "reference": "salary-nov" }'
202 { "data": { "reference": "LPO…", "status": "pending_approval", "amount": 100000, "fee": 5500, "net_amount": 94500, "requires_approval": true, … } }
The call returns 202 and the payout continues in the background. Use webhooks (payout.updated) or retrieve it to follow the result. Repeating a request with the same Idempotency-Key returns the original payout and never pays twice.
GET /payouts/{reference} (your reference also works) GET /payouts?status=&page=&limit=
GET /recipients POST /recipients with { "phone": "0712345678", "name": "Name on the account" }
New recipients start as pending and can be used once our team marks them approved. Your settlement wallet is listed as settlement and is always usable.
amount is what was debited from your balance, fee the fee, and net_amount what the recipient receives.pending_approval). You can cancel them in the dashboard until they are approved.GET /balance.payout.updated, signed exactly like payment events, with the payout object as data.| Status | |
|---|---|
pending_approval | Waiting for review. Funds are held. |
processing | Approved and being sent. |
paid | Delivered to the recipient. |
failed | Not delivered. Funds returned to your balance. See failure_code. |
rejected / cancelled | Declined by our team / cancelled by you. Funds returned. |
reversed | Was paid, then returned. Funds returned to your balance. |
Payout error codes: PAYOUTS_NOT_ENABLED (403), INSUFFICIENT_BALANCE (402), DAILY_LIMIT_EXCEEDED (403), RECIPIENT_NOT_APPROVED (403), RECIPIENT_NOT_FOUND (404), AMOUNT_ABOVE_OPEN_DESTINATION_LIMIT (403), INVALID_RECIPIENT / INVALID_AMOUNT (400), PAYOUT_NOT_FOUND (404).
Instead of polling, give us an HTTPS endpoint in your dashboard (Webhooks) and we will call it when a payment reaches a final status (success, failed, cancelled or expired). We sign every request so you can be sure it came from Lipia.
POST https://shop.example.com/lipia/webhook
Content-Type: application/json
X-Lipia-Event: payment.updated
X-Lipia-Event-Id: evt_9f3c2a71b0d44e5a8c21
X-Lipia-Delivery: 1042
X-Lipia-Signature: t=1763886900,v1=5b1c…e9
{
"id": "evt_9f3c2a71b0d44e5a8c21",
"event": "payment.updated",
"created_at": "2026-11-23T10:16:40+03:00",
"data": { "reference": "LP3F9A1C2B7D4E5F60", "external_reference": "order-1042", "status": "success",
"amount": 10000, "fee": 300, "net_amount": 9700, "currency": "TZS", … }
}
The signature is the hex HMAC-SHA256 of "{t}.{raw request body}" using your signing secret (shown once when you set your endpoint; you can regenerate it). Use the raw body, compare in constant time, and reject requests whose timestamp t is more than 5 minutes old.
<?php // PHP
$raw = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_X_LIPIA_SIGNATURE'] ?? ''), $sig); // t, v1
$ok = isset($sig['t'], $sig['v1']) && abs(time() - (int) $sig['t']) <= 300
&& hash_equals(hash_hmac('sha256', $sig['t'] . '.' . $raw, getenv('LIPIA_WEBHOOK_SECRET')), $sig['v1']);
if (!$ok) { http_response_code(401); exit; }
$event = json_decode($raw, true);
http_response_code(200);
// Node.js (Express: use express.raw({type: 'application/json'}) so you receive the raw body)
const crypto = require('crypto');
function verify(rawBody, header, secret) {
const p = Object.fromEntries(header.split(',').map(kv => kv.split('=')));
if (!p.t || !p.v1 || Math.abs(Date.now() / 1000 - Number(p.t)) > 300) return false;
const calc = crypto.createHmac('sha256', secret).update(`${p.t}.${rawBody}`).digest('hex');
return calc.length === p.v1.length && crypto.timingSafeEqual(Buffer.from(calc), Buffer.from(p.v1));
}
2xx status within 10 seconds. Anything else counts as a failure.id, and use data.status and updated_at to decide what is newest.GET /payments/{reference}.webhook.test event and show you the request, your server's response, the response time and fixes for common problems. Send test event does the same for a saved endpoint and logs it. Test events carry a sample payment with "test": true and a reference starting LPTEST; they never create a real payment.| Status | Final? | Meaning |
|---|---|---|
pending | No | Customer has been prompted and must approve on their phone. |
processing | No | We are confirming the outcome. Keep polling; do not create another payment for the same order. |
success | Yes | Paid. Fee is charged. |
failed | Yes | The payment did not complete. See failure_code. |
cancelled | Yes | The customer cancelled the prompt. |
expired | Yes | The customer did not respond in time. |
Errors use standard HTTP status codes and this body:
{ "error": { "code": "INVALID_PHONE", "message": "phone must be a valid Tanzanian mobile number, e.g. 255712345678 or 0712345678." } }
| HTTP | Code | Meaning |
|---|---|---|
| 400 | INVALID_REQUEST, INVALID_AMOUNT, INVALID_PHONE, INVALID_CUSTOMER, INVALID_REFERENCE, IDEMPOTENCY_KEY_REQUIRED | The request is malformed. Fix it before retrying. |
| 401 | UNAUTHORIZED, INVALID_API_KEY | Key missing, wrong or revoked. |
| 403 | ACCOUNT_NOT_ENABLED | KYC not approved, or API access suspended. |
| 404 | PAYMENT_NOT_FOUND, NOT_FOUND | Unknown payment or endpoint. |
| 400 | INVALID_IDEMPOTENCY_KEY | Idempotency-Key may only contain letters, digits and . _ : -. |
| 409 | IDEMPOTENCY_KEY_REUSED, DUPLICATE_REFERENCE | Conflicts with an earlier request. |
| 429 | TOO_MANY_PENDING_REQUESTS | This phone has several unpaid requests. Wait retry_after_seconds. |
| 401 | API_KEY_EXPIRED | The key passed its expiry date. Generate a new one. |
| 403 | IP_NOT_ALLOWED, KEY_READ_ONLY, SCOPE_DENIED | The key is restricted to other IP addresses, is read-only, or is not allowed to use that area (collections, payouts, sms). |
| 422 | MESSAGE_REJECTED | An SMS looks like a scam message (for example asks for a PIN). Contact support if it is legitimate. |
| 429 | MERCHANT_PROMPT_LIMIT | Your account triggered too many payment prompts this hour. |
| 413 | PAYLOAD_TOO_LARGE | Request body over 256 KB. |
| 429 | PHONE_RATE_LIMITED | That phone received too many payment requests this hour (any merchant). Wait retry_after_seconds. |
| 429 | RATE_LIMITED | Too many requests (or too many failed authentications from your IP). Honour the Retry-After header. Every API response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset; default limits are 120 requests/min and 30 writes (POST)/min per account. |
| 502 | PAYMENT_NOT_STARTED | The payment was not started; safe to retry with a new Idempotency-Key. |
| 502 / 503 | PAYMENT_FAILED, SERVICE_UNAVAILABLE | Temporary problem. Retry later. |
If a request times out or you get a network error, do not create a new payment with a new key: retry with the same key, or retrieve the payment by your reference.
status is success.failed, cancelled and expired with a clear message and a way to try again.Questions? support@lipia.co.tz