Skip to main content

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:

Request Authentication

All API requests must include your API key in the x-api-key header:

Data Protection

Sensitive Data Handling

What to encrypt:
  • User personal information (PII)
  • Transaction details
  • Bank account numbers
  • Phone numbers
Best practices:
  • Use AES-256 encryption at rest
  • Use TLS 1.3 for data in transit
  • Encrypt database backups
  • Never log sensitive data
Database security:
  • Enable encryption at rest
  • Use strong passwords
  • Limit database access
  • Regular security audits
Example:
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
Data retention:
  • Transaction logs: 7 years (compliance)
  • Temporary data: Delete after use
  • Inactive accounts: Archive after 1 year
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:

Handle Rate Limits


Common Security Threats

Threat: API key leaked in public repository or client-side codePrevention:
  • Never commit .env files
  • Add .env to .gitignore
  • Use environment variables
  • Never expose keys in frontend
  • Scan repositories for leaked keys
If compromised:
  1. Immediately rotate API key
  2. Revoke old key
  3. Audit all transactions
  4. Check for unauthorized access
  5. Update all environments

Input Validation

Always validate and sanitize user inputs:

Logging Best Practices

DO log:
  • API requests (without sensitive data)
  • Response status codes
  • Error messages
  • Transaction references
  • User actions
  • System events
Example:
NEVER log:
  • API keys
  • Passwords
  • Card numbers
  • CVVs
  • PINs
  • Full bank account numbers
  • Personal identification numbers
Example:
Best practices:
  • Encrypt logs at rest
  • Restrict log access
  • Rotate logs regularly
  • Centralized logging
  • Log retention policies
Retention:
  • 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:
1

Identify the Breach

  • Detect unauthorized access
  • Check logs for anomalies
  • Identify affected systems
2

Contain the Damage

  • Rotate API keys immediately
  • Revoke compromised credentials
  • Block suspicious IPs
  • Isolate affected systems
3

Assess the Impact

  • Review transaction logs
  • Check for unauthorized transactions
  • Identify affected users
  • Document all findings
4

Notify Stakeholders

  • Contact Monei support
  • Notify affected users
  • Report to authorities (if required)
  • Update security team
5

Remediate

  • Fix security vulnerabilities
  • Update security policies
  • Implement additional controls
  • Train team on prevention
6

Monitor

  • Enhanced monitoring
  • Regular security audits
  • Penetration testing
  • Continuous improvement

Security Checklist

API Keys

✅ Stored in environment variables
✅ 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

Access Control

✅ Role-based access
✅ Least privilege principle
✅ MFA enabled
✅ Regular access audits

Monitoring

✅ Real-time alerts
✅ 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