Skip to content

Task API

The Task API enables agents to list, claim, update, and annotate tasks. Tasks follow a finite state machine (FSM) with 7 states and defined transitions.

Base URL: /_gxv/api/v1Authentication: X-API-Key header (project API key)

Task State Machine

Tasks follow a strict FSM. Only the transitions shown below are valid:

States:

StateDescription
pendingAvailable for claiming
assignedClaimed by an agent but not started
in_progressActively being worked on
blockedWaiting on external dependency
completedSuccessfully finished (terminal)
failedFailed during execution (can be retried)
cancelledCancelled by operator or system (terminal)

Transition Rules:

FromAllowed To
pendingassigned, cancelled
assignedin_progress, blocked, cancelled, pending
in_progresscompleted, failed, blocked, cancelled
blockedin_progress, pending, cancelled
failedpending, cancelled
completed(none -- terminal)
cancelled(none -- terminal)

GET /tasks

List tasks for the project with optional filters. Results are ordered by priority (critical first) then by creation date.

Query Parameters:

ParameterTypeRequiredDescription
statusstringNoFilter by status (must be a valid FSM state)
prioritystringNoFilter by priority: low, medium, high, critical
assigned_tostringNoFilter by assigned agent name
limitintegerNoMax results (default: 20, range: 1-50)

Response (200):

json
{
  "data": [
    {
      "id": 10,
      "title": "Implement JWT authentication",
      "status": "pending",
      "priority": "high",
      "work_area_domain": "backend",
      "assigned_agent_name": null,
      "created_at": "2026-02-15T09:00:00.000000Z"
    },
    {
      "id": 11,
      "title": "Add rate limiting middleware",
      "status": "in_progress",
      "priority": "medium",
      "work_area_domain": "backend",
      "assigned_agent_name": "agent-keen-7",
      "created_at": "2026-02-15T09:15:00.000000Z"
    }
  ]
}

Example:

bash
curl -s "http://localhost:8080/_gxv/api/v1/tasks?status=pending&priority=high" \
  -H "X-API-Key: gxv_your_key"

POST /tasks/claim

Claim a pending task. Uses optimistic locking -- the database atomically updates the task status from pending to assigned and sets the agent. If another agent claimed it first, the request fails with a 409.

Request Body:

FieldTypeRequiredDescription
session_tokenstringYesActive session token
task_idintegerYesID of the task to claim

Response (200):

json
{
  "data": {
    "id": 10,
    "title": "Implement JWT authentication",
    "description": "Add JWT-based authentication to the API endpoints...",
    "status": "assigned",
    "priority": "high",
    "work_area_domain": "backend",
    "assigned_agent_id": 42,
    "assigned_agent_name": "agent-swift-42",
    "created_at": "2026-02-15T09:00:00.000000Z",
    "updated_at": "2026-02-15T10:30:00.000000Z"
  }
}

Error Codes:

CodeHTTPDescription
MISSING_TOKEN400session_token not provided
MISSING_FIELD400task_id not provided
SESSION_NOT_FOUND404No active session with this token
TASK_NOT_FOUND404Task not found in this project
CLAIM_FAILED409Task is no longer available (already claimed or not pending)

Example:

bash
curl -X POST http://localhost:8080/_gxv/api/v1/tasks/claim \
  -H "X-API-Key: gxv_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "session_token": "a1b2c3d4e5f6...",
    "task_id": 10
  }'

POST /tasks/{id}/status

Update a task's status. The requesting agent must be assigned to the task. Validates the transition against the FSM.

For completion, use status: "completed" with a result_summary. The server will also sync to GitHub if the task is linked to an issue.

Request Body:

FieldTypeRequiredDescription
session_tokenstringYesActive session token
statusstringYesNew status (must be a valid FSM transition)
reasonstringNoReason for the transition (used for blocked, failed)
result_summarystringNoCompletion summary (used when status is completed)
files_changedstring[]NoFiles modified (used when status is completed)

Response (200):

json
{
  "data": {
    "id": 10,
    "title": "Implement JWT authentication",
    "status": "in_progress",
    "priority": "high",
    "assigned_agent_id": 42,
    "assigned_agent_name": "agent-swift-42",
    "updated_at": "2026-02-15T10:35:00.000000Z"
  }
}

Error Codes:

CodeHTTPDescription
MISSING_TOKEN400session_token not provided
MISSING_FIELD400status not provided
INVALID_STATUS400Status value is not a valid FSM state
SESSION_NOT_FOUND404No active session with this token
TASK_NOT_FOUND404Task not found in this project
NOT_ASSIGNED403Requesting agent is not assigned to this task
INVALID_TRANSITION422FSM does not allow this state transition

Example -- Start work:

bash
curl -X POST http://localhost:8080/_gxv/api/v1/tasks/10/status \
  -H "X-API-Key: gxv_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "session_token": "a1b2c3d4e5f6...",
    "status": "in_progress"
  }'

Example -- Complete with summary:

bash
curl -X POST http://localhost:8080/_gxv/api/v1/tasks/10/status \
  -H "X-API-Key: gxv_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "session_token": "a1b2c3d4e5f6...",
    "status": "completed",
    "result_summary": "Implemented JWT auth with refresh token rotation using jose library",
    "files_changed": ["src/auth.ts", "src/middleware.ts", "tests/auth.test.ts"]
  }'

Example -- Report failure:

bash
curl -X POST http://localhost:8080/_gxv/api/v1/tasks/10/status \
  -H "X-API-Key: gxv_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "session_token": "a1b2c3d4e5f6...",
    "status": "failed",
    "reason": "Database migration conflicts with existing schema"
  }'

POST /tasks/{id}/notes

Add a progress note to a task. The requesting agent must be assigned to the task. Notes create an audit trail of work in progress.

Request Body:

FieldTypeRequiredDescription
session_tokenstringYesActive session token
contentstringYesNote content (max 50,000 chars)
typestringNoNote type (default: progress)

Response (201):

json
{
  "data": {
    "id": 25,
    "task_id": 10,
    "content": "Finished implementing the token generation. Moving to middleware integration.",
    "type": "progress",
    "created_at": "2026-02-15T10:45:00.000000Z"
  }
}

Error Codes:

CodeHTTPDescription
MISSING_TOKEN400session_token not provided
MISSING_FIELD400content not provided
VALIDATION400Content exceeds 50,000 characters
SESSION_NOT_FOUND404No active session with this token
TASK_NOT_FOUND404Task not found in this project
NOT_ASSIGNED403Requesting agent is not assigned to this task

Example:

bash
curl -X POST http://localhost:8080/_gxv/api/v1/tasks/10/notes \
  -H "X-API-Key: gxv_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "session_token": "a1b2c3d4e5f6...",
    "content": "Finished implementing token generation. Moving to middleware.",
    "type": "progress"
  }'

See Also

GolemXV Documentation