MoMo Open API - Best Practices
Guidelines for building secure, reliable, and scalable integrations
1. Security & Credential Management
1. Gestion de la securite et des identifiants (Security & Credential Management)
MoMo API credentials provide direct access to your wallet and must be protected at all times.
Protect Your Credentials
Protegez vos identifiants
- API User
- API Key
- Subscription Keys
Important: If any credential is compromised, rotate it immediately.
Credential Management Best Practices
Bonnes pratiques de gestion des identifiants
- Never hard-code credentials in source code
- Store secrets in environment variables or secure key vaults
- Never commit
.envor secret files to version control - Use separate credentials for Sandbox, Staging, and Production
Credential Rotation
Rotation des identifiants
- Implement periodic credential rotation
- Rotate credentials when employees leave or systems are decommissioned
- Rotate immediately if compromise is suspected
Access Token Handling
Gestion des tokens d'acces
- Do not reuse access tokens across services
- Cache tokens only for their valid lifetime
- Never log token values
- Logging token expiry timestamps is allowed
2. Callback Handling & Webhook Security
2. Gestion des callbacks et securite des webhooks (Callback Handling & Webhook Security)
Endpoint Requirements
Exigences des endpoints
- Use HTTPS on port 443
- Use certificates from trusted certificate authorities
- Respond within a few seconds
- Always return HTTP
200 OKpromptly
Monitoring & Reliability
Surveillance et fiabilite
- Monitor HTTP response codes
- Track latency and availability
- Monitor SSL certificate expiry
Callback Security
Securite des callbacks
- Never blindly trust callback payloads
- Validate source IP addresses (MoMo callbacks originate from approved IP ranges)
- Validate transaction reference identifiers
High-Scale Callback Processing
Traitement des callbacks a grande echelle
- Queue callback processing internally
- Acknowledge callbacks immediately and process asynchronously
Additional Callback Security (Recommended)
Securite supplementaire des callbacks (recommandee)
Include a transaction-specific hash in the callback URL:
https://api.momocallbacks.com/disbursement-callbacks/{transactionHash}
Note: Only route parameters are allowed. Query parameters are not permitted.
3. Transaction Status Handling
3. Gestion du statut des transactions (Transaction Status Handling)
- Do not rely solely on callbacks
- Every transaction has a corresponding Get Transaction Status endpoint
- Use status checks to handle callback or network failures
Polling Strategy
Strategie de polling
- Use exponential backoff
- Define a maximum polling duration
- Stop polling after reaching a terminal status
UX Considerations
Considerations UX
- Handle pending and delayed confirmations gracefully
- Never assume immediate transaction success
4. IP Whitelisting
4. Liste blanche des IP (IP Whitelisting)
- Communicate in advance when adding or changing IP addresses
- Ensure whitelisted IPs are stable and monitored
Services Requiring IP Whitelisting
Services necessitant une liste blanche IP
- Disbursements / Transfers
- Remittances / Transfers
- Collections / Pre-Approval
- Dynamic Journey Services
5. Customer Consent for Debits
5. Consentement du client pour les debits (Customer Consent for Debits)
Customer consent is mandatory for debit operations.
- Verify that the MSISDN belongs to the requesting user
- Implement explicit confirmation logic
Recommended Approach
Approche recommandee
- Send an OTP to the MSISDN during registration
- Require OTP verification when using a new or unverified MSISDN
6. Idempotency & Transaction Safety
6. Idempotence et securite des transactions (Idempotency & Transaction Safety)
- Generate
X-Reference-Idserver-side using UUIDs - Persist transaction state before initiating MoMo requests
- Never reuse
X-Reference-Idacross different operations - Ensure retry logic is idempotent
7. Error Handling & Response Interpretation
7. Gestion des erreurs et interpretation des reponses (Error Handling & Response Interpretation)
- Do not treat HTTP
202 Acceptedas success - Always poll for final transaction status
- Centralize error handling logic
- Log correlation identifiers for support investigations
8. Logging, Monitoring & Auditing
8. Journalisation, surveillance et audit (Logging, Monitoring & Auditing)
Logging
Journalisation
- Mask sensitive fields such as tokens and MSISDNs
- Log timestamps, transaction IDs, and status changes
Monitoring
Surveillance
- Alert on abnormal failure rates
- Monitor callback delays and API error spikes
Auditing
Audit
- Retain logs according to regulatory requirements
- Ensure logs are tamper-resistant
9. Financial Reconciliation & Reporting
9. Rapprochement financier et reporting (Financial Reconciliation & Reporting)
- Perform financial reconciliation daily
- Do not wait for monthly close or audits
- Investigate discrepancies immediately
10. Support & Escalation Readiness
10. Preparation du support et des escalades (Support & Escalation Readiness)
When reporting issues to MoMo support, always provide:
- MSISDN
X-Reference-Id- Transaction timestamp
- Operation type (Debit, Transfer, Disbursement)