Webhooks

Receive real-time notifications when events occur in your MPPFi account. Webhooks enable your application to respond immediately to payments, policy violations, balance changes, and blockchain confirmations.

Overview

Webhooks allow your application to receive HTTP POST requests when specific events happen. This is more efficient than polling the API and enables real-time integrations with AI agents.

Key Features:

  • Real-time delivery: Events delivered within milliseconds

  • Cryptographic signatures: HMAC-SHA256 verification for security

  • Automatic retries: Exponential backoff for failed deliveries

  • Blockchain confirmations: Events include on-chain transaction data

  • Idempotent delivery: Duplicate events include same event ID

Creating Webhooks

Via API

const webhook = await mppfi.webhooks.create({
  url: 'https://api.yourcompany.com/webhooks/mppfi',
  events: [
    'payment.created',
    'payment.completed',
    'payment.failed',
    'policy.violation',
    'balance.low'
  ],
  description: 'Production webhook endpoint',
  secret: 'whsec_your_generated_secret_key'
});

console.log(`Webhook ID: ${webhook.id}`);
console.log(`Secret: ${webhook.secret}`); // Store securely

Via Dashboard

  1. Click "Add Endpoint"

  2. Enter your URL and select events

  3. Save and note your webhook secret

Event Types

Payment Events

Event
Description
Includes Blockchain Data

payment.created

Payment initiated

No

payment.processing

Payment submitted to blockchain

Yes

payment.completed

Payment confirmed on-chain

Yes

payment.failed

Payment failed to process

Yes (if tx submitted)

payment.refunded

Payment refunded

Yes

Agent Events

Event
Description

agent.created

New AI agent account created

agent.funded

Agent account received funds

agent.balance_low

Agent balance below threshold

agent.suspended

Agent account suspended

Policy Events

Event
Description

policy.created

New spending policy deployed

policy.updated

Policy rules modified

policy.violation

Payment blocked by policy

policy.approval_required

Multi-sig approval needed

policy.approval_granted

Approval signature received

Account Events

Event
Description

account.balance_updated

Account balance changed

account.balance_low

Balance below warning threshold

account.frozen

Account frozen by admin or policy

account.unfrozen

Account reactivated

Blockchain Events

Event
Description

blockchain.transaction_confirmed

On-chain tx reached finality

blockchain.block_missed

Transaction not included in expected block

blockchain.reorg_detected

Blockchain reorganization detected

Webhook Payload

All webhooks follow this structure:

Verifying Signatures

CRITICAL: Always verify webhook signatures to ensure requests are from MPPFi.

TypeScript/Node.js

Using SDK

Python

Rust

Event Examples

Payment Completed

Policy Violation

Balance Low Warning

Best Practices

1. Respond Quickly

Respond with 200 OK within 5 seconds. Process events asynchronously:

2. Handle Idempotency

Events may be delivered more than once. Use event ID to track processed events:

3. Use HTTPS

Webhook URLs must use HTTPS in production. HTTP is only allowed in test mode.

4. Monitor Webhook Health

Check webhook delivery status via dashboard or API:

5. Implement Retry Logic

If processing fails, implement your own retry mechanism:

Retry Logic

If your endpoint returns a non-2xx status code, MPPFi will automatically retry delivery:

Attempt
Delay

1

Immediate

2

5 seconds

3

30 seconds

4

2 minutes

5

10 minutes

6

1 hour

After 6 failed attempts, the webhook is marked as failed and you'll receive an email notification.

Rate limiting: If your endpoint returns 429 Too Many Requests, MPPFi will respect the backoff and retry later.

Testing Webhooks

Send Test Events

Local Development

Use tools like ngrokarrow-up-right or LocalTunnelarrow-up-right to expose your local server:

Webhook Inspector

View webhook delivery logs in the dashboard:

Dashboard → Webhooks → [Select Webhook] → Delivery Logs

Each delivery shows:

  • Request payload (full JSON)

  • Response status code

  • Response body

  • Response time

  • Timestamp

  • Retry attempts

Example Integrations

Slack Notifications

Database Sync

Email Alerts

Webhook Security

IP Allowlist

Restrict webhook traffic to MPPFi's IP addresses:

Updated list: Check docs.mppfi.xyz/webhook-ipsarrow-up-right

Firewall configuration:

Rate Limiting

MPPFi respects rate limits. If your endpoint returns 429 Too Many Requests, deliveries will backoff and retry later.

Timeout

Webhook requests timeout after 10 seconds. Ensure your endpoint responds quickly.

Managing Webhooks

Update Webhook

Disable Webhook

Disable without deleting:

Delete Webhook

List Webhooks

Webhook Limits

Plan
Max Webhooks
Max Retries
Event Retention

Free

2

4

7 days

Pro

10

6

30 days

Enterprise

Unlimited

Custom

Custom

Troubleshooting

Webhook Not Receiving Events

  1. Check webhook status: Verify it's enabled in dashboard

  2. Verify URL: Ensure URL is publicly accessible via HTTPS

  3. Check event subscriptions: Confirm events are selected

  4. Review firewall rules: Allow MPPFi IP addresses

  5. Test endpoint: Send test event via dashboard

Signature Verification Failing

  1. Check secret key: Ensure using correct webhook secret

  2. Verify timestamp: Check mppfi-timestamp header handling

  3. Raw body: Use raw body (not parsed JSON) for verification

  4. Timing attack protection: Use crypto.timingSafeEqual() or equivalent

High Failure Rate

  1. Check response time: Endpoint must respond within 10 seconds

  2. Return 200 OK: Even if async processing fails later

  3. Handle errors: Log errors but still return 200

  4. Review logs: Check webhook delivery logs in dashboard

Next Steps

Last updated

Was this helpful?