MODULARPAY DEVELOPERS
Build payments into your product.
Accept deposits and request payouts through one REST API for MTN Mobile Money and Airtel Money in Uganda.
GETTING STARTED
One API for deposits and payouts
ModularPay provides JSON endpoints to verify a key, create mobile-money deposit and withdrawal requests, and check transaction status. Every API request must use HTTPS. Requests that need a key use a Bearer token.
The included rail is sandbox. In sandbox mode, requests are simulated and do not move real money. Live mobile-money processing is unavailable until a live provider is configured and enabled.
ACCOUNT SETUP
Get API access
- 1Use an active account
Suspended accounts cannot use the API.
- 2Verify your email address
Email verification is required before creating or using a key.
- 3Verify your website ownership
Add your website in Connect site & API keys, publish the unique DNS TXT record shown there, then choose Check DNS record. This proves you control the domain.
- 4Create a test key for that website
Choose the verified website when creating the key. Copy the secret when shown; it is displayed only once.
- 5Keep it on your server
Store the key in your server environment. Never put it in browser JavaScript, a public repository, or a mobile app bundle.
Website DNS verification and the API connection check are separate steps. The DNS record proves domain control; the API check confirms the key is active.
Authorization header
Authorization: Bearer YOUR_MODULARPAY_API_KEY
Accept: application/json
Use the full API key as the Bearer token. Do not send a separate secret key.
PROVE DOMAIN CONTROL
Verify website ownership
In your signed-in account, add the domain without https:// or a page path. ModularPay displays a one-time TXT record using the host _modularpay-verification. Add that host and its exact value in the domain's DNS manager, wait for it to publish, then select Check DNS record.
Once the record is found, the website is marked as verified and can be selected for an API key. Removing or changing the DNS record later does not automatically revoke a previously verified domain.
Publishing the TXT record does not test your API key. After creating a key for the verified website, use GET /v1/account as the separate API connection check.
FIRST REQUEST
Verify your connection
This confirms the API key is active and returns its linked website, account balance, supported networks, and current transaction limits. It does not perform the DNS ownership check.
/v1/accountRequires API keycurl "https://pay.aash.online/v1/account" \
-H "Authorization: Bearer YOUR_MODULARPAY_API_KEY" \
-H "Accept: application/json"
{
"verified": true,
"website_ownership": { "verified": true, "domain": "example.com" },
"account": { "available_balance": 0, "currency": "UGX" },
"supported_mobile_money_networks": ["mtn", "airtel"],
"payment_limits": {
"deposit": { "min": 500, "max": null },
"withdrawal": { "min": 500, "max": null }
}
}
The numeric limits in your response are authoritative; an administrator can change them.
COLLECT MONEY
Create a deposit
Replace the sample callback address with an HTTPS endpoint on your own public domain; placeholder addresses are not accepted.
/v1/depositsCreates a payment requestphoneRequired. Ugandan wallet phone number.networkRequired. mtn or airtel.amountRequired. Whole UGX amount within the current deposit limits.descriptionOptional. Up to 255 characters.callback_urlOptional. HTTPS address for a signed completion event.X-Idempotency-KeyRequired header. Unique value for this deposit attempt, up to 64 characters.curl -X POST "https://pay.aash.online/v1/deposits" \
-H "Authorization: Bearer YOUR_MODULARPAY_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Idempotency-Key: order-1001-deposit" \
-d '{
"phone": "+256700000000",
"network": "mtn",
"amount": 5000,
"description": "Order 1001",
"callback_url": "https://merchant.example.com/modularpay/events"
}'
The response is HTTP 201 with a transaction reference and current status. Save the reference for your records.
SEND MONEY
Create a withdrawal
Replace the sample callback address with an HTTPS endpoint on your own public domain; placeholder addresses are not accepted.
/v1/withdrawalsCreates a payout requestWithdrawals use only the available balance belonging to the API key's account. The administrator's withdrawal limits apply, and the platform can pause new withdrawals.
curl -X POST "https://pay.aash.online/v1/withdrawals" \
-H "Authorization: Bearer YOUR_MODULARPAY_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Idempotency-Key: order-1001-payout" \
-d '{
"phone": "+256750000000",
"network": "airtel",
"amount": 5000,
"description": "Merchant payout",
"callback_url": "https://merchant.example.com/modularpay/events"
}'
Use a different idempotency key for every new operation. If you retry the same operation, reuse its original key so you do not create a duplicate request.
TRACK A REQUEST
Check transaction status
/v1/transactions/{reference}Only this account's transactionscurl "https://pay.aash.online/v1/transactions/TRANSACTION_REFERENCE" \
-H "Authorization: Bearer YOUR_MODULARPAY_API_KEY" \
-H "Accept: application/json"
Possible statuses are pending, processing, succeeded, and failed. The endpoint returns 404 if the reference does not belong to your account.
AUTOMATE UPDATES
Completion callbacks
Pass a callback_url with a deposit or withdrawal request. When that transaction reaches succeeded or failed, ModularPay sends an HTTPS POST with a JSON event. Callback URLs must resolve only to public IP addresses; local and private-network addresses are rejected.
{
"id": "evt_DP-TRANSACTIONREFERENCE.succeeded",
"event": "transaction.succeeded",
"data": {
"reference": "DP-TRANSACTIONREFERENCE",
"type": "deposit",
"status": "succeeded",
"amount": 5000,
"currency": "UGX",
"phone": "+256700000000",
"network": "mtn",
"completed_at": "2026-12-02T12:00:00+03:00"
}
}
Verify the signature
The headers include X-ModularPay-Event, X-ModularPay-Delivery, and X-ModularPay-Signature. The signature is HMAC-SHA256 of the exact raw request body. To form its signing key, take the lowercase hexadecimal SHA-256 hash of your full API key, then calculate HMAC-SHA256 and compare it with sha256=... using a constant-time comparison.
// PHP example. Keep the API key in a server environment variable.
$rawBody = file_get_contents('php://input');
$apiKey = getenv('MODULARPAY_API_KEY');
$signingKey = hash('sha256', $apiKey); // lowercase hexadecimal
$expected = 'sha256='.hash_hmac('sha256', $rawBody, $signingKey);
$received = $_SERVER['HTTP_X_MODULARPAY_SIGNATURE'] ?? '';
if (!hash_equals($expected, $received)) {
http_response_code(401);
exit;
}
$event = json_decode($rawBody, true, flags: JSON_THROW_ON_ERROR);
// Process the event idempotently, then return HTTP 200.
Return HTTP 2xx after processing. Delivery is attempted twice for transient failures; there is no delivery history or scheduled retry queue yet. Use the transaction-status endpoint as a fallback. Treat delivery IDs as idempotency keys because a callback may be repeated.
TROUBLESHOOTING
Errors and request limits
401Missing, invalid, revoked, or disabled API key.403Email verification is needed, the environment is unavailable, or withdrawals are paused.403website_verification_required: the key is not linked to a verified website.404Transaction reference not found for this account.409Insufficient available balance, or another request conflict.422Invalid input, outside the administrator's limits, or callback URL is not allowed.429Rate limit reached. API keys are limited to 120 requests per minute.Send JSON with Content-Type: application/json and request JSON responses with Accept: application/json. API validation failures return a JSON error response. Check the current account response for up-to-date amount limits.