Platform API reference

Introduction

Use speech, AI agents for calls, chat, email and texts, a CRM, and versioned, searchable records, each on its own or together. Speech, the CRM, versioned data with one query language over all of it, stored files, background jobs and webhooks, code repositories and organization administration all work without an agent; agents build on them, and the lab tests and debugs what they do.

Every Platform route is an HTTP call on https://api.hilus.ai/Platform/..., with JSON in and JSON out; live surfaces are Server-Sent Events streams and WebSockets. A successful response is the documented object itself; a failed request is an HTTP error status (see Errors).

Key concepts

Five ideas explain most of the platform; every guide builds on them.

Terms

Authentication

Send a credential with every request:

Keep API keys on your server. Browser code and WebSockets opened from a browser use a short-lived session token instead, minted by your server, passed as the token query parameter (browsers cannot set socket headers). Never put an API key in a URL.

curl https://api.hilus.ai/Platform/docs/api \
  -H "Authorization: Bearer $HILUS_API_KEY"

Errors

A failed request returns an error status with a JSON body such as {"success": false, "error": "...", "code": "..."}. error is a message for people; code, when present, is a stable identifier to branch on, and other fields add details. A few framework errors answer {"detail": ...} instead, so read error and fall back to detail. Some errors also carry X-Error-Type, a stable machine-readable classification.

Status Meaning
400 Invalid parameters or body; the error message names the problem.
401 Missing or invalid credentials.
403 Authenticated, but not allowed: a missing scope or role, an inactive organization (X-Error-Type), or a route the credential does not grant.
404 The route or the addressed record does not exist.
409 The request conflicts with the current state of the record.
429 Rate or concurrency limit reached; retry after Retry-After seconds.
500 Server error; quote the request id when reporting it.
503 Temporarily unavailable: a dependency (authentication, an upstream system) is degraded or the service is restarting; retry with backoff.
504 The route did not finish within its timeout; long work should use an async execution (202) instead.

Request IDs and rate limits

Every response carries X-Request-Id, the id the request's logs are filed under; errors returned through MCP or the CLI include it. Quote it when you report a problem.

Rate-limited requests return 429 with:

Header Meaning
X-RateLimit-Limit Requests allowed in the window.
X-RateLimit-Remaining Requests left in the window.
Retry-After Seconds to wait before retrying.

Async operations

A synchronous call returns only when the route finishes, and an agent turn that calls several tools can take minutes: give your HTTP client a generous timeout, or run the call asynchronously.

A long-running route may answer 202 Accepted before it finishes. The body names the execution and where to poll:

Field Meaning
async_id Execution identifier used for polling.
status The execution has not completed.
path Requested route path.
poll_url Route for retrieving the execution outcome.

The response headers X-Hilus-Async-Id and X-Hilus-Async-Status carry the same id and status. Poll poll_url until the status is terminal; the completed result has the route's documented response shape, serialized as a string. It is always the whole result, however large: one too large to keep on the execution record is stored as a value, the record carries its handle as result_ref, and polling and full webhook payloads still return the complete result. Hold on to result_ref to read the value after the execution record expires.

Streaming

Streaming routes answer text/event-stream. Each event is a data: line holding one JSON frame, followed by a blank line; lines starting with : are keep-alive comments to ignore. Each streaming route documents its frames on its Streaming events page.

WebSockets

WebSocket routes are documented as channels: the frames the client sends (Client events) and the frames the server sends (Server events). Every frame is a JSON object whose type field names it. Authenticate with the same credentials as HTTP, or ?token= with a session token from a browser.

When a channel has a heartbeat, the server sends {"type": "ping"}; answer each with {"type": "pong"} or the connection is closed. On a session-authenticated socket a session_refreshed frame carries a renewed token to store for the next connection.

Close code Meaning
1000 Normal close; also sent when the client stops answering heartbeat pings.
1003 No WebSocket route at this path.
1008 Policy violation: credential not accepted for this route, missing scope or role, or invalid connection parameters (the reason names them).
1011 Server error while handling the connection.
1012 Server restarting; reconnect.
1013 Rate or concurrency limit reached; retry later.
4001 Session expired or missing; re-authenticate (reload) and reconnect.
4002 Closed for inactivity (no real client frame within the idle timeout); reconnect at once only to resume a conversation the server has stored, otherwise when the user acts again.
4003 Credential of the wrong kind for this route; do not retry with the same credential.

Platform's live surfaces are sockets: a conversation with an agent runs over a chat socket, a phone call's audio and events over the calls sockets, and speech synthesis over text-to-speech. Each socket's page lists the frames it accepts and sends.

Backwards compatibility

Existing routes, fields and frames are not removed or renamed without notice. New optional fields, new routes and new frame types can appear at any time: ignore fields and frame types you do not recognize. A route's documentation page stays at the same URL; a renamed route redirects from its old page.

Common objects

Objects returned by more than one resource are described once, here.