TaifaPayTz API
Connect your app or website and collect mobile money with a USSD push to your customer's phone.
Download the full API kit
ZIP with the guide plus ready-to-run Node.js, PHP, Python and cURL examples — just add your key.
1. Get your API key
Sign in, open API keys in your dashboard and press New key. Copy the secret (tp_live_…) — it is shown once. Keep it on your server only, never in browser or mobile app code.
Open a merchant account2. Authentication
Send your key on every request in the x-api-key header (Authorization: Bearer also works). Base URL:
https://YOUR-TaifaPayTz-DOMAIN/api/public/v13. Endpoints
POST/payments
Creates a payment and sends a USSD push. The customer enters their PIN on their phone; the status starts as PENDING.
| amount | integer | Amount in TZS (within the gateway's min/max) |
| phone | string | Customer's Tanzanian mobile number, e.g. 0755123456 or 255755123456 |
| customer_name | string | Customer's name |
| external_id | string? | Your own order ID — must be unique; protects against double charges |
curl -X POST "https://YOUR-TaifaPayTz-DOMAIN/api/public/v1/payments" \
-H "x-api-key: tp_live_YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 50000, "phone": "0755123456", "customer_name": "Asha Juma", "external_id": "order-1001"}'201 Created
{
"success": true,
"message": "USSD push sent. Customer must enter PIN on their phone.",
"data": {
"reference": "FP-7K2Q9ZD4XA",
"external_id": "order-1001",
"amount": 50000, "currency": "TZS",
"fee": 5000, "net_amount": 45000,
"status": "PENDING",
"phone": "255755123456",
"channel": null,
"created_at": "2026-11-25T15:40:00Z", "updated_at": "2026-11-25T15:40:01Z"
}
}GET/payments/{reference}
Returns the latest status, confirmed live with the mobile network. Poll every 5 seconds for up to 2 minutes until the status is final.
curl "https://YOUR-TaifaPayTz-DOMAIN/api/public/v1/payments/FP-7K2Q9ZD4XA" -H "x-api-key: tp_live_YOUR_SECRET_KEY"Statuses: PENDING · SUCCESS · CANCELLED · REJECTED · FAILED
GET/payments?limit=20
Lists your most recent payments (max 100).
GET/balance
{ "success": true, "data": { "available": 450000, "currency": "TZS" } }4. Example (Node.js)
const API = "https://YOUR-TaifaPayTz-DOMAIN/api/public/v1";
const KEY = process.env.TAIFAPAY_API_KEY;
const res = await fetch(API + "/payments", {
method: "POST",
headers: { "x-api-key": KEY, "Content-Type": "application/json" },
body: JSON.stringify({ amount: 50000, phone: "0755123456", customer_name: "Asha Juma", external_id: "order-1001" }),
});
const { data } = await res.json();
// Poll until final
let status = data.status;
for (let i = 0; i < 24 && status === "PENDING"; i++) {
await new Promise((r) => setTimeout(r, 5000));
const s = await fetch(API + "/payments/" + data.reference, { headers: { "x-api-key": KEY } });
status = (await s.json()).data.status;
}
console.log(status); // SUCCESSExample (PHP)
$ch = curl_init("https://YOUR-TaifaPayTz-DOMAIN/api/public/v1/payments");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["x-api-key: " . getenv("TAIFAPAY_API_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(["amount" => 50000, "phone" => "0755123456", "customer_name" => "Asha Juma", "external_id" => "order-1001"]),
]);
$payment = json_decode(curl_exec($ch), true)["data"];5. Errors
{ "success": false, "error": { "code": "unauthorized", "message": "Missing or invalid API key" } }| 401 | unauthorized |
| 403 | account_inactive / inactive |
| 409 | duplicate |
| 422 | validation_error / phone / range |
| 502 | provider |
