Core concepts
Webhooks
Signed, retry-safe events for orders, inventory, payments and trips.
Event types
Webhooks deliver a JSON envelope with a type, a created timestamp and a data object. Subscribe to specific types per endpoint.
- order.created, order.updated, order.refunded
- inventory.adjusted, inventory.transferred
- payment.settled, payment.failed
- trip.updated, trip.disrupted
- close.completed
Verify the signature
Every request includes Viraj-Signature: t=timestamp,v1=hex. Compute an HMAC over `${timestamp}.${rawBody}` with the endpoint secret and compare in constant time.
Reject requests older than five minutes. Verify against the raw body, before JSON parsing.
import { createHmac, timingSafeEqual } from 'node:crypto'
export function verifyWebhook(
rawBody: string,
signature: string,
secret: string,
): boolean {
const [timestampPart, digestPart] = signature.split(',')
const timestamp = timestampPart?.replace('t=', '') ?? ''
const digest = digestPart?.replace('v1=', '') ?? ''
if (!timestamp || !digest) return false
if (Date.now() - Number(timestamp) * 1000 > 5 * 60_000) return false
const expected = createHmac('sha256', secret)
.update(`${timestamp}.${rawBody}`)
.digest('hex')
const a = Buffer.from(expected)
const b = Buffer.from(digest)
return a.length === b.length && timingSafeEqual(a, b)
}Delivery and retries
Endpoints must return 2xx within ten seconds. Anything else is retried with exponential backoff for 24 hours: 1m, 5m, 30m, 2h, 6h, then hourly.
Deliveries are at-least-once. Store the event id and make handlers idempotent before acknowledging.
{
"id": "evt_01HZ8R2K",
"type": "order.created",
"created_at": "2026-03-14T16:42:00Z",
"data": { "id": "ord_4821", "status": "paid", "total_cents": 482000 }
}Test locally
Forward events to localhost with the CLI, then replay from Console without re-triggering the original action.
viraj webhooks listen --forward-to http://localhost:3000/api/webhooks \
--events order.created,inventory.adjusted