Device relay API
For an account with end-to-end encryption, a device the user opted in answers the decrypt and encrypt steps of MCP tool calls.
Implementation notes
For an account with end-to-end encryption, a device the user opted in answers the decrypt and encrypt steps of MCP tool calls (OpenSpec mcp-device-relay). The server never holds the key; relayed text exists only in memory during the call and is never stored, logged or audited. Session cookies only (no API tokens); every route is refused on a demo instance.
- POST
/api/v1/relay/answers/{id} - GET
/api/v1/relay/devices - PUT
/api/v1/relay/devices/{device} - DELETE
/api/v1/relay/devices/{device} - PUT
/api/v1/relay/devices/{device}/routines - DELETE
/api/v1/relay/devices/{device}/routines - GET
/api/v1/relay/events
POST /api/v1/relay/answers/{id}
Relay answer · Session only
{box} sealed the same way, holding {results: [{value} or {error}]} or {error: "device_limit"|"declined_on_device"|"locked"} → 204; any other session, a second answer or a box that does not open → 404 not_found
Needs a session; tokens are refused.
| Field | Type | Description |
|---|---|---|
id required | string | path |
| Field | Type | Description |
|---|---|---|
box required | string |
GET /api/v1/relay/devices
List relay devices · Session only
{devices: [{deviceId, label, enabledAt, online, thisSession, mcp, routines, connected, capabilities}]}: mcp answers AI connectors, routines runs your routines (below), connected its own stream is open, capabilities what it announced (routines, ai)
Needs a session; tokens are refused.
| Field | Type | Description |
|---|---|---|
devices required | array of object | |
devices[].capabilities required | array of string | |
devices[].connected required | boolean | |
devices[].deviceId required | string | |
devices[].enabledAt required | number | |
devices[].label required | string | |
devices[].mcp required | boolean | |
devices[].online required | boolean | |
devices[].routines required | boolean | |
devices[].thisSession required | boolean |
PUT /api/v1/relay/devices/{device}
Replace a relay device · Session only
{label} → 204. Needs a recently confirmed session; binds the opt-in to this session. 409 not_encrypted without encryption, 409 mcp_disabled while the owner has MCP off. Recorded as relay.enabled
Needs a session; tokens are refused. Needs a recently confirmed session or second factor.
| Field | Type | Description |
|---|---|---|
device required | string | path |
| Field | Type | Description |
|---|---|---|
label required | string |
DELETE /api/v1/relay/devices/{device}
Delete a relay device · Session only
→ 204; ends the device's AI connector opt-in and its stream (a routines opt-in stays). Recorded as relay.disabled. Signing out the session that opted in and turning encryption off also end it
Needs a session; tokens are refused.
| Field | Type | Description |
|---|---|---|
device required | string | path |
PUT /api/v1/relay/devices/{device}/routines
Update relay device routines · Session only
{label} → 204: "Run my routines on this device". Needs a recently confirmed session; binds the opt-in to this session; does not need the owner's MCP switch. Survives locking (the device answers only while unlocked); ends at sign-out of that session or when encryption is turned off. 409 not_encrypted without encryption
Needs a session; tokens are refused. Needs a recently confirmed session or second factor.
| Field | Type | Description |
|---|---|---|
device required | string | path |
| Field | Type | Description |
|---|---|---|
label required | string |
DELETE /api/v1/relay/devices/{device}/routines
Delete relay device routines · Session only
→ 204 from any of your devices: ends the routines opt-in
Needs a session; tokens are refused.
| Field | Type | Description |
|---|---|---|
device required | string | path |
GET /api/v1/relay/events
List relay events · Session only
Server-sent events for the opted-in device of this session only (403 not_opted_in otherwise). caps (comma-separated, for a routines opt-in): routines, and ai when the on-device assistant is set up and consented on it. key is the device's ephemeral ECDH P-256 public key (uncompressed, base64url). The first event, hello, carries {stream, key}: the stream id and the server's key. Both sides derive an AES-256-GCM key with HKDF-SHA-256 (salt = stream id, info opentodo relay v1). Each request event is {id, box}: box is base64url(nonce ‖ AES-GCM of {op, items, call, deadline}) with id as associated data. A routine event (routines opt-in) is {id, box} sealed the same way with the run id as id, holding {op: "routine.run", rule, run, occurrence, at, task?, rev, auto, tokens, budget}: ids and numbers only
Needs a session; tokens are refused.