What are webhooks?
Webhooks are HTTP callbacks that M2M sends to your server when events occur. Instead of polling the API for updates, you receive instant notifications when:- A magic link is created
- A user opens a magic link
- M2M needs additional user data
- A money transfer operation is created
- A money transfer operation is cancelled
Configuration
Configure your webhook URL in the Partner Portal:- Navigate to Settings > Webhooks
- Enter your webhook endpoint URL (must be HTTPS)
- Save your configuration
- Copy your webhook secret for signature verification
Per-link callback URL
You can override the default webhook URL for specific links by providing acallbackUrl when creating the link:
Webhook format
All webhooks are sent as HTTP POST requests with a JSON body:Headers
Every webhook includes these headers:| Header | Description |
|---|---|
Content-Type | Always application/json |
X-M2M-Event | Event type (e.g., link.opened) |
X-M2M-Timestamp | Unix timestamp (seconds) |
X-M2M-Signature | HMAC-SHA256 signature for verification |
Always verify the
X-M2M-Signature header before processing webhooks. See Webhook Security for implementation details.Delivery guarantees
M2M implements reliable webhook delivery with automatic retries:Retry schedule
If your endpoint returns a non-2xx status code or times out, M2M retries with exponential backoff:| Attempt | Delay after failure |
|---|---|
| 1 | Immediate |
| 2 | 1 minute |
| 3 | 5 minutes |
| 4 | 30 minutes |
| 5 | 2 hours |
Timeout
Your endpoint must respond within 30 seconds. If processing takes longer, return a200 OK immediately and process the webhook asynchronously.
Success criteria
A webhook is considered delivered when your endpoint returns:- HTTP status code
200-299 - Within 30 seconds
Best practices
Respond quickly
Respond quickly
Return a
200 OK response as soon as you receive the webhook. Process the payload asynchronously if needed.Implement idempotency
Implement idempotency
Webhooks may be delivered more than once. Use the event data to ensure you don’t process the same event twice.
Verify signatures
Verify signatures
Always verify the
X-M2M-Signature header to ensure the webhook came from M2M. See Webhook Security.Handle unknown events gracefully
Handle unknown events gracefully
New event types may be added. Return
200 OK for unknown events instead of an error.Log webhook payloads
Log webhook payloads
Store webhook payloads for debugging and audit purposes. This helps troubleshoot issues and track user journeys.
Monitor delivery health
Monitor delivery health
Use the Partner Portal to monitor webhook delivery success rates. Set up alerts for repeated failures.
Testing webhooks
Sandbox environment
In the sandbox environment, webhooks work exactly like production. Use a tool like ngrok to expose your local development server:Manual testing
- Create a magic link in sandbox
- Check your webhook endpoint for the
link.createdevent - Open the link in your browser
- Check your webhook endpoint for the
link.openedevent - If you didn’t provide full user data, you’ll receive a
user.data_requestevent - Complete a money transfer in the widget to receive an
operation.createdevent - Cancel an operation from the widget to receive an
operation.cancelledevent
Troubleshooting
Webhooks not arriving
Webhooks not arriving
- Verify your endpoint URL is correct and uses HTTPS
- Check that your server is publicly accessible
- Review firewall rules that might block M2M’s IP addresses
- Check the Partner Portal for delivery errors
Signature verification failing
Signature verification failing
- Ensure you’re using the raw request body (before JSON parsing)
- Verify you’re using the correct webhook secret
- Check that you haven’t modified the payload before verification
Webhooks arriving late
Webhooks arriving late
- Check your endpoint’s response time
- Ensure you’re returning 200 OK promptly
- Review the retry schedule - delayed webhooks may be retries
Next steps
Webhook Events
See all event types and their payloads.
Webhook Security
Implement signature verification.