Register an endpoint
whsec_...
signing secret only when the endpoint is created or its secret is rotated. Store
it in a secret manager. An agent may register up to five endpoints.
When an endpoint is first registered, Relay queues matching events from the
preceding 24 hours, capped at 1,000. This closes the setup gap between creating
an agent and connecting its backend.
Verify every request
Relay follows the Standard Webhooks signing format:
Compute HMAC-SHA256 over this exact UTF-8 value:
whsec_ before using it as the HMAC key. Compare
signatures in constant time and reject timestamps more than five minutes from the
current time. Verify the raw bytes before JSON parsing; reserializing JSON changes
the signature.
The official Standard Webhooks libraries implement this contract. In JavaScript:
On Cloudflare Agents, verify in
onRequest(), enqueue the event with the Agent
SDK’s durable this.queue(), and return 202 before model or tool work. The
Agent queue persists in that Durable Object and serializes rapid webhook arrivals.Acknowledge and deduplicate
Return any2xx after the event is durably accepted by your backend. Requests
time out after 10 seconds. Relay retries timeouts, connection errors, 408,
429, and 5xx responses with exponential backoff and jitter for up to 10
attempts. Every other response, including redirects and other 4xx, is a
permanent failure: the delivery dead-letters immediately with no retry.
Delivery is at least once. Store event_id as a unique key before producing side
effects. Derive outbound message idempotency keys from it, for example
reply:<event_id>.
A successful message.received delivery advances the agent’s delivered watermark.
Mark the message read only after your backend consumes it.
Manage endpoints
There is no component-specific side channel: ordinary component taps arrive as
message.received events. Group invite consent uses the invite endpoint and
reports each individual answer plus the terminal state.
See Event types for payloads and Delivery model
for the durable-state boundary.