# Agents API

A2A agent gateway (ADR 0103). Agents are declared in YAML; clients call them here with a gateway key holding agents:invoke, from a team the agent allows.

## GET /v1/agents

`GET /v1/agents` · operation `listAgents`

Agents the key may invoke (agents:invoke and a team the agent allows), with gateway URLs. Requires a2a_agents.

**Authentication:** `bearerAuth`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | List of agents with url and card_url pointing to this gateway | — |
| `401` | Missing or invalid key | — |
| `403` | Key without agents:invoke | — |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |


## POST /a2a/{agent_id}

`POST /a2a/{agent_id}` · operation `invokeAgent`

A2A JSON-RPC 2.0, forwarded as sent with the agent credential (never exposed) and the A2A-Version header. Methods: 0.3 (message/send, message/stream, tasks/get, tasks/cancel, tasks/resubscribe, agent/getAuthenticatedExtendedCard) and 1.0 (SendMessage, SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, GetExtendedAgentCard). Push notification configs are not proxied (-32601). Streams come back as SSE. Task and context IDs in an answer to a message are bound to the calling key's team; with organization_admins, a call naming a task or context of another team, or a task ID the gateway never handed to the team, answers 404 with JSON-RPC error -32001 before reaching the agent, and ListTasks keeps only the team's tasks and drops totalSize (T192). Redirects from the agent are refused. Bodies up to 4 MiB.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `agent_id` | path | string, required, max length 63 |  |

**Request body** (required)

- `application/json`: object
  - `jsonrpc` (`"2.0"`, required)
  - `id` (any)
  - `method` (string, required)
  - `params` (object)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | JSON-RPC result or error (-32600 invalid request, -32601 method not proxied, -32603 agent unavailable or redirected), or an SSE stream | — |
| `401` | Missing or invalid key | — |
| `403` | Key without agents:invoke | — |
| `404` | Feature disabled, or an agent that does not exist or that the key's team may not use (same answer); with organization_admins, a task or context of another team (JSON-RPC -32001) | — |
| `413` | Body over 4 MiB | — |
| `503` | With organization_admins, task ownership could not be read (JSON-RPC -32603) | — |


## GET /a2a/{agent_id}/.well-known/agent-card.json

`GET /a2a/{agent_id}/.well-known/agent-card.json` · operation `getAgentCard`

The agent card with every JSON-RPC interface pointing to this gateway (gRPC/REST interfaces removed) and the gateway key as the security scheme, in the 0.3 or 1.0 shape of the upstream card. Cached five minutes.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `agent_id` | path | string, required, max length 63 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Agent card | — |
| `401` | Missing or invalid key | — |
| `404` | Feature disabled or agent not available to the key | — |
| `502` | The agent card could not be read | — |


## GET /a2a/{agent_id}/.well-known/agent.json

`GET /a2a/{agent_id}/.well-known/agent.json` · operation `getAgentCardLegacy`

Same as agent-card.json, at the path older A2A clients use.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `agent_id` | path | string, required, max length 63 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Agent card | — |
| `401` | Missing or invalid key | — |
| `404` | Feature disabled or agent not available to the key | — |
| `502` | The agent card could not be read | — |


## GET /api/v1/admin/agents

`GET /api/v1/admin/agents` · operation `listAgentsAdmin`

Requires providers:read and a2a_agents. Declared agents with URLs (credentials and query strings removed), teams and whether the credential is configured.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Agents, wrapped in data, with the configuration version | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |

Response `200` fields:

- `application/json`: object
  - `version` (integer, required)
  - `data` (array of [Agent](/docs/api/schemas/a/#agent), required)


## PUT /api/v1/admin/agents/{agent_id}

`PUT /api/v1/admin/agents/{agent_id}` · operation `upsertAgent`

Requires providers:manage, a2a_agents and storage. Creates or overrides an agent as a versioned console override (a YAML agent can be overridden). The whole configuration is validated first. secret_env names the environment variable holding the agent credential; the credential itself is never stored or returned.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `agent_id` | path | string, required, max length 63 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer, required)
  - `agent` ([AgentInput](/docs/api/schemas/a/#agentinput), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | New configuration version and the agent | — |
| `400` | Missing version, path mismatch or unknown field | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | version_conflict | — |
| `422` | invalid_agent (URL, teams, auth pair) | — |
| `503` | Storage unavailable | — |


## DELETE /api/v1/admin/agents/{agent_id}

`DELETE /api/v1/admin/agents/{agent_id}` · operation `deleteAgent`

Requires providers:manage. Removes a console agent or reverts a YAML agent to its declaration.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `agent_id` | path | string, required, max length 63 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer, required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | New configuration version | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled or no console override | — |
| `409` | version_conflict | — |


## POST /api/v1/admin/agents/{agent_id}/kill_switch

`POST /api/v1/admin/agents/{agent_id}/kill_switch` · operation `agentKillSwitch`

Requires providers:manage. Disables (or re-enables) an agent at once; a disabled agent answers 404 to every caller.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |
| `agent_id` | path | string, required, max length 63 |  |

**Request body** (required)

- `application/json`: object
  - `version` (integer, required)
  - `disabled` (boolean, required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | New configuration version and the agent | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled or unknown agent | — |
| `409` | version_conflict | — |


## POST /api/v1/admin/agents/{agent_id}/test

`POST /api/v1/admin/agents/{agent_id}/test` · operation `testAgentAdmin`

Requires providers:manage. Reads the agent card now, bypassing the cache, with the agent credential.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |
| `agent_id` | path | string, required, max length 63 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | ok with name, version, protocol_version and skills, or ok false | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled or unknown agent | — |

