Status: Private beta. The contract is cmd/allternit-api/openapi/selfhost-v1.yaml, version 1.0.0. The server that implements it is still being built.
The full, interactive reference is the Self-Hosted Agents API reference group in the API Reference tab, generated from the same OpenAPI file. You can also download the OpenAPI file and load it into your own tools, or generate a client from it. Default base URL: http://127.0.0.1:8400. Agent shapes follow the Platform API, without the fields that only apply to hosted voice and phone agents.

Conventions

  • JSON in and out. IDs are prefixed: agent_, env_, sess_, work_, evt_.
  • Lists use cursor pagination: ?limit= (1 to 100, default 20) and ?after=, answered with {"data": [...], "has_more": ..., "next_cursor": ...}.
  • Create routes accept an Idempotency-Key header (up to 255 characters): POST /v1/agents, /v1/environments, /v1/sessions and /v1/sessions/{id}/messages. The server enforces it:
    • The key is scoped to the caller, the method, the path and the key.
    • The same key with the same body replays the stored response, with the header Idempotency-Replayed: true.
    • The same key with a different body gives 422 idempotency_key_reuse.
    • The same key while the first request still runs gives 409 idempotency_in_progress. Retry shortly. A request in progress for more than 60 seconds is taken over.
    • Only 2xx responses are stored, for 24 hours. A failed request can be sent again with the same key.
    • A key over 255 characters or with characters other than printable ASCII gives 400 invalid_idempotency_key.
    • The official SDKs retry a failed request with the same key. To retry safely from your own code, send your own key and reuse it. See SDKs.
  • Every error is {"error": {"type", "message", "code"}}. The HTTP status says the kind of error; code says what went wrong.

Routes

Server and resources (server API key or OIDC; viewer can only read): Keys (role admin): Worker side (environment key, then the session secret): The route the agent loop uses to queue tool calls is loopback only, uses an internal token, and is not part of the public API.

Session events

seq rises by one for each event in a session, and events are never edited or removed. On the stream, each frame has id: <seq>, event: <type> and data: <event JSON>, with a keepalive comment every 15 seconds. Session statuses: idle, running, waiting_for_worker, interrupted, error, archived.

Error codes