What you’ll need
- A Macropay account with an organization
- An organization access token — see Authentication
- An endpoint reachable over HTTPS (for local work, tunnel with ngrok)
Register an endpoint
Create the endpoint from the dashboard or the API. Either way, you’ll get back a signing secret (whsec_...) — store it like a password; you’ll use it to verify every delivery.
In the dashboard
- Open your organization Settings → Webhooks
- Click Add Endpoint
- Paste your handler URL, e.g.
https://your-app.com/api/webhooks/macropay - Tick the events you care about
- Create, then copy the signing secret
Via the API
Pick your events
“The customer just paid” → listen for
order.paid. It is the single signal for money cleared, across every flow:checkout.updated → status: succeeded is a funnel signal, not a fulfillment one — it can arrive before the order is fully paid. Grant access on order.paid, not on a checkout event. Distinguish one-time vs. subscription orders with order.subscription_id / order.billing_reason.
The full catalog — including events for usage-based meters and AI/agent billing — lives in the event reference.
Verify, then handle
Every delivery is signed using the Standard Webhooks spec and carries three headers:webhook-id, webhook-timestamp, and webhook-signature. Always verify against the raw request body before you trust a payload — never parse JSON first, or you’ll break the signature check.
Next.js (App Router)
FastAPI (Python)
Express.js
Test before you ship
Tunnel to localhost
https://abc123.ngrok-free.app/api/webhooks/macropay. Point your sandbox endpoint at it so test events never touch production.
Fire a real event
- Spin up a checkout link for one of your products
- Pay with the sandbox test card
4242 4242 4242 4242 - Confirm the
order.paidevent lands at your handler and your fulfillment logic runs
Harden for production
Deduplicate with webhook-id
The same event may be delivered more than once (that’s how at-least-once delivery guarantees nothing is lost). Treat webhook-id as an idempotency key:
Acknowledge fast, work later
Verify the signature, hand the payload to a queue, and return200 right away. Long-running fulfillment (emails, provisioning, third-party calls) belongs in a worker, not the request cycle:
Where to go next
Event reference
Every event type and payload shape, including usage and agent-billing events
Signature verification
How Standard Webhooks signing works under the hood
Delivery & retries
Retry backoff, ordering, and delivery guarantees
Customer state
Query a customer’s live entitlements on demand