Hosts
The relay that lets a phone run an operation on your desktop: presence stream, exec and result.
A host is a device that keeps GET /v1/hosts/stream open. Another device posts an exec; the gateway relays it over that stream and blocks until the host posts the result or the timeout fires. Presence expires 45 s after the last heartbeat. This relay is best-effort and not part of the public sessions protocol spec. Walkthrough: hosts guide.
Authorization
bearerAuth A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by /v1/realtime.
In: header
Header Parameters
Client correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128Response Body
application/json
application/json
application/json
curl -X GET "https://example.com/v1/hosts"{ "hosts": [ { "device_id": "2b6d8c1e-4f3a-4e9b-9c0d-7a1e5f6b8c2d", "name": "codai desktop", "platform": "desktop", "os": "windows", "hostname": "dragos-desktop", "roots": [ "E:\\gh", "C:\\Users\\me\\Projects" ], "since": 1758616800000, "last_seen": 1758616845000 } ]}Authorization
bearerAuth A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by /v1/realtime.
In: header
Query Parameters
Host operating system label; truncated to 40 chars.
length <= 40Host machine name; truncated to 120 chars.
length <= 120Comma-separated list of filesystem roots the host exposes; blanks dropped, max 32 entries.
Header Parameters
Client correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128Stable device UUID. Registers the device on first use (name/platform from x-codai-device-name / x-codai-device-platform) and selects the shared-sessions protocol.
uuidResponse Body
text/event-stream
application/json
application/json
application/json
application/json
curl -X GET "https://example.com/v1/hosts/stream" \ -H "x-codai-device: 497f6eca-6276-4993-bfeb-53cbbbba6f08""string"Authorization
bearerAuth A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by /v1/realtime.
In: header
Path Parameters
Device UUID of the target host (from GET /v1/hosts).
uuidHeader Parameters
Client correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128Stable device UUID. Registers the device on first use (name/platform from x-codai-device-name / x-codai-device-platform) and selects the shared-sessions protocol.
uuidRequest Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v1/hosts/497f6eca-6276-4993-bfeb-53cbbbba6f08/exec" \ -H "x-codai-device: 497f6eca-6276-4993-bfeb-53cbbbba6f08" \ -H "Content-Type: application/json" \ -d '{ "op": "shell" }'{ "req_id": "b0b81fb9-c6eb-4a11-855e-45e48af9566f", "ok": true, "result": null, "error": "string"}Authorization
bearerAuth A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by /v1/realtime.
In: header
Path Parameters
The req_id from the exec event (UUID; malformed → 400).
uuidHeader Parameters
Client correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128Stable device UUID. Registers the device on first use (name/platform from x-codai-device-name / x-codai-device-platform) and selects the shared-sessions protocol.
uuidRequest Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v1/hosts/exec/497f6eca-6276-4993-bfeb-53cbbbba6f08/result" \ -H "x-codai-device: 497f6eca-6276-4993-bfeb-53cbbbba6f08" \ -H "Content-Type: application/json" \ -d '{ "ok": true }'{ "ok": true}