Webhooks
Receive signed notifications from services like Stripe, and notify other services with retries.
In stackly.json and the CLI it is webhooks. It has no price of its own; see What features cost.
webhooks · optional · needs backend · Workers with signature checks, on background jobs
Receive signed notifications from services like Stripe or GitHub, and notify other services with signed, retried requests.
Turn it on
"features": ["backend", "webhooks"],
"secrets": [{ "name": "STRIPE_WEBHOOK_SECRET", "description": "Stripe webhook signing secret (whsec_…)" }]
Add "queues" to send in the background with retries, "database" to see every webhook on its page in Stackly,
and the receiving host to "outbound" to send.
Use it
Receiving, in an API route:
import { env } from "cloudflare:workers";
import { verifyWebhook, WebhookError } from "#/lib/webhooks.server";
POST: async ({ request }) => {
try {
const hook = await verifyWebhook(request, { provider: "stripe", secret: env.STRIPE_WEBHOOK_SECRET });
if (hook.event === "checkout.session.completed") await enqueue("fulfil", { id: hook.data.data.object.id });
return new Response("ok");
} catch (error) {
if (error instanceof WebhookError) return new Response(error.message, { status: error.status });
throw error;
}
},
Providers: stripe, github, svix (Clerk, Resend and others), hmac (a hex HMAC-SHA256 of the body in a header;
set header). Answer fast; hand slow work to a job.
Sending:
import { sendWebhook } from "#/lib/webhooks.server";
await sendWebhook("https://hooks.example.com/orders", "order.paid", { orderId }, { secret: env.ORDER_HOOK_SECRET });
The body is { id, event, createdAt, data }, signed in Stackly-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<body>">. With queues on it is retried up to 5 times; without, it is tried once.
Limits
Incoming bodies up to 1 MB; signed timestamps up to 5 minutes old. The log keeps 30 days.
Locally
Outgoing deliveries are held in stackly dev and the draft, like other outgoing requests. Try incoming ones with a
signed test request.