Core concepts
Webhooks
Subscribe to billing events, verify signatures, and handle retries safely.
Webhooks push billing events to your endpoint as they happen. This page is a placeholder for the delivery contract.
Subscribe#
/v1/webhooksRegister an endpoint to receive events. The secret is returned once.
{
"url": "https://example.com/hooks/verlix",
"events": ["invoice.issued", "payment.failed"]
}Verify the signature#
Every delivery carries a signature over the raw body. Verify it before you parse the payload.
Verify before you trust
An unverified webhook is an unauthenticated write to your system. Reject any delivery whose signature does not match.
import { verifySignature } from "@verlix/sdk";
export async function POST(request: Request) {
const raw = await request.text();
const signature = request.headers.get("verlix-signature") ?? "";
if (!verifySignature(raw, signature, process.env.WEBHOOK_SECRET!)) {
return new Response("invalid signature", { status: 401 });
}
return new Response("ok");
}Event types#
| Event | Fires when |
|---|---|
invoice.issued | An invoice becomes final |
invoice.paid | An invoice is fully paid |
payment.failed | A payment attempt fails |
customer.created | A customer record is created |
Handle retries#
Respond quickly
Return a 2xx within five seconds. Do the real work asynchronously.
Be idempotent
A delivery may arrive more than once. Key your processing on the event id.
Expect backoff
Failed deliveries are retried with exponential backoff for up to 24 hours.