Prefer client.eventsHandler(secret, fallback) to bind the handler to your API client.
Verify and parse an event, then await its registered callback or the fallback. Callbacks only run after successful verification and parsing. Acknowledge delivery with a 2xx response only after this promise resolves.
Unchanged request body. The caller owns reading and limiting it.
Complete value of the SIGNATURE_HEADER header.
EventSignatureError If verification fails, including the five-minute timestamp check.
EventPayloadError If the body cannot be decoded as a JSON object.
EventCallbackError If processing fails; its cause holds the original error.
Read a standard Fetch Request and process it with EventsHandler.handle. Consumes the entire body and reads SIGNATURE_HEADER; do not read the body first. Configure body-size limits in your server or hosting platform and send the response yourself. Use handle(body, signature) with Express or other frameworks that provide a different request type.
Register a callback for an event type. Its event and fetched resource types are inferred.
This handler, for chaining registrations.
EventError If the callback is missing or the type is already registered.
Verify and parse an incoming event without invoking callbacks. Requires a signing timestamp within five minutes of the receiver's clock. Event fields follow the API contract and are not separately validated.
Unchanged request body, read before JSON parsing.
Complete value of the SIGNATURE_HEADER header.
A typed notification, or UnknownEvent for an unrecognized type.
EventSignatureError If verification fails.
EventPayloadError If the body cannot be decoded as a JSON object.
Verify incoming events and dispatch them to typed callbacks. Create a handler with client.eventsHandler(secret, fallback), then register callbacks with on(). Known events without a callback and unknown event types reach the fallback. Calls may run concurrently; callbacks must synchronize shared state as needed.