Overview

The Agents API is the central surface for creating, configuring, running, and managing agents on the Allternit platform. Agents are persistent, user-owned records. Each one has a profile (name, description, system prompt), capabilities, a tool policy, a harness configuration, a set of enabled surfaces, and a model + provider pair. POST /api/agents/:id/runs calls that model and provider directly today. Once created, an agent can be run on demand, instantiated from a template, published to the marketplace, or wired as a subagent under an orchestrator.
Existing runtime/provider APIs expose implementation controls intentionally. The Agency API is the abstraction that hides those controls behind capabilities and one durable agent identity. On this API, model, provider and the template brain object are real, returned fields and are documented as such.

Agents API vs Agency API

An Agent is configuration and identity. Agency is execution of work.

Routes

All agent routes are mounted under /api and require a valid bearer token via the platform auth middleware.

Base URL

Authentication

All requests must include a valid bearer token in the Authorization header. See Authentication for details.

Agent object

Agent creation checklist

Every creation flow enforces the same validation rules:
  • name must be at least 3 characters.
  • description must be at least 10 characters.
  • type is required.
  • model and provider are required.
  • harness_config.mode must be one of byok, cloud, local, or subprocess.
  • enabled_modes must contain at least one surface.
  • trust_tier is required.

Endpoints

List agents

Returns all agents owned by the authenticated user, newest first.

Query parameters

Example request

Example response

Create an agent

Creates a new agent. The request body is validated against the agent creation checklist.

Request body

Example request

Example response

Returns 201 Created. principal_token is present only when a fabric-transport bearer token was issued, and it is shown exactly once.

Get an agent

Returns the full agent record.

Example request

Example response

Update an agent

Partial update using COALESCE semantics: omitted fields keep their current values. The same harness-mode and enabled-modes validations apply.

Example request

Example response

Patch an agent

Merge-semantics partial update: only provided fields change. A successful change bumps the agent’s version and writes an agent_versions snapshot. Returns the updated agent. Unknown or un-owned IDs return 404 (unlike PUT, which keeps its lenient {"success": true} shape).

Archive an agent

One-way archive: status becomes archived and archived_at is stamped. There is no unarchive endpoint in this release. Unknown IDs return 404.

Save an Agent Studio prototype

Saves an Agent Studio draft as a real agent row with status prototype, keyed by user + name (saving again with the same name updates it). Requires name (at least 2 characters) and model; max_tokens, if given, must be at least 1. Prototypes are hidden from GET /api/agents unless include=prototypes is passed.

Agent toolset

Reads or replaces the agent’s toolset fields. PUT uses merge semantics, bumps version, and writes an agent_versions snapshot. Unknown permission values, or permission keys naming tools the agent does not have, return 400.

Delete an agent

Deletes the agent and its database row. Best-effort cleanup of related runtime state may happen asynchronously.

Example response

Subagents

Subagents are agents whose mode is subagent and whose parent_agent_id points to an orchestrator or the primary Companion. They are created through the same checklist as any other agent.

List subagents

Returns a compact view of all subagents under the parent agent.

Example response

Create a subagent

Creates a subagent under the parent. The route forces parent_agent_id to :id and mode to subagent. The parent must exist and belong to the caller.

Example request

Example response

Companion agent

Ensure Companion

Idempotently ensures the user has a primary “Allternit Companion” agent. If one already exists, the existing agent is returned; otherwise a new orchestrator is created with a runnable local model. If the user’s configured default is empty or an unconfigured fallback, the Companion uses ollama / qwen2.5:0.5b so it runs out of the box.

Example response (created)

Example response (existing)

Templates

Templates are persisted agent patterns (orchestrator + subagents) stored in the agent_templates table.

List templates

Returns all agent templates, built-ins first.

Example response

Instantiate a template

Creates a live orchestrator and its subagents from a template. The model can be overridden with brain; otherwise the user’s default model is used, falling back to a local Ollama model.

Request body

Example request

Example response

Running agents

Run an agent

Sends input through the Gizzi runtime using the agent’s system prompt and its configured model and provider. The call records a run, persists the outcome, and emits ledger events in the Allternit Factory engine.

Request body

Example request

Example response (success)

Example response (model error)

List agent runs

Returns up to 50 run records for the agent, newest first.

Example response

Stream agent events

Server-sent events (SSE) stream of ledger events (Allternit Factory engine) scoped to the agent. Replays up to 50 recent matching events on connect, then polls for new events every 2 seconds.

Example curl

Example event

Ingest an agent event

Appends a runtime-bridged event to the Allternit Factory ledger so it appears on GET /api/agents/:id/events (for example waiting_approval, waiting_input or blocked states). The payload must be a JSON object and is merged under agent_id (and run_id when given). Unsupported event types return 400; success returns 202 with {"ok": true}.

Agent identity

Get agent identity

Returns whether the agent has a bound identity key and the key itself.

Example response

Set agent identity

Binds a caller-supplied public key to the agent. The platform never generates or returns private keys.

Request body

Example request

Example response

Provision an agent wallet

Provisions an Etrid wallet for the agent. The platform owns the wallet-service relationship, so clients never handle wallet key material.

Agent metrics

List metrics

Returns event-style metric samples for the caller’s agents. Defaults to the last 7 days.

Query parameters

Example response

Test suites

List test suites

Returns test suites for the caller, optionally filtered by agent.

Example response

Create a test suite

Request body

Example request

Example response

Run an agent test

Runs a single real round-trip against the agent’s configured model using the last user message in messages, or a default connectivity probe.

Request body

Example request

Example response

Agent marketplace

The marketplace lets users publish snapshots of their agents, browse published listings, install copies, and rate them.

List listings

Query parameters

Example response

Publish an agent

Publishes a snapshot of one of the caller’s own agents. Only the agent’s owner can publish it.

Request body

Example response

Get a listing

Returns the listing plus up to 20 recent ratings.

Example response

Unpublish a listing

Only the publisher can unpublish.

Example response

Install a listing

Clones the listing’s snapshot into a brand-new agent owned by the caller. The creation checklist is re-run; the new agent is standalone (mode: primary, no parent).

Example response

Rate a listing

Request body

Example request

Example response

Agents v1 remote compatibility surface

The /api/agents/v1/* surface mirrors the shape of widely-used remote agent APIs so existing client code can point at Allternit with minimal changes.

Status

Example response

List models

Returns the caller’s agents as model objects.

Example response

Get a model

Example response

Same shape as an item from list models.

List tools

Returns the tools available to the agent profile, including deferred MCP tools and built-in platform tools.

Example response

Search tools

Request body

Example response

Same shape as list tools.

Activate tools

Activates one or more tools for a session, persisting the selection in the session metadata.

Request body

Example request

Example response

Get a response

Retrieves a completed assistant response by response_id, discovered from conversation message metadata.

Example response

Workspace initialization

Initialize agent workspace

Creates the agent’s workspace directory and writes a batch of documents into it. Paths must be relative. Parent directories are created as needed.

Request body

Example request

Example response

Error codes