Relay v1
Use the locked Relay v1 contract instead of remembered examples.
Ground truth
- Read the locked source record.
- Read
contracts/relay-v1-openapi.yaml from the public Relay-SDK
repository at api.public_source.commit in the lock, and verify its
hash against api.openapi_sha256. The Server commit records the
contract's origin; private Server access is not required. If the
public copy and the lock disagree, report the stale source.
- Read the relevant guide and implementation evidence when it is available in
the workspace.
- Use the bundled Relay docs MCP to find material, not to override the locked
OpenAPI. If a search result disagrees with the lock, report the result as
stale and do not use its route, field, event, or package.
- Prefer
@relaymessenger/sdk for TypeScript and show equivalent cURL when
teaching an HTTP operation.
Never invent a route, resource, field, event, package, or migration. Label
unproved behavior unknown.
Agent event path
Relay derives an agent's event path from saved Webhook subscriptions:
| Saved configuration |
Path |
| One or more Webhook subscriptions |
Webhooks |
| Zero Webhook subscriptions |
WebSocket |
There is no transport mode or toggle. A socket upgrade while any subscription
exists returns HTTP 409. Creating the first subscription closes connected
agent sockets; deleting the final subscription makes the WebSocket path
available. Read Agent events before changing
subscriptions or connection code.
Core model
Relay uses Contacts, Handles, Chats, Messages, parts, Attachments, reactions,
and per-recipient delivery state. A Contact has kind: "user" | "agent".
For details, read only the reference needed:
- Messaging for sends, parts, Attachments, replies,
reactions, mentions, and receipts.
- Chats and Contacts for groups,
membership periods, Add requests, blocks, Contact Cards, and history.
- Agent events for Webhooks, WebSocket, ACK,
path changes, FULL sync, typing, retries, and
trace_id.
- SDK and authentication for Agent Tokens,
environments, the public TypeScript surface, retries, and errors.
Verification
Prove the integration at its real boundaries:
- signature verification over raw webhook bytes;
- durable event commit before webhook
2xx or WebSocket ACK;
- duplicate
event_id handling;
- idempotent REST replies;
- reconnect/replay and FULL-sync behavior for WebSocket consumers;
- first-subscription and last-subscription path changes;
- Webhook SSRF and redirect handling;
- direct and group Message behavior relevant to the product.
Keep Agent Tokens in trusted backend storage. Use a staging API root only with
credentials created in that same environment.
1---2name: relay3description: Implement, debug, or review a Relay v1 agent backend, Webhook receiver, WebSocket consumer, messaging flow, or @relaymessenger/sdk integration.4---56# Relay v178Use the locked Relay v1 contract instead of remembered examples.910## Ground truth11121. Read the [locked source record](references/relay-v1-lock.json).132. Read `contracts/relay-v1-openapi.yaml` from the public Relay-SDK14 repository at `api.public_source.commit` in the lock, and verify its15 hash against `api.openapi_sha256`. The Server commit records the16 contract's origin; private Server access is not required. If the17 public copy and the lock disagree, report the stale source.183. Read the relevant guide and implementation evidence when it is available in19 the workspace.204. Use the bundled Relay docs MCP to find material, not to override the locked21 OpenAPI. If a search result disagrees with the lock, report the result as22 stale and do not use its route, field, event, or package.235. Prefer `@relaymessenger/sdk` for TypeScript and show equivalent cURL when24 teaching an HTTP operation.2526**Never invent a route, resource, field, event, package, or migration.** Label27unproved behavior `unknown`.2829## Agent event path3031Relay derives an agent's event path from saved Webhook subscriptions:3233| Saved configuration | Path |34| --- | --- |35| One or more Webhook subscriptions | Webhooks |36| Zero Webhook subscriptions | WebSocket |3738There is no transport mode or toggle. A socket upgrade while any subscription39exists returns HTTP `409`. Creating the first subscription closes connected40agent sockets; deleting the final subscription makes the WebSocket path41available. Read [Agent events](references/agent-events.md) before changing42subscriptions or connection code.4344## Core model4546Relay uses Contacts, Handles, Chats, Messages, parts, Attachments, reactions,47and per-recipient delivery state. A Contact has `kind: "user" | "agent"`.4849For details, read only the reference needed:5051- [Messaging](references/messaging.md) for sends, parts, Attachments, replies,52 reactions, mentions, and receipts.53- [Chats and Contacts](references/chats-and-contacts.md) for groups,54 membership periods, Add requests, blocks, Contact Cards, and history.55- [Agent events](references/agent-events.md) for Webhooks, WebSocket, ACK,56 path changes, FULL sync, typing, retries, and `trace_id`.57- [SDK and authentication](references/sdk-and-auth.md) for Agent Tokens,58 environments, the public TypeScript surface, retries, and errors.5960## Verification6162Prove the integration at its real boundaries:6364- signature verification over raw webhook bytes;65- durable event commit before webhook `2xx` or WebSocket ACK;66- duplicate `event_id` handling;67- idempotent REST replies;68- reconnect/replay and FULL-sync behavior for WebSocket consumers;69- first-subscription and last-subscription path changes;70- Webhook SSRF and redirect handling;71- direct and group Message behavior relevant to the product.7273Keep Agent Tokens in trusted backend storage. Use a staging API root only with74credentials created in that same environment.