Skip to main content
A
Docs

Agents API reference

Endpoints, request and response examples, and errors for the Agents API: agents, runs, traces, approvals and templates.

Authentication

Send a token as Authorization: Bearer <token>. Read API conventions.

Endpoints

MethodPathPurposeRole
GET/api/v1/agentsList agentsAny
POST/api/v1/agentsCreate an agentadmin
GET/api/v1/agents/{agent_id}Get an agentAny
PUT/api/v1/agents/{agent_id}Change an agentadmin
DELETE/api/v1/agents/{agent_id}Delete an agentadmin
POST/api/v1/agents/batch-deleteDelete more than one agentadmin
POST/api/v1/agents/{agent_id}/cloneCopy an agentadmin
POST/api/v1/agents/{agent_id}/publishPublish an agent so that people can run itadmin
POST/api/v1/agents/{agent_id}/archiveArchive an agentadmin
POST/api/v1/agents/{agent_id}/pausePause an agent. New runs are refused until you resume it.admin, manager, officer
POST/api/v1/agents/{agent_id}/resumeResume a paused agentadmin, manager, officer
POST/api/v1/agents/{agent_id}/runRun an agent and wait for the resultAny
POST/api/v1/agents/{agent_id}/streamRun an agent and stream its stepsAny
GET/api/v1/agents/{agent_id}/runsList the runs of an agentAny
GET/api/v1/agents/{agent_id}/historyRun history of an agentAny
GET/api/v1/agents/{agent_id}/tracesList the traces of an agentAny
GET/api/v1/agents/{agent_id}/traces/{run_id}Get the trace of a runAny
GET/api/v1/agents/{agent_id}/metricsMetrics of an agentAny
GET/api/v1/runs/{run_id}Get a runAny
POST/api/v1/runs/{run_id}/stopStop a runadmin, manager, officer
GET/api/v1/approvalsList runs that wait for a person, oldest firstAny
GET/api/v1/approvals/{run_id}Get the pending action of a runAny
POST/api/v1/approvals/{run_id}/decideApprove, edit or reject the pending actionadmin, manager, officer
GET/api/v1/executionsList runs of all agentsAny
GET/api/v1/agents/templatesList pre-built agent templatesAny
GET/api/v1/agents/templates/{template_id}Get a templateAny
POST/api/v1/agents/templates/{template_id}/deployCreate an agent from a templateAny
GET/api/v1/agents/toolsList the tools that agents can useAny
GET/api/v1/agents/tools/{tool_name}Get a toolAny
GET/api/v1/auditRead the agent audit logAny
GET/api/v1/stats/overviewOverview statisticsAny
POST/api/v1/playground/chatTry an agent in the playgroundAny
GET/api/v1/healthHealth checkNone

Run an agent

curl https://agents.example.gov/api/v1/agents/$AGENT_ID/run \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"input": "What documents do I need to renew a trade licence?", "max_steps": 8}'
FieldTypeRequiredMeaning
inputstringYesThe task. Up to 10,000 characters.
contextobjectNoExtra data for the run
max_stepsintegerNoThe maximum number of model rounds for this run, 1 to 100
reasoning_effortstringNolow, medium or high, for models that support it

Response

{
  "id": "run_5c1e",
  "agent_id": "citizen_inquiry_agent",
  "input": "What documents do I need to renew a trade licence?",
  "output": "...",
  "status": "completed",
  "steps_count": 3,
  "total_tokens": 1840,
  "duration_ms": 5210
}

When a run reaches a consequential tool, its status shows that it waits for approval. Get it from GET /api/v1/approvals.

Decide on an approval

Send the decision to POST /api/v1/approvals/{run_id}/decide. You need the officer, manager or admin role.

{"decision": "edit", "arguments": {"channel": "Registered employee portal"}, "reason": "Use the portal, not email."}
FieldMeaning
decisionapprove, edit or reject
argumentsThe changed tool arguments, for edit
reasonWhy you decided. It goes into the audit log.

Errors

StatusCause
403Your role cannot change agents or decide approvals
404The agent or run does not exist
409The agent is not published, or it is paused