PUBLIC API GUIDE

LeeTec M-Pesa API Documentation

Connect your backend to LeeTec Engine for authenticated M-PESA STK Push collections, transaction status, and direct routing to your configured Till, PayBill, or bank account.

1. Prepare your workspace

Add and activate a Till, PayBill, or Bank under Workspace → Payout methods. Customer payments route directly to your selected payout method. Keep enough LeeTec wallet balance for the platform fee. Requests without an active destination return 412 PAYOUT_METHOD_REQUIRED; insufficient wallet balance returns 402 INSUFFICIENT_WALLET_FUNDS.

2. Connect securely

Use base URL https://leetec.online and keep your API key on your server. Authenticate with Authorization: Bearer YOUR_API_KEY or the x-api-key header. Never expose a secret key in browser or mobile-client code.

3. Initiate an STK Push

Send an HTTPS POST /api/v1/stkpush request with a Kenyan phoneNumber, positive whole-KES amount, an accountReference, and a unique requestId. Optionally pass an active payout method ID as tillId to select a specific Till, PayBill, or Bank; without it, LeeTec selects an active method. Customer payments route directly to the selected payout method. Reuse the same request ID only to retry that payment. An accepted prompt is not a confirmed payment.

4. Confirm and reconcile

Check GET /api/v1/transactions/status?requestId=YOUR_REQUEST_ID or review GET /api/v1/transactions. Fulfil only when the final status is SUCCESS, and reconcile the amount, phone, reference, and receipt.

Merchant webhooks are optional

LeeTec records Safaricom payment callbacks without requiring a merchant webhook. Configure a signed webhook only if your backend needs event notifications; verify the signature and process duplicate deliveries safely.

Examples in your server language

The full API reference includes copyable cURL, Node.js, Python, PHP, and Java examples. Each example uses KES 1 and an example phone number; replace it with a phone you control before testing. Code examples send real production requests when run.

Open the full interactive API reference