Skip to main content
A webhook tells your server when to look. It does not tell you what is true: delivery is at least once, may arrive out of order, and carries no authority. getGasExecution remains the source of truth, and every integration should reconcile against it. Webhooks covers delivery timing and retries; this page is the SDK surface.

Create an endpoint

The returned secret is shown once. Store it where you can read it on every delivery, and nowhere else.
The URL must be https and resolve to a public address, and redirects are not followed. A project environment can have up to 10 endpoints.

Verify every delivery

verifyWebhook checks the signature against the exact raw request body. It uses a timing-safe comparison, rejects a timestamp outside the tolerance, and confirms the body parses and its id matches the gol-webhook-id header. It lives in the server entry point because it needs the Node.js crypto module and your secret. The critical detail is the raw body. Parse JSON first and the signature no longer matches.
In a framework, configure a raw body parser for the webhook route only. A global JSON parser is the most common reason verification fails. Every failure throws GolWebhookVerificationError with one of: missing signature headers, a timestamp outside the tolerance, an invalid signature, or a webhook id mismatch. Reject with a non-2xx status in all four cases and let GOL retry. verifyWebhook is a constant-time HMAC-SHA256 over timestamp.rawBody, keyed by the endpoint secret, which is exactly what the signature header carries. You can compute it yourself if you need to, but the helper also enforces the tolerance window and the id check for you.

Rotate without dropping events

During a rotation both secrets sign deliveries for 24 hours, and verifyWebhook accepts an array. Verify against both, then replace the old one once the overlap ends.
Rotate from rotateWebhookSecret, which returns a new one-time secret. Store the new value, deploy it alongside the old, and delete the previous variable after the overlap.

Event types

GolWebhookEvent<Data> is generic, so you can type the payload you expect for a handler. Every event also carries id, type, createdAt, projectId, and environment. The type union includes (string & {}), so an unknown type from a future release is still assignable and reaching your switch rather than failing to compile.

Manage endpoints

An endpoint carries a status of enabled or disabled, and setWebhookEndpointEnabled returns it updated. A disabled endpoint keeps its pending deliveries for 72 hours rather than dropping them instantly. listWebhookDeliveries(projectId, endpointId, limit?) returns recent attempts with their status and response code, which is the fastest way to tell a signature bug from a delivery problem.

Type a handler

GasExecutionResponse comes from the browser-safe root entry point, so a shared handler module can import it without pulling in your secret.