MobiariDocs

Webhooks

Receive a POST every time something interesting happens in your store.

A webhook is a URL you register that Mobiari POSTs to when an event fires. Use them to keep external systems (ERPs, AI agents, accounting, Slack) in sync without polling.

Setup

Create the webhook from the admin under Webhooks, or with the API. The request carries a store API key; the key names the store, so no store appears in the path. Pass the events to subscribe to in events:

curl -X POST "https://api.mobiari.com/v1/webhooks" \
  -H "Authorization: Bearer $MOBIARI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://api.example.com/mobiari/webhook",
    "secret": "a-long-random-string-that-stays-on-your-server",
    "events": ["orders.created", "orders.paid"]
  }'

The response (201) is the webhook, including its id, secret and events. Leave secret out and one is generated for you. You'll use it to verify signatures. An invalid URL or an event name that is not in the catalog answers 422 validation_failed.

MethodPathPurpose
GET/webhooksList webhooks, newest first. ?event=orders.paid keeps only the ones subscribed to that event.
POST/webhooksCreate. Body: url, optional secret, is_active, events.
PATCH/webhooks/{webhook_id}Change url, secret, is_active or events (the full list: events left out are no longer sent). Fields left out stay as they are.
DELETE/webhooks/{webhook_id}Delete.
GET/webhooks/{webhook_id}/deliveriesDelivery attempts, newest first, with response status and body.
GET/event-typesEvery event type you can subscribe to, with the object it carries and its details.
GET/eventsThe store's events, newest first, each exactly as its webhook was sent. Filter: type.

Paths are relative to https://api.mobiari.com/v1. The lists are paged as described in API conventions.

Changing the events of a webhook

Send the full list in events with PATCH /webhooks/{webhook_id}: events you leave out stop being sent, new ones start. Deliveries already queued are not affected.

Common events

EventFired when
orders.createdA new order is committed (payment intent issued).
orders.paidThe payment provider confirmed the payment.
orders.fulfilled, orders.shipped, orders.deliveredFulfillment progress.
orders.cancelledThe order was cancelled.
orders.refundedA full refund cleared the provider.
orders.updatedAny other change to an order.
products.created, products.updated, products.deletedCatalog changes, including media.
inventory.low_stock, inventory.back_in_stockStock crossed a threshold.
customers.created, customers.updated, customers.deletedCustomer records.
carts.abandoned, carts.recoveredCart recovery.

The full list is GET /event-types. New events are added over time; your handler should acknowledge events it doesn't handle.

Delivery shape

Every delivery is a POST whose body is the event:

{
  "id": "019a8c2e-5b7d-7f21-9c3e-6d1a2b3c4d5e",
  "type": "orders.refunded",
  "created_at": "2026-11-17T14:42:56.864Z",
  "store_id": "0199a4f2-6c1e-7d3a-9b1f-3e2c8a5d7f10",
  "data": {
    "object": {
      "id": "019a8c2d-1f2e-7a3b-8c4d-5e6f7a8b9c0d",
      "number": "1042",
      "status": "refunded",
      "total_cents": 12990,
      "...": "the rest of the order"
    },
    "details": { "refund_cents": 12990 }
  }
}
  • data.object is the object the event is about, exactly as its GET answers it (GET /orders/{order_id} here), read when the event was sent. It is the same on every retry. An object that no longer exists (after products.deleted, say) is {"id": "...", "deleted": true}.
  • data.details holds what the event knows that the object does not: the amount of this refund, the stage a customer left. GET /event-types lists the object and the details of every type, and the API reference has the full schema of each webhook.
  • GET /events answers the same events, with the same id and data (without store_id, since you named the store to ask). A key that may not read an event's kind of object (customers.read for a customer's events) gets its object and details withheld, and subscribing a webhook to such an event answers 403 missing_permission.

Money is in integer cents, like everywhere else in the API.

Headers on every delivery:

HeaderValue
Mobiari-Signaturet=<unix seconds>,v1=<signature>, see below
Mobiari-Event-TypeThe event type, same as type in the body
Mobiari-Event-IdThe event's id. The same on every retry: use it to dedupe.
User-AgentMobiari-Webhooks/1.0
Content-Typeapplication/json

Respond with any 2xx within 30 seconds. Anything else is a failure and is retried.

Verifying signatures

Every delivery carries a Mobiari-Signature header:

Mobiari-Signature: t=1763390576,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd

t is when the delivery was sent (Unix seconds) and v1 is HMAC-SHA256(secret, "<t>.<raw body>") in lowercase hex. Signing the time with the body lets you refuse a request someone recorded and sends again later. The SDKs check both:

import { verifyWebhook } from '@mobiari/api'

// rawBody: the body exactly as received (string or bytes), not parsed JSON.
const event = await verifyWebhook(rawBody, req.headers['mobiari-signature'], secret)
if (event.type === 'orders.paid') {
  const order = event.data.object // typed as an Order
}
from mobiari import verify_webhook

event = verify_webhook(request.body, request.headers['Mobiari-Signature'], secret)

Both throw (WebhookSignatureError) when the signature does not match or the request is more than five minutes old.

Without the SDK:

import crypto from 'node:crypto'

export function verify(rawBody, header, secret, toleranceSeconds = 300) {
  const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')))
  if (Math.abs(Date.now() / 1000 - Number(parts.t)) > toleranceSeconds) return false
  const expected = crypto.createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex')
  const a = Buffer.from(parts.v1 ?? '')
  const b = Buffer.from(expected)
  return a.length === b.length && crypto.timingSafeEqual(a, b)
}

Compute the HMAC over the raw bytes, not the parsed JSON: re-serializing would change whitespace and break the comparison. Always compare with a constant-time function: a plain === leaks information about the secret to a timing attacker.

Retries

Failed deliveries (non-2xx, timeout, connection error) are retried from a durable queue with exponential backoff: roughly 10 seconds, then 20, 40 and 80, for up to 5 attempts. Retries survive our deploys. After the last attempt the delivery is marked failed and not retried automatically.

Every attempt is recorded with its response status and body. See them in the admin under Webhooks → Deliveries, or with GET /webhooks/{webhook_id}/deliveries.

Make your handlers fast

The whole retry schedule spans about two and a half minutes, so an endpoint that is down for longer loses deliveries. Acknowledge the delivery (return 2xx) as soon as you've validated the signature and persisted the payload, then process asynchronously.

Idempotency

The same event can reach you more than once: a retry after your handler timed out, for example. Dedupe on the event's id (also in the Mobiari-Event-Id header), which is the same on every attempt. The body is identical across retries too; only the signature's time changes.

key = f"mobiari:webhook:{request.headers['Mobiari-Event-Id']}"
if not redis.set(key, 1, nx=True, ex=86400):
    return ack()  # already processed

Testing locally

Spin up a tunnel (cloudflared, ngrok) pointing at your dev server, register the public URL as a webhook against a development store, and trigger an event from the admin. The Webhooks → Deliveries tab shows everything that was attempted, including failures, with response bodies. That helps when your handler is returning the wrong status.

Permission cheatsheet

ActionPermission
List webhooks and deliverieswebhooks.read
Createwebhooks.write
Editwebhooks.edit
Deletewebhooks.delete
List the store's events (GET /events)stores.read

A key without the permission answers 403 missing_permission.

On this page