Webhooks & crons
Declare HMAC-signed database webhooks with automatic retries and replay, plus scheduled UTC cron jobs, right in mantis/schema.ts.
Declare table webhooks and recurring cron jobs alongside your tables in mantis/schema.ts. They
version with your schema, show up in the dashboard's Automation tab, and keep a full history of
every delivery and run.
Declare webhooks and crons
import { defineSchema, t, table } from "@shipmantis/sdk";
export default defineSchema(
{
orders: table({
customerEmail: t.text(),
status: t.text().default("pending"),
totalCents: t.integer(),
}),
},
{
webhooks: {
orderCreated: {
table: "orders",
events: ["insert", "update"],
url: "https://api.example.com/webhooks/orders",
secret: process.env.ORDER_WEBHOOK_SECRET,
},
},
crons: {
dailyDigest: {
schedule: "0 9 * * *",
url: "https://api.example.com/internal/daily-digest",
method: "POST",
secret: process.env.CRON_SECRET,
},
},
},
);Push with npx shipmantis push to register or update your webhooks and crons.
Database webhooks
Whenever a matching insert, update, or delete commits on the watched table, Mantis sends an
HTTPS POST request with a 10-second timeout and up to 3 automatic attempts on network errors or
5xx responses.
Request headers and payload
| Header | Value |
|---|---|
content-type | application/json |
mantis-event | <table_name>.<op>, for example orders.insert |
mantis-signature | sha256=<hex> HMAC-SHA256 of the raw JSON body (sent when secret is set) |
{
"event": "orders.insert",
"table": "orders",
"op": "insert",
"old": null,
"new": {
"id": "5c7f0e93-b6d4-4f6e-8a21-4b1e07c29d3a",
"createdAt": "2026-12-04T12:00:00Z",
"customerEmail": "[email protected]",
"status": "pending",
"totalCents": 4900
},
"committedAt": "2026-12-04T12:00:00.142Z"
}Verify the HMAC signature
Always verify mantis-signature using a constant-time comparison before trusting the payload:
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyMantisSignature(rawBody: string, header: string | null, secret: string) {
if (!header) return false;
const expected = "sha256=" + createHmac("sha256", secret).update(rawBody).digest("hex");
const a = Buffer.from(header);
const b = Buffer.from(expected);
return a.length === b.length && timingSafeEqual(a, b);
}Inspect & replay deliveries
Every delivery attempt is logged in _mantis.webhook_deliveries with HTTP status, attempt count,
and error details:
- Dashboard: Open Automation to inspect deliveries and click Replay on any failed or past delivery to re-send the exact payload with a fresh signature.
- MCP: Agents can inspect recent deliveries with
list_webhook_deliveries.
Cron jobs
Cron jobs evaluate standard 5-field UTC cron expressions (minute hour day-of-month month day-of-week)
every minute on main:
| Field | Required | Details |
|---|---|---|
schedule | Yes | 5-field UTC cron expression (supports *, lists 1,15, ranges 1-5, steps */15). |
url | Yes | Public https:// endpoint to call. |
method | No | "POST" (default) or "GET". |
secret | No | When set, Mantis signs the request body with mantis-signature: sha256=<hex>. |
Each cron invocation sends mantis-cron: <name> and (for POST) a JSON body:
{
"cron": "dailyDigest",
"ranAt": "2026-12-04T09:00:00Z"
}Every run is recorded in _mantis.cron_runs. Trigger any cron on demand from the dashboard's
Automation tab (Run now) or from an agent using the trigger_cron MCP tool.
Security
Webhook and cron URLs must be public https:// addresses (private/loopback IPs are refused in
production to prevent SSRF). Keep secrets in environment variables rather than hardcoding them in
mantis/schema.ts.