Skip to content

Agents API

All agent endpoints. Agents belong to a workspace and represent a running Claude Code session.

Create agent

POST /api/workspaces/:id/agents

Creates and starts a new agent in the specified workspace.

Request body:

FieldTypeRequiredDescription
rolestringyesAgent role (e.g. "code", "review")
taskstringnoInitial task message. Falls back to role template default
bypassbooleannoSkip permission prompts (default false)
spawnedBystringnoID of the agent that requested this spawn
allowDuplicatebooleannoAllow multiple agents with the same role (default false)

Response: 201 with the created AgentSession object.

Returns 409 if a duplicate role already exists and allowDuplicate is false.


Send message

POST /api/agents/:id/send

Sends a follow-up message to a running agent.

Request body:

FieldTypeRequiredDescription
messagestringconditionalText message (required if no attachments)
attachmentsAttachmentData[]noFile attachments (image or document)
effortstringnoOverride effort level for this turn
modelstringnoOverride model for this turn

Response: 200 { ok: true, agentId: string }


Stop agent

POST /api/agents/:id/stop

Interrupts a running agent. Aborts the SDK conversation, drains pending delegation queues, and sets status to idle.

Response: 200 { ok: true }


Compact context

POST /api/agents/:id/compact

Triggers SDK context compaction for the agent. Fails with 409 if the agent is currently working.

Response: 200 { ok: true }


Send slash command

POST /api/agents/:id/command

Sends a slash command to the agent (e.g. /compact, /clear).

Request body:

FieldTypeRequiredDescription
commandstringyesSlash command starting with /

Response: 200 { ok: true }

Fails with 409 if the agent is busy.


Reopen agent

POST /api/agents/:id/reopen

Reopens a closed (history) agent, moving it back to the active list.

Response: 200 with the AgentSession object.


Update agent

PATCH /api/agents/:id

Updates agent configuration fields.

Request body (all optional):

FieldTypeDescription
customNamestringDisplay name override
modelstringModel override
effortstringEffort level: "low", "medium", or "high"
bypassbooleanPermission bypass
cleanModebooleanShow only agent/user messages in UI
isOrchestratorbooleanEnable orchestrator capabilities
canSpawnSubagentsbooleanAllow SDK Agent tool usage

Response: 200 with the updated AgentSession.


Delete agent

DELETE /api/agents/:id

Closes the agent and moves it to history.

Response: 200 { ok: true }


Get agent log (paginated)

GET /api/agents/:id/log?limit=50&offset=0

Returns paginated log entries for the agent. Entries are returned in chronological order, newest at the end.

Query parameters:

ParamDefaultDescription
limit50Number of entries to return
offset0Offset from the end of the log

Response:

json
{
  "total": 120,
  "limit": 50,
  "offset": 0,
  "entries": [ ... ]
}

Delegate task

POST /api/agents/delegate

Delegates a task from an orchestrator agent to another agent by role. Only orchestrator agents can delegate.

Request body:

FieldTypeRequiredDescription
fromstringyesOrchestrator agent ID
tostringyesTarget role name
toIdstringnoSpecific target agent ID
taskstringyesTask description
modelstringnoModel override for the target agent

Response: 200 with delegation result. Returns 403 if the source agent is not an orchestrator.


Get agent pool

GET /api/agents/pool?workspaceId=xxx

Returns all active agents with sessions, optionally filtered by workspace.

Query parameters:

ParamRequiredDescription
workspaceIdnoFilter by workspace

Response:

json
[
  {
    "id": "abc123",
    "role": "code",
    "status": "idle",
    "currentTask": "...",
    "workspaceId": "ws1",
    "queueSize": 0
  }
]

Create spawn request

POST /api/agents/spawn-request

Requests spawning multiple agents. Requires user approval via the UI.

Request body:

FieldTypeRequiredDescription
fromAgentIdstringyesRequesting agent ID
rolesstring[]yesRoles to spawn
tasksstring[]yesTask for each role
reasonstringnoReason for the request

Response: 201 { requestId: string }


Respond to spawn request

POST /api/agents/spawn-request/:id/respond

Approves or denies a pending spawn request.

Request body:

FieldTypeRequiredDescription
approvedbooleanyesWhether to approve
maxCountnumbernoMax agents to spawn
approvedRolesstring[]noSubset of roles to approve

Response: 200 { ok: true, status, maxCount, approvedRoles }

Released under the MIT License.