To get started with the MTN MoMo API in Uganda: (1) register on momodeveloper.mtn.com, (2) subscribe to the Collections API product, (3) generate sandbox API credentials, (4) set up a Node.js or Python project with an HTTP client, (5) authenticate and get an access token, (6) send a Request to Pay with the customer's phone number, amount in UGX, and a UUID reference, (7) handle the callback on your server to confirm the payment result. The entire sandbox flow can be tested without real money.
This tutorial assumes you can write basic JavaScript or Python. You do not need to know anything about payment APIs or mobile money. If you have ever made an HTTP request using fetch, axios, or the requests library in Python, you have enough background.
You will need:
You do not need an MTN MoMo account with money in it. You do not need a Ugandan phone number. You do not need a registered business. The sandbox is completely free and works from anywhere.
Go to the MTN MoMo Developer Portal.
Next, you need to create a sandbox API user. The MoMo sandbox has a provisioning endpoint for this:
This provisioning step trips up many beginners because it is a multi-step process just to get credentials. Do not skip any step. If you get a 401 or 404 error, double-check that you are using the sandbox URL, not the production URL.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
With your sandbox credentials ready, here is the flow to collect a payment:
In the sandbox, the payment is automatically approved. In production, the customer would see a USSD prompt on their phone and enter their PIN to confirm. The sandbox skips this step and simulates a successful payment.
The most common beginner mistakes here: using the wrong Content-Type (must be application/json), forgetting the X-Reference-Id header, or sending the phone number without the country code (256).
After the customer confirms (or the sandbox auto-approves), MoMo sends a POST request to your callback URL with the transaction result. Your server needs to be ready for this.
Set up a simple Express server (Node.js) or Flask server (Python) with a POST endpoint at your callback path. The callback body contains:
For local development, your server runs on localhost, which MoMo cannot reach. Use ngrok to create a public URL that tunnels to your local server:
ngrok http 3000As a fallback (and a good practice), always implement status polling. After sending a Request to Pay, you can GET the transaction status using the reference ID. This protects you against missed callbacks due to network issues, server downtime, or timeout problems.
Log every callback you receive. In the early days of your integration, these logs will be your primary debugging tool. See our common MoMo and Airtel Money API errors guide for the error codes you will encounter.
Your sandbox code is 90% of your production code. The things that change:
Structure your code so that the base URL, credentials, and target environment are loaded from environment variables. This way, switching between sandbox and production is a configuration change, not a code change.
For a deeper guide on sandbox testing strategies, read our testing mobile money in sandbox guide. For the production deployment process, our Deployment and Going Live course (KES 4,999, approximately UGX 140,000) walks through the full flow from working code to live product.
You have the basics of MoMo API integration. Here is what to learn next, in order of practical value:
If you want structured instruction on mobile money integration with mentorship and feedback, McTaba's M-Pesa Integration course (KES 9,999, approximately UGX 280,000) teaches the request-callback architecture, sandbox-to-production workflow, and error handling patterns. The course uses M-Pesa and Airtel Money as the teaching vehicle, but the architecture you learn applies directly to MoMo.
Create a free McTaba Academy account. Access starter lessons, join the community, and explore at your own pace.
Create Free Account