REST API Reference
Manage workers, assign tasks, handle approvals, and query evidence programmatically. All endpoints live at https://api.agentfarms.in/v1.
Authentication
All API requests require a Bearer token. Generate one from Workspace → Settings → API Keys.
# All requests require this header
Authorization: Bearer af_live_xxxxxxxxxxxxxxxxxxxx
# Base URL
https://api.agentfarms.in/v1Keep your key secret
af_live_. Rotate from Settings if exposed.Error format
All errors return a consistent JSON body:
{
"error": {
"code": "validation_error",
"message": "worker_id is required",
"field": "worker_id"
}
}| Field | Type | Description |
|---|---|---|
400 | Bad Request | Missing or invalid parameters |
401 | Unauthorized | Missing or invalid API key |
403 | Forbidden | API key lacks access to this resource |
404 | Not Found | Resource does not exist |
409 | Conflict | Re-deciding an already-decided approval |
429 | Rate Limited | Too many requests — retry with backoff |
Workers
Workers are role-based AI agents deployed into your workspace. Each worker has a defined role, tool access, and approval threshold.
List workers
/v1/workersReturn all workers in the workspace.
| Parameter | Type | Description |
|---|---|---|
status | string | Filter: active | paused | failed | provisioning |
role | string | Filter by role slug (e.g. backend-developer) |
limitdefault: 20 | number | Results per page (1–100) |
cursor | string | Pagination cursor from previous response |
{
"workers": [
{
"id": "wkr_01HXYZ",
"name": "Rex",
"role": "backend-developer",
"status": "active",
"approval_threshold": "medium",
"tasks_completed": 47,
"tasks_active": 1,
"created_at": "2026-05-01T09:00:00Z"
}
],
"has_more": false,
"cursor": null
}Create a worker
/v1/workersDeploy a new worker. Provisioning takes 30–60 seconds.
| Parameter | Type | Description |
|---|---|---|
namerequired | string | Display name for this worker (e.g. Rex) |
rolerequired | string | Role slug — see worker roles reference |
workspace_idrequired | string | Workspace to deploy into |
repo_ids | string[] | Repo IDs the worker may access (code roles) |
approval_thresholddefault: medium | low | medium | high | Minimum risk level that triggers approval |
persona | object | { display_name, email } — worker identity in connected tools |
{
"name": "Rex",
"role": "backend-developer",
"workspace_id": "ws_01HXYZ",
"repo_ids": ["repo_abc123"],
"approval_threshold": "medium",
"persona": {
"display_name": "Rex",
"email": "rex@yourcompany.com"
}
}{
"worker": {
"id": "wkr_01HXYZ",
"name": "Rex",
"role": "backend-developer",
"status": "provisioning",
"created_at": "2026-05-30T09:00:00Z"
}
}Get a worker
/v1/workers/:idGet full worker details including status and usage stats.
{
"worker": {
"id": "wkr_01HXYZ",
"name": "Rex",
"role": "backend-developer",
"status": "active",
"approval_threshold": "medium",
"connectors": ["github", "jira", "slack"],
"tasks_completed": 47,
"tasks_active": 1,
"tasks_failed": 2,
"last_active_at": "2026-05-30T08:55:00Z",
"created_at": "2026-05-01T09:00:00Z"
}
}Update a worker
/v1/workers/:idUpdate worker name, approval threshold, or persona.
| Parameter | Type | Description |
|---|---|---|
name | string | New display name |
approval_threshold | low | medium | high | Updated approval threshold |
persona | object | Updated persona fields |
Retire a worker
/v1/workers/:idRetire a worker. Active tasks complete before removal.
{ "success": true }Tasks
Tasks are units of work assigned to a worker. The worker plans, executes, and captures evidence for every task.
Assign a task
/v1/tasksAssign a task to an active worker.
| Parameter | Type | Description |
|---|---|---|
worker_idrequired | string | Target worker |
descriptionrequired | string | Natural language task description. Be specific and bounded. |
repo_id | string | Repository context for code tasks |
prioritydefault: normal | low | normal | high | Task priority affecting queue order |
metadata | object | Arbitrary key/value metadata attached to this task |
webhook_url | string | Override webhook URL for this task only |
{
"worker_id": "wkr_01HXYZ",
"description": "Fix the /api/users email validation. Return clear 400 errors for invalid formats. Add or update tests.",
"repo_id": "repo_abc123",
"priority": "normal",
"metadata": { "jira_ticket": "ENG-482" }
}{
"task": {
"id": "tsk_01ABCD",
"status": "queued",
"worker_id": "wkr_01HXYZ",
"priority": "normal",
"estimated_completion": "2026-05-30T09:20:00Z",
"created_at": "2026-05-30T09:01:00Z"
}
}Get task status
/v1/tasks/:idPoll task status, progress, and outputs.
{
"task": {
"id": "tsk_01ABCD",
"status": "completed",
"worker_id": "wkr_01HXYZ",
"progress": 1.0,
"risk_level": "medium",
"actions_taken": 7,
"approvals_required": 1,
"approvals_granted": 1,
"outputs": {
"pr_url": "https://github.com/org/repo/pull/482",
"pr_title": "Fix: email validation in /api/users",
"tests_added": 3
},
"evidence_url": "https://api.agentfarms.in/v1/evidence?task_id=tsk_01ABCD",
"started_at": "2026-05-30T09:02:00Z",
"completed_at": "2026-05-30T09:18:00Z"
}
}List tasks
/v1/tasksList tasks with optional filters.
| Parameter | Type | Description |
|---|---|---|
worker_id | string | Filter by worker |
status | string | Filter: queued | planning | executing | awaiting_approval | completed | failed | cancelled |
from | ISO 8601 | Created-at start range |
to | ISO 8601 | Created-at end range |
limitdefault: 20 | number | Results per page (1–100) |
Cancel a task
/v1/tasks/:id/cancelCancel a queued or in-progress task. Evidence is preserved.
{ "success": true }Approvals
When a worker reaches an action above your approval threshold, it pauses and creates an approval request.
List approvals
/v1/approvalsList approval requests in your workspace.
| Parameter | Type | Description |
|---|---|---|
statusdefault: pending | string | pending | approved | rejected | expired |
worker_id | string | Filter by worker |
risk_level | string | Filter by risk: low | medium | high |
limitdefault: 20 | number | Results per page |
{
"approvals": [
{
"id": "apr_01HXYZ",
"task_id": "tsk_01ABCD",
"worker_id": "wkr_01HXYZ",
"action_type": "merge_pr",
"risk_level": "medium",
"status": "pending",
"action_payload": {
"pr_url": "https://github.com/org/repo/pull/482",
"pr_title": "Fix: auth timeout in billing retries",
"files_changed": 3
},
"expires_at": "2026-05-31T09:00:00Z"
}
]
}Decide on an approval
/v1/approvals/:idApprove or reject a pending action. Decisions are final (409 on re-decision).
| Parameter | Type | Description |
|---|---|---|
decisionrequired | approved | rejected | Your decision |
note | string | Optional feedback for the worker on rejection |
{
"decision": "approved",
"note": "Looks good — proceed with the merge."
}{
"approval": {
"id": "apr_01HXYZ",
"status": "approved",
"decided_at": "2026-05-30T09:15:00Z"
}
}Evidence
Query evidence
/v1/evidenceQuery the append-only evidence trail.
| Parameter | Type | Description |
|---|---|---|
task_id | string | Filter to a specific task |
worker_id | string | Filter to a specific worker |
event_type | string | Filter by event type (e.g. action.executed) |
from | ISO 8601 | Start of time range |
to | ISO 8601 | End of time range |
limitdefault: 50 | number | Results per page (1–500) |
Export evidence
/v1/evidence/exportExport a full evidence bundle as JSON or CSV.
| Parameter | Type | Description |
|---|---|---|
task_id | string | Export for a specific task |
from | ISO 8601 | Export range start |
to | ISO 8601 | Export range end |
formatdefault: json | json | csv | Export format |
Connectors
List connectors
/v1/connectorsList configured connectors and health status.
Add a connector
/v1/connectorsAdd a new connector. See the Connectors guide for per-tool setup.
Remove a connector
/v1/connectors/:idRemove a connector and revoke its credentials.
Rate limits
| Field | Type | Description |
|---|---|---|
Starter+ | 60 req/min | 100 tasks/day |
Pro+ | 300 req/min | 500 tasks/day |
Enterprise | Custom | Unlimited tasks |
Rate limit headers on every response: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.