Webhooks
Send and receive real-time events between Nebutra and your external systems.
Overview
Nebutra's webhook system (@nebutra/webhooks) allows you to:
- Receive events from Nebutra (inbound webhooks — e.g. Creem, GitHub)
- Send events to your customers' systems (outbound webhooks — when things happen in your product)
Outbound webhooks
Register an endpoint
Customers register webhook endpoints from Settings → Webhooks → Add Endpoint. There's no separate client SDK for this — the settings page calls the gateway route directly, which stores the endpoint and its event subscriptions via @nebutra/webhooks.
Send an event
import { getWebhooks } from "@nebutra/webhooks";
const webhooks = await getWebhooks();
await webhooks.sendEvent({
id: crypto.randomUUID(),
eventType: "invoice.paid",
payload: {
invoiceId: "inv_123",
amount: 9900,
currency: "usd",
},
timestamp: new Date().toISOString(),
tenantId: "org_123",
});Nebutra handles delivery, retries (with exponential backoff), and signature signing automatically.
Event delivery guarantees
| Property | Value |
|---|---|
| Delivery | At-least-once |
| Retry attempts | 6 (exponential backoff, 5s initial delay) |
| Signature | HMAC-SHA256 |
| Payload format | JSON |
| Timeout per attempt | 30 seconds |
Inbound webhooks (receiving events)
Verifying signatures
Always verify webhook signatures before processing events. Nebutra's own current card rail (Creem, per ADR 2026-09-26) verifies the raw request body before parsing it — the same pattern applies to any inbound webhook you receive:
import { verifyCreemSignature } from "@nebutra/billing";
export async function POST(req: Request) {
// Verify the bytes as received — parsing first would change them.
const rawBody = await req.text();
const signature = req.headers.get("creem-signature");
if (!verifyCreemSignature(rawBody, signature)) {
return new Response("Invalid signature", { status: 401 });
}
const event = JSON.parse(rawBody);
switch (event.eventType) {
case "checkout.completed":
await handleCheckoutCompleted(event.object);
break;
case "refund.created":
await handleRefundCreated(event.object);
break;
}
return new Response("OK", { status: 200 });
}Subscription webhooks (customer.subscription.*, invoice.*) still arrive from Stripe today (legacy) at a separate endpoint — see Payment Webhooks.
GitHub webhooks
import { createHmac, timingSafeEqual } from "node:crypto";
export async function POST(req: Request) {
const body = await req.text();
const signature = req.headers.get("x-hub-signature-256") ?? "";
const expected =
"sha256=" +
createHmac("sha256", process.env.GITHUB_WEBHOOK_SECRET!).update(body).digest("hex");
if (!timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) {
return new Response("Invalid signature", { status: 400 });
}
const event = JSON.parse(body);
// handle event.action, event.repository, etc.
return new Response("OK", { status: 200 });
}Webhook events reference
| Event | When it fires |
|---|---|
org.created | A new organization is created |
org.updated | Org name or settings change |
org.deleted | Organization is deleted |
member.invited | A member invitation is sent |
member.joined | A member accepts an invitation |
member.removed | A member is removed from the org |
api_key.created | An API key is created |
api_key.revoked | An API key is revoked |
project.created | A new project is created |
project.deleted | A project is deleted |
invoice.paid | A billing invoice is paid |
subscription.changed | Plan upgrade or downgrade |
quota.warning | Usage reaches 80% of quota |
quota.exceeded | Usage exceeds 100% of quota |
Testing webhooks locally
For Creem, set CREEM_TEST_MODE=true and point the webhook at your local tunnel, or use ngrok to expose your local server:
ngrok http 3000
# Copy the HTTPS URL → paste into your webhook endpoint settingsRelated
How is this guide?
Last updated on