API Documentation
Paylor provides a robust, secure, and developer-friendly API for processing M-Pesa payments. Our platform abstracts the complexity of direct integration, allowing you to go live in minutes.
Authentication
The Paylor API uses high-security Bearer tokens (API Keys) for authentication. Requests are made using HTTPS to ensure data privacy. Refer to the table below for the required integration credentials found in your dashboard.
Base URLs
Live Environment
Use this URL for production transactions.
https://api.paylorke.com/api/v1Sandbox Environment
Coming soon for testing purposes.
https://api.paylorke.com/api/v1/sandboxInitiate STK Push
The STK Push (Lipa na M-Pesa Online) allows you to trigger a payment request directly to a customer's phone. The customer will be prompted to enter their M-Pesa PIN to authorize the transaction.
Request Body
phoneRequiredCustomer phone number in international format (e.g., 254712345678).
amountRequiredAmount to charge in KES. Minimum is 1.
channelIdRequiredThe unique ID (alias) of your payment channel (Found in your API Settings).
referenceRequiredA unique internal reference used for tracking top-ups or specific orders.
callbackUrlHighly RecommendedA public URL to receive instant payment notifications. Securely signed with your Webhook Secret (Key ID).
Implementation Example
Query Transaction
Check the status of a transaction at any time using our query endpoint. This is particularly useful for verifying payments if you miss a webhook callback.
Error Codes
Webhooks Overview
Webhooks allow your application to receive real-time notifications when a transaction status changes. Instead of polling the status API, Paylor will push data to your server as soon as the event occurs.
Steps to Integrate
- Create an HTTP POST endpoint on your server (e.g.,
/api/paylor-webhook). - Go to your Dashboard > Developers > API Keys.
- Copy the Key ID (this is your Webhook Secret).
- Provide a
callbackUrlin your STK Push request body. - Secure your endpoint by verifying the
X-Webhook-Signatureheader using your Secret.