Use the REST API when your backend is not running Node.js or when you want direct control over HTTP requests.Documentation Index
Fetch the complete documentation index at: https://moflay.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A Moflay account and organization
- A sandbox API key with the
express.paypermission - A phone number you can use for a sandbox STK push test
Step 1: Store your API key
Step 2: Start an express payment
CallPOST /v1/express with either phoneNumber or customerId. For the first test, use phoneNumber.
202 Accepted after Moflay sends the payment request to M-Pesa.
Step 3: Check the payment status
Use thepaymentId returned by POST /v1/express to read the latest payment status. You can also use the related transactionId if that is the identifier you stored.
pending to a final state such as completed or failed.
Request rules
| Field | Requirement |
|---|---|
phoneNumber or customerId | One is required |
amount | Whole number, greater than 0, up to 250000 |
description | Required, up to 13 characters |
accountReference | Optional, up to 12 alphanumeric characters |
Idempotency-Key | Optional, recommended for payment creation retries |
If you use
customerId, do not send extra customer fields such as
customerName or customerDescription in the same request.Production status handling
PollingGET /v1/payments/{paymentId} is useful during development. In production, configure Moflay webhooks so your backend receives signed payment events such as payment.completed and payment.failed.
Verify the result
Your HTTP integration is working when:POST /v1/expressreturns202- The response includes a
paymentId GET /v1/payments/{paymentId}returns the same payment in the sandbox environment