Getting Started
REST API Overview
The InfinityPay API lets you accept mobile money collections and generate payment links and invoices — from a website, a mobile app, an ecommerce platform, or your own backend. It's a predictable, versioned REST API: JSON in, JSON out, one response shape everywhere.
Base URL
Every endpoint in these docs is relative to this base URL:
https://api.infinitypay.meThere is no separate sandbox host. Your key decides the environment — an sk_test_ key is simulated and moves no money, an sk_live_ key is real, and both go to the same address. Switching to production means swapping the key, not the URL.
The response envelope
Every response — success or error, single object or paginated list — has the same top-level shape, so you only need to write one response parser:
{
"success": true,
"data": { "...": "..." },
"meta": null
}{
"success": true,
"data": [ { "...": "..." } ],
"meta": { "page": 1, "page_size": 20, "total": 42, "total_pages": 3 }
}{
"success": false,
"error": {
"code": "insufficient_balance",
"message": "Insufficient balance: available TZS 100,000, requested TZS 5,000,000",
"details": null
}
}List endpoints accept ?page=1&page_size=20 (page_size caps at 100). See Error Codes for the full list of error.code values.
Authentication
Server-to-server requests — from your backend, not a browser — authenticate with an API key generated in the dashboard, sent as an Authorization: Bearer header (or the equivalent X-API-Key header). Use the secret half of the key pair — the public key identifies a key but cannot authorize a request. Full detail, including scopes, sandbox vs. live keys, and key rotation, is in API Key Authentication.
Authorization: Bearer sk_live_YOUR_SECRET_KEYIdempotency
Every endpoint that moves money — creating a payment link, initiating a collection, or a customer completing a checkout — requires an Idempotency-Key header (any unique string, e.g. a UUID you generate per attempt). Retrying the same key with the same request body replays the original response instead of double-processing; reusing the key with a different body is rejected with 409 idempotency_key_reused.
Always generate a fresh key per user action, not per HTTP request
API resources
Collections API
Push USSD, STK Push, Selcom Pesa Push, and Dynamic QR collections.
Payment Links API
Generate shareable checkout links for any amount.
Invoices API
Itemized invoices with a built-in Pay Now link.
Webhooks
Real-time event notifications delivered to your server.
Error Codes
Every error code the API returns, and what to do about it.
Rate limits
Each API key is limited to 120 requests per minute by default. Responses include no special rate-limit headers yet — if you need a higher limit for a high-volume integration, contact us.
Who this API is for
The same REST API powers every kind of integration — a checkout flow on a website, a native mobile app, an ecommerce plugin, or an internal web app calling InfinityPay from your own backend. There's no platform-specific SDK required: any language or framework that can make an HTTPS request and parse JSON can integrate. See cURL, JavaScript, and Python examples to get started in your stack.