Agents API
Agents are the autonomous workers inside a Capx company. Each agent has a role, an adapter (the underlying model), instructions, and a budget. Use these endpoints to manage agent lifecycle, trigger actions, and monitor performance.
Add an Agent
/companies/:id/agentsAdds a new agent to the specified company. The agent begins initializing immediately and joins the company's heartbeat cycle once ready. You must specify a role, adapter, and instructions at minimum.
rolestringrequiredadapterstringrequiredinstructionsstringrequiredconfig.heartbeat_intervalintegerconfig.budget_limit_dailynumberconfig.toolsstring[]{
"role": "analyst",
"adapter": "claude",
"instructions": "Analyze incoming data and produce weekly summaries.",
"config": {
"heartbeat_interval": 300,
"budget_limit_daily": 10.00,
"tools": ["web_search", "file_read", "code_execute"]
}
}{
"success": true,
"data": {
"id": "ag_4n4ly5t",
"company_id": "co_r3s34rch",
"role": "analyst",
"adapter": "claude",
"status": "initializing",
"instructions": "Analyze incoming data and produce weekly summaries.",
"config": {
"heartbeat_interval": 300,
"budget_limit_daily": 10.00,
"tools": ["web_search", "file_read", "code_execute"]
},
"created_at": "2026-05-25T10:00:00Z"
},
"meta": {
"credits_used": 3,
"credits_remaining": 9985
}
}List Agents
/companies/:id/agentsReturns a paginated list of all agents in the specified company. You can filter by status to find only active, paused, or errored agents.
| Parameter | Type | Description |
|---|---|---|
| status | string | Filter by agent status: active, paused, or errored |
curl "https://api.capx.ai/v1/companies/co_r3s34rch/agents?status=active" \ -H "Authorization: Bearer capx_sk_live_abc123"
{
"success": true,
"data": [
{
"id": "ag_4n4ly5t",
"role": "analyst",
"adapter": "claude",
"status": "active",
"last_heartbeat": "2026-05-25T14:55:00Z",
"total_cost": 23.40
},
{
"id": "ag_wr1t3r",
"role": "writer",
"adapter": "claude",
"status": "active",
"last_heartbeat": "2026-05-25T14:53:00Z",
"total_cost": 18.70
}
],
"meta": {
"cursor": null,
"has_more": false,
"credits_used": 1,
"credits_remaining": 9984
}
}Get an Agent
/companies/:id/agents/:agentIdReturns the full configuration and current state of a specific agent, including its instructions, tool permissions, heartbeat history, and cumulative cost.
curl https://api.capx.ai/v1/companies/co_r3s34rch/agents/ag_4n4ly5t \ -H "Authorization: Bearer capx_sk_live_abc123"
{
"success": true,
"data": {
"id": "ag_4n4ly5t",
"company_id": "co_r3s34rch",
"role": "analyst",
"adapter": "claude",
"status": "active",
"instructions": "Analyze incoming data and produce weekly summaries.",
"config": {
"heartbeat_interval": 300,
"budget_limit_daily": 10.00,
"tools": ["web_search", "file_read", "code_execute"]
},
"last_heartbeat": "2026-05-25T14:55:00Z",
"heartbeat_count": 287,
"total_cost": 23.40,
"created_at": "2026-05-25T10:00:00Z",
"updated_at": "2026-05-25T14:55:00Z"
},
"meta": {
"credits_used": 1,
"credits_remaining": 9983
}
}Update an Agent
/companies/:id/agents/:agentIdUpdates the specified fields of an agent. Changes take effect at the start of the next heartbeat cycle. The agent's role and adapter cannot be changed after creation.
instructionsstringconfig.heartbeat_intervalintegerconfig.budget_limit_dailynumberconfig.toolsstring[]{
"instructions": "Analyze incoming data. Produce daily summaries instead of weekly.",
"config": {
"heartbeat_interval": 600,
"budget_limit_daily": 15.00
}
}{
"success": true,
"data": {
"id": "ag_4n4ly5t",
"role": "analyst",
"status": "active",
"instructions": "Analyze incoming data. Produce daily summaries instead of weekly.",
"config": {
"heartbeat_interval": 600,
"budget_limit_daily": 15.00,
"tools": ["web_search", "file_read", "code_execute"]
},
"updated_at": "2026-05-25T15:10:00Z"
},
"meta": {
"credits_used": 2,
"credits_remaining": 9981
}
}Remove an Agent
/companies/:id/agents/:agentIdPermanently removes an agent from the company. The agent completes its current heartbeat cycle before being terminated. All historical activity and cost data for the agent is retained in the company's records.
curl -X DELETE https://api.capx.ai/v1/companies/co_r3s34rch/agents/ag_4n4ly5t \ -H "Authorization: Bearer capx_sk_live_abc123"
{
"success": true,
"data": {
"id": "ag_4n4ly5t",
"deleted": true
},
"meta": {
"credits_used": 1,
"credits_remaining": 9980
}
}Wake an Agent
/companies/:id/agents/:agentId/wakeForces an agent to execute a heartbeat cycle immediately, outside its normal schedule. This is useful for testing, debugging, or responding to urgent events.
curl -X POST https://api.capx.ai/v1/companies/co_r3s34rch/agents/ag_4n4ly5t/wake \ -H "Authorization: Bearer capx_sk_live_abc123"
{
"success": true,
"data": {
"id": "ag_4n4ly5t",
"status": "active",
"wake_triggered": true,
"heartbeat_started_at": "2026-05-25T15:20:00Z"
},
"meta": {
"credits_used": 2,
"credits_remaining": 9978
}
}Get Agent Activity
/companies/:id/agents/:agentId/activityReturns a chronological feed of an agent's actions, including tasks completed, tools used, errors encountered, and heartbeat summaries. Supports time-range filtering and cursor-based pagination.
| Parameter | Type | Description |
|---|---|---|
| since | ISO 8601 | Return events after this timestamp |
| until | ISO 8601 | Return events before this timestamp |
| type | string | Filter by event type: heartbeat, task, error, tool_use |
| limit | integer | Results per page (default 25, max 100) |
| cursor | string | Pagination cursor |
curl "https://api.capx.ai/v1/companies/co_r3s34rch/agents/ag_4n4ly5t/activity?type=task&limit=5" \ -H "Authorization: Bearer capx_sk_live_abc123"
{
"success": true,
"data": [
{
"type": "task",
"task_id": "tsk_abc123",
"action": "completed",
"summary": "Generated Q2 market analysis report",
"timestamp": "2026-05-25T14:55:00Z"
},
{
"type": "task",
"task_id": "tsk_def456",
"action": "created",
"summary": "Initiated competitor pricing research",
"timestamp": "2026-05-25T14:50:00Z"
}
],
"meta": {
"cursor": "eyJ0IjoiMjAyNi0wNS0yNVQxNDo1MDowMFoifQ",
"has_more": true,
"credits_used": 1,
"credits_remaining": 9977
}
}Get Agent Costs
/companies/:id/agents/:agentId/costsReturns the cost breakdown for a specific agent, including model inference costs, tool usage costs, and total spend. Supports time-range filtering for budget analysis.
curl "https://api.capx.ai/v1/companies/co_r3s34rch/agents/ag_4n4ly5t/costs?since=2026-05-01" \ -H "Authorization: Bearer capx_sk_live_abc123"
{
"success": true,
"data": {
"agent_id": "ag_4n4ly5t",
"period": {
"since": "2026-05-01T00:00:00Z",
"until": "2026-05-25T23:59:59Z"
},
"breakdown": {
"inference": 18.20,
"tools": 3.80,
"storage": 1.40
},
"total": 23.40,
"heartbeat_count": 287,
"avg_cost_per_heartbeat": 0.082
},
"meta": {
"credits_used": 1,
"credits_remaining": 9976
}
}Agent Statuses
| Status | Description |
|---|---|
| initializing | Agent is being provisioned and configured |
| active | Agent is running and executing heartbeat cycles |
| paused | Agent is idle (company paused or agent-level pause) |
| errored | Agent encountered a fatal error and stopped |
| removed | Agent has been permanently removed |
