API Keys
All requests to the M2M Partner API require authentication using an API key. You can manage your API keys in the Partner Portal.Key format
API keys follow a specific format that indicates the environment:| Prefix | Environment | Example |
|---|---|---|
m2m_test_ | Sandbox | m2m_test_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6 |
m2m_live_ | Production | m2m_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6 |
Using your API key
Include your API key in theX-API-Key header for all requests:
Managing API keys
From the Partner Portal, you can:- Create new keys - Generate additional keys for different services or environments
- Revoke keys - Immediately invalidate a compromised key
- View key prefixes - See which keys are active (full keys are never shown again)
- Track usage - Monitor when each key was last used
Authentication errors
When authentication fails, you’ll receive one of these error responses:Missing API key
Invalid or revoked key
Suspended partner
Webhook authentication
When M2M sends webhooks to your endpoint, each request includes a signature so you can verify it came from M2M.Webhook headers
Every webhook includes these headers:| Header | Description |
|---|---|
X-M2M-Signature | HMAC-SHA256 signature (format: sha256=<hex>) |
X-M2M-Timestamp | Unix timestamp when the webhook was sent |
X-M2M-Event | Event type (e.g., link.opened) |
Webhook secret
Your webhook secret is available in the Partner Portal under webhook settings. The secret format is:Verifying signatures
See the Webhook Security guide for complete verification examples in multiple languages.Security best practices
Store keys securely
Store keys securely
- Never commit API keys to version control
- Use environment variables or a secrets manager
- Restrict access to keys on a need-to-know basis
Use environment-appropriate keys
Use environment-appropriate keys
- Use
m2m_test_*keys in development and staging - Use
m2m_live_*keys only in production - Never use production keys for testing
Rotate keys regularly
Rotate keys regularly
- Create a new key before revoking the old one
- Update your services to use the new key
- Revoke the old key once migration is complete
Monitor for anomalies
Monitor for anomalies
- Track API usage patterns
- Set up alerts for unusual activity
- Review webhook delivery logs regularly
Verify webhook signatures
Verify webhook signatures
- Always verify the
X-M2M-Signatureheader - Check the timestamp to prevent replay attacks
- Reject webhooks with invalid signatures
Next steps
Quick Start
Create your first magic link.
Webhook Security
Implement signature verification.