Build reliably
Webhooks
Meem POSTs a signed JSON event to your endpoint whenever a payment changes state. Verify the signature over the raw body, acknowledge fast, and process each event idempotently.
Register an endpoint
/api/v1/webhook-endpointswebhooks.manageurlstringrequired- Absolute
httpsURL of your receiver. Checked by the SSRF guard. eventTypesarray<string>optional- Event types to receive. Empty or omitted means all events. Names aren't validated, so copy them exactly from the list below.
curl -X POST "https://api.sandbox.meem-dev.example/api/v1/webhook-endpoints" \
-H "Authorization: Bearer $MEEM_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://shop.example.com/webhooks/meem",
"eventTypes": [
"payment.authorized",
"payment.captured",
"payment.declined",
"payment.refunded"
]
}'{
"endpoint": {
"id": "848b7ec6-7087-42a8-ba17-bb980c397f74",
"merchantId": "<merchant_id>",
"url": "https://shop.example.com/webhooks/meem",
"eventTypes": [
"payment.authorized",
"payment.captured",
"payment.declined",
"payment.refunded"
],
"active": true,
"createdAt": "2026-12-03T09:00:00+00:00"
},
"signingSecret": "whsec_<shown_once>"
}Event types
One event per payment state transition. Internal states (Created, Routing, Processing, RefundPending, Unknown) don't produce events.
| Event type | Payment status |
|---|---|
payment.authorized | Authorized |
payment.captured · payment.partially_captured | Captured · PartiallyCaptured |
payment.refunded · payment.partially_refunded | Refunded · PartiallyRefunded |
payment.voided | Voided |
payment.declined | Declined |
payment.failed | Failed |
payment.pending | Pending |
payment.requires_3ds · payment.requires_action | Requires3DS · RequiresAction |
payment.expired · payment.cancelled | Expired · Cancelled |
Request format
Each delivery is a POST with Content-Type: application/json, the signature in X-Webhook-Signature and the flow's X-Correlation-Id. The body is compact JSON with snake_case keys; null fields are omitted.
{
"event_id": "11111111-1111-1111-1111-111111111111",
"event_type": "payment.captured",
"payment_id": "22222222-2222-2222-2222-222222222222",
"merchant_id": "33333333-3333-3333-3333-333333333333",
"previous_state": "Authorized",
"new_state": "Captured",
"occurred_at": "2026-12-03T09:20:00+00:00",
"correlation_id": "0b8e5f8a-2f4c-4d6e-8a1b-3c9d7e6f5a21",
"data": {
"amount": "150.00",
"currency": "SAR"
}
}event_idstring (uuid)required- Unique per event. Use it to de-duplicate.
event_typestringrequired- One of the event types.
payment_id · merchant_idstring (uuid)required- The payment and its merchant.
previous_state · new_statestringoptional- The transition that triggered the event.
occurred_atstring (date-time)required- When the transition happened.
correlation_idstringrequired- Ties the event to the originating API request and logs.
datamap<string, string>optional- Non-sensitive details such as
amountandcurrency. Never card data.
Verify the signature
- Signature = HMAC-SHA256, key = your
signingSecret(the fullwhsec_…string, UTF-8), message = the raw request body bytes. - Output is lowercase hex, sent as-is in
X-Webhook-Signature(no prefix, no timestamp). - Verify before parsing. Re-serialising JSON changes bytes and breaks the check.
- Compare in constant time and reject mismatches with
401.
# BODY: the exact raw request body you received. SIGNATURE: the X-Webhook-Signature header.
EXPECTED=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$MEEM_WEBHOOK_SECRET" | sed 's/^.* //')
if [ "$EXPECTED" = "$SIGNATURE" ]; then echo "valid"; else echo "invalid"; fiProcess events idempotently
- Store
event_idwith a unique constraint; if it's already there, return200and stop. - Apply state changes keyed by
payment_idandnew_state, so applyingpayment.capturedtwice has no extra effect. - Don't assume ordering. When in doubt, read the current state with
GET /api/v1/payments/{payment_id}and act on that. - Acknowledge with
2xxquickly and do slow work asynchronously.
Delivery, retries and replay
- A delivery succeeds only on a
2xxreceived within 10 seconds. A later2xxcounts as a failure. - Failures are retried with exponential backoff: up to 6 attempts in total, waiting about 1, 2, 4, 8 and 16 minutes between them.
- After the last attempt the delivery is marked failed and appears in the failed-deliveries queue.
| Endpoint | Permission | Purpose |
|---|---|---|
GET /api/v1/webhook-deliveries/failed | webhooks.read | Failed deliveries for your merchant. |
POST /api/v1/webhook-deliveries/{id}/replay | webhooks.manage | Re-queue a delivery; returns 202. |
deliveryId="<delivery_id>"
curl -X POST "https://api.sandbox.meem-dev.example/api/v1/webhook-deliveries/$deliveryId/replay" \
-H "Authorization: Bearer $MEEM_ACCESS_TOKEN"{
"deliveryId": "<delivery_id>",
"status": "replay_scheduled"
}Destination rules (SSRF guard)
Meem refuses to call internal networks on your behalf. The URL is checked when you register it and again before every delivery, because DNS can change.
- Absolute
httporhttpsURL; usehttpsfor real endpoints. - Every address the host resolves to must be public. Private (10/8, 172.16/12, 192.168/16), link-local (169.254/16, including cloud metadata), carrier-grade NAT (100.64/10), loopback, reserved and IPv6 unique-local or link-local addresses are rejected.
- Loopback is allowed only in non-production deployments, for local testing.
- A blocked URL is rejected at registration with
422(webhook_endpoint.invalid_destination); a URL that becomes blocked later fails its deliveries.
Documentation reflects the platform as verified on 3 December 2026. Placeholder hosts and credentials are used throughout; your real sandbox host and keys are provided at onboarding.