Overview
Security is paramount when building financial applications. This guide covers essential security practices for your Monei integration. What you’ll learn:- API key management
- Authentication best practices
- Data protection
- Rate limiting
- Common security threats
- Incident response
API Key Security
Your API key is the gateway to your Monei account. Protect it at all costs.Never Expose Keys
Never commit API keys to version control or expose them client-side
Use Environment Variables
Store keys in environment variables, not in code
Rotate Regularly
Rotate API keys periodically (every 90 days recommended)
Separate Environments
Use different keys for development, staging, and production
Storing API Keys
✅ CORRECT - Environment Variables
❌ WRONG - Hardcoded in Code
Environment Separation
Use different API keys for different environments:| Environment | Key Type | Purpose |
|---|---|---|
| Development | sk_test_... | Local development and testing |
| Staging | sk_test_... | Pre-production testing |
| Production | sk_live_... | Live production environment |
Request Authentication
All API requests must include your API key in thex-api-key header:
Data Protection
Sensitive Data Handling
Encrypt Sensitive Data
Encrypt Sensitive Data
What to encrypt:
- User personal information (PII)
- Transaction details
- Bank account numbers
- Phone numbers
- Use AES-256 encryption at rest
- Use TLS 1.3 for data in transit
- Encrypt database backups
- Never log sensitive data
Secure Storage
Secure Storage
Database security:
- Enable encryption at rest
- Use strong passwords
- Limit database access
- Regular security audits
Minimize Data Collection
Minimize Data Collection
Collect only what you need:
- Don’t store card CVVs
- Don’t store full card numbers
- Minimize PII collection
- Delete data when no longer needed
- Transaction logs: 7 years (compliance)
- Temporary data: Delete after use
- Inactive accounts: Archive after 1 year
Access Control
Access Control
Principle of least privilege:
- Limit API key permissions
- Use role-based access control (RBAC)
- Audit access logs regularly
- Implement multi-factor authentication (MFA)
Rate Limiting
Monei implements rate limiting to prevent abuse:| Endpoint Type | Rate Limit | Window |
|---|---|---|
| Read Operations | 1000 requests | 1 minute |
| Write Operations | 100 requests | 1 minute |
| Authentication | 10 requests | 1 minute |
| Webhooks | 500 requests | 1 minute |
Handle Rate Limits
Common Security Threats
- API Key Exposure
- Man-in-the-Middle
- Replay Attacks
- SQL Injection
Threat: API key leaked in public repository or client-side codePrevention:
- Never commit
.envfiles - Add
.envto.gitignore - Use environment variables
- Never expose keys in frontend
- Scan repositories for leaked keys
- Immediately rotate API key
- Revoke old key
- Audit all transactions
- Check for unauthorized access
- Update all environments
Input Validation
Always validate and sanitize user inputs:Logging Best Practices
What to Log
What to Log
DO log:
- API requests (without sensitive data)
- Response status codes
- Error messages
- Transaction references
- User actions
- System events
What NOT to Log
What NOT to Log
NEVER log:
- API keys
- Passwords
- Card numbers
- CVVs
- PINs
- Full bank account numbers
- Personal identification numbers
Secure Log Storage
Secure Log Storage
Best practices:
- Encrypt logs at rest
- Restrict log access
- Rotate logs regularly
- Centralized logging
- Log retention policies
- Application logs: 30 days
- Transaction logs: 7 years
- Error logs: 90 days
- Audit logs: 1 year
Incident Response
What to do if security is compromised:Contain the Damage
- Rotate API keys immediately
- Revoke compromised credentials
- Block suspicious IPs
- Isolate affected systems
Assess the Impact
- Review transaction logs
- Check for unauthorized transactions
- Identify affected users
- Document all findings
Notify Stakeholders
- Contact Monei support
- Notify affected users
- Report to authorities (if required)
- Update security team
Remediate
- Fix security vulnerabilities
- Update security policies
- Implement additional controls
- Train team on prevention
Security Checklist
API Keys
✅ Stored in environment variables
✅ Never committed to git
✅ Rotated every 90 days
✅ Separate keys per environment
✅ Never committed to git
✅ Rotated every 90 days
✅ Separate keys per environment
Data Protection
✅ Encryption at rest
✅ TLS 1.3 in transit
✅ No sensitive data in logs
✅ Regular backups
✅ TLS 1.3 in transit
✅ No sensitive data in logs
✅ Regular backups
Access Control
✅ Role-based access
✅ Least privilege principle
✅ MFA enabled
✅ Regular access audits
✅ Least privilege principle
✅ MFA enabled
✅ Regular access audits
Monitoring
✅ Real-time alerts
✅ Transaction monitoring
✅ Error tracking
✅ Audit logs
✅ Transaction monitoring
✅ Error tracking
✅ Audit logs
Next Steps
Webhooks
Secure webhook implementation
Best Practices
Additional security best practices
Testing
Test in sandbox environment
Error Handling
Handle errors securely

