Skip to main content

Task Management API

/api/task - Task management endpoints, providing HTTP interface version of CLI viben task commands

Overview

The Gateway Task API (/api/task/*) provides a complete HTTP interface for the viben task CLI commands. All endpoints reuse the CLI's core implementation, only converting input/output formats.

Design Principles:

  1. Reuse CLI core functions - Gateway endpoints directly call functions in task/ops/*
  2. snake_case parameters - All request/response parameters use snake_case format
  3. workspace_path required - Most endpoints require workspace_path to specify workspace
  4. POST requests - CLI-style endpoints uniformly use POST method

Endpoint List

CategoryEndpointsCLI Corresponding Commands
CRUDlist, create, view, deleteviben task list/create/view/delete
Lifecyclepause, resume, approve, reject, retry, cancelviben task pause/resume/approve/reject/retry/cancel
Queue Managementenqueue, dequeue, queue-status, batch-enqueue, queue-config, clear-historyviben task enqueue/dequeue
Configurationset-branch, set-base, set-agentviben task set-branch/set-base/set-agent
Context Managementinit-context, add-context, remove-context, list-context, validate-contextviben task init-context/add-context/...
Execution Controlstart, execute, stop, runningviben task start
Phase Commandsplan-phase, implement-phase, check-phase, work-phase, plan (legacy)viben task plan-phase/...
Reviewreview, context, status, create-prviben task review/context/status/create-pr
Archivefinish, archive, list-archiveviben task finish/archive/list-archive
Worktreecreate-worktree, validate-check-phase-passed, cleanupviben task create-worktree/cleanup
Events/Streamingevents, specs, events-stream, execution-stream-
Sessionadd-sessionviben task add-session

CRUD Endpoints

POST /api/task/list

List tasks.

Request Body:

{
"workspace_path": "/path/to/workspace",
"status": "backlog",
"mine": false
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
statusstringNoFilter by status
minebooleanNoOnly show current developer's tasks

Response:

{
"success": true,
"tasks": [
{
"name": "add-user-auth",
"status": "backlog",
"priority": "P2",
"assignee": "john"
}
]
}

POST /api/task/create

Create a new task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"title": "Add user authentication",
"slug": "add-user-auth",
"assignee": "john",
"priority": "P1",
"agent": "coding-assistant",
"executor": "CLAUDE_CODE",
"model": "claude-sonnet-4-20250514",
"branch": "feature/user-auth",
"worktree": true,
"start": false
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
titlestringYesTask title
slugstringNoTask identifier, defaults to generated from title
assigneestringNoAssignee
prioritystringNoPriority (P0/P1/P2/P3)
agentstringNoAssociated agent ID
executorstringNoExecutor type
modelstringNoModel ID
branchstringNoGit branch name
worktreebooleanNoWhether to use worktree
startbooleanNoAuto-start after creation

Response:

{
"success": true,
"task_dir": ".viben/tasks/03-15-add-user-auth",
"task": { ... }
}

POST /api/task/view

View task details.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Response:

{
"success": true,
"task": {
"id": "add-user-auth",
"title": "Add user authentication",
"status": "backlog",
...
}
}

POST /api/task/delete

Delete a task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"force": false
}

Lifecycle Endpoints

POST /api/task/pause

Pause a task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

State Transition: queue / in_progress -> paused


POST /api/task/resume

Resume a paused task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

State Transition: paused -> original state (queue or in_progress)


POST /api/task/approve

Approve a task under review.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

State Transition: review -> completed


POST /api/task/reject

Reject task, return to backlog.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"reason": "Needs more test coverage"
}

State Transition: review -> backlog


POST /api/task/retry

Retry a failed task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

State Transition: failed -> queue


POST /api/task/cancel

Cancel a task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"reason": "Requirements changed",
"force": false
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
task_idstringYesTask identifier
reasonstringNoCancellation reason
forcebooleanNoForce cancel task in in_progress state

State Transition: * -> cancelled


Queue Management Endpoints

POST /api/task/enqueue

Add task to queue.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"agent": "my-agent",
"executor": "CLAUDE_CODE",
"model": "claude-sonnet-4-20250514",
"priority": "P1"
}

State Transition: backlog -> queue


POST /api/task/dequeue

Remove task from queue.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

State Transition: queue -> backlog


POST /api/task/queue-status

Get queue status.

Request Body:

{
"workspace_path": "/path/to/workspace"
}

Response:

{
"success": true,
"running": [],
"pending": [],
"active_count": 0,
"pending_count": 0,
"config": {
"max_concurrent": 4
}
}

POST /api/task/batch-enqueue

Batch enqueue multiple tasks.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_ids": ["task-1", "task-2", "task-3"],
"executor": "CLAUDE_CODE"
}

POST /api/task/queue-config

Get or update queue configuration.

Request Body:

{
"workspace_path": "/path/to/workspace",
"max_concurrent": 4
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
max_concurrentnumberNoMaximum concurrent tasks (omit to read current config)

POST /api/task/clear-history

Clear execution history.

Request Body:

{
"workspace_path": "/path/to/workspace"
}

Configuration Endpoints

POST /api/task/set-branch

Set task's Git branch.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"branch": "feature/user-auth"
}

POST /api/task/set-base

Set PR target branch.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"branch": "develop"
}

POST /api/task/set-agent

Set associated agent configuration.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"agent": "coding-assistant"
}

Context Management Endpoints

POST /api/task/init-context

Initialize empty context files.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Created files:

  • implement.jsonl - Implementation phase context
  • check.jsonl - Check phase context
  • fix.jsonl - Fix phase context

POST /api/task/add-context

Add context files.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"files": ["src/auth/index.ts", "docs/api.md"],
"reason": "API reference documentation",
"recursive": false
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
task_idstringYesTask identifier
filesstring[]YesFile path list
reasonstringNoReason for adding
recursivebooleanNoRecursively add directory

POST /api/task/remove-context

Remove context files.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"files": ["src/old-file.ts"]
}

POST /api/task/list-context

List context entries.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Response:

{
"success": true,
"entries": [
{
"file": "src/auth/index.ts",
"reason": "Main authentication module"
}
]
}

POST /api/task/validate-context

Validate that context files exist.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Response:

{
"success": true,
"valid": true,
"missing": []
}

Execution Control Endpoints

POST /api/task/start

Start task execution (standard entry point).

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"executor": "CLAUDE_CODE",
"detach": true,
"worktree": false,
"resume": false,
"session_id": null
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
task_idstringYesTask identifier
executorstringNoExecutor type
detachbooleanNoRun in background (default true)
worktreebooleanNoRun in worktree
resumebooleanNoResume existing session
session_idstringNoSpecify session ID (used with resume)

Executor Types: CLAUDE_CODE, CURSOR, GEMINI, OPENCODE, IFLOW, CODEX, KILO, KIRO, ANTIGRAVITY


POST /api/task/execute

Execute task through queue system.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"executor": "CLAUDE_CODE",
"wait": false,
"worktree": false
}

POST /api/task/stop

Stop task execution.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

POST /api/task/running

Check task execution status.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Response:

{
"success": true,
"running": true,
"pid": 12345,
"elapsed": "5m 32s"
}

Phase Command Endpoints

POST /api/task/plan-phase

Run Plan phase.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"platform": "claude",
"verbose": false
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
task_idstringYesTask identifier
platformstringNoPlatform (claude/cursor/iflow/opencode)
verbosebooleanNoVerbose output

POST /api/task/implement-phase

Run Implement phase.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"platform": "claude",
"verbose": false
}

POST /api/task/check-phase

Run Check phase.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"platform": "claude",
"verbose": false
}

POST /api/task/work-phase

Run Work phase (auto-creates worktree).

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"platform": "claude",
"verbose": false,
"detach": true
}

POST /api/task/plan

Run Plan phase (legacy endpoint, same as plan-phase).

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"platform": "claude",
"verbose": false
}
note

This is a legacy endpoint maintained for backward compatibility. Prefer using POST /api/task/plan-phase instead.


Review Endpoints

POST /api/task/review

Get task review information.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Response:

{
"success": true,
"review": {
"title": "Add user authentication",
"status": "review",
"priority": "P1",
"pr_url": "https://github.com/org/repo/pull/123",
"branch": "feature/user-auth",
"files_changed": 12,
"additions": 425,
"deletions": 89
}
}

POST /api/task/context

Get task context (for AI).

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"format": "json"
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
task_idstringYesTask identifier
formatstringNoOutput format (json/text), default json

POST /api/task/status

Get task status details.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"detail": false
}

Response:

{
"success": true,
"status": "in_progress",
"phase": "implement",
"elapsed": "5m 32s",
"running": true,
"pid": 12345
}

POST /api/task/create-pr

Create Pull Request.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"dry_run": false
}

Response:

{
"success": true,
"pr_url": "https://github.com/org/repo/pull/123"
}

Archive Endpoints

POST /api/task/finish

Complete a task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

POST /api/task/archive

Archive a completed task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Archives to archive/YYYY-MM/ directory.


POST /api/task/list-archive

List archived tasks.

Request Body:

{
"workspace_path": "/path/to/workspace",
"month": "2026-03"
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
monthstringNoSpecify month (YYYY-MM), list all if not provided

Worktree Endpoints

POST /api/task/create-worktree

Create Git worktree for a task.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"skip_prd": false
}

POST /api/task/validate-check-phase-passed

Validate if Check phase passed.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"output": "Agent output text...",
"output_file": null
}

POST /api/task/cleanup

Clean up worktree and related resources.

Request Body:

{
"workspace_path": "/path/to/workspace",
"branch": "feature/user-auth",
"keep_branch": false,
"yes": false,
"merged": false,
"all": false,
"list": false
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
branchstringNoSpecify branch (mutually exclusive with merged/all/list)
keep_branchbooleanNoDon't delete Git branch
yesbooleanNoSkip confirmation
mergedbooleanNoClean all merged worktrees
allbooleanNoClean all worktrees
listbooleanNoOnly list worktrees

Event/Streaming Endpoints

POST /api/task/events

Get task event history.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Response:

{
"success": true,
"events": [
{
"type": "QUEUE",
"timestamp": "2026-03-15T10:00:00Z",
"data": {}
}
]
}

POST /api/task/specs

Get task PRD/subtasks/logs.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth"
}

Response:

{
"success": true,
"prd": "# PRD Content...",
"subtasks": [],
"logs": []
}

GET /api/task/events-stream

SSE event subscription.

Query Parameters:

ParameterTypeDescription
workspace_pathstringWorkspace path
task_idstringTask identifier

Response Format: text/event-stream

data: {"type": "task", "task": {...}}

data: {"type": "event", "event": {...}}

GET /api/task/execution-stream

SSE execution progress stream.

Query Parameters:

ParameterTypeDescription
workspace_pathstringWorkspace path
task_idstringTask identifier

Session Endpoints

POST /api/task/add-session

Add session record to task log.

Request Body:

{
"workspace_path": "/path/to/workspace",
"task_id": "add-user-auth",
"title": "Implement login feature",
"commit": "abc1234",
"summary": "Completed basic login flow"
}

Field Description:

FieldTypeRequiredDescription
workspace_pathstringYesWorkspace path
task_idstringYesTask identifier
titlestringYesSession title
commitstringNoAssociated commit hash
summarystringNoSession summary

State Transition Table

EndpointAllowed Starting StatesTarget State
/api/task/enqueuebacklogqueue
/api/task/dequeuequeuebacklog
/api/task/pausequeue, in_progresspaused
/api/task/resumepausedqueue or in_progress
/api/task/approvereviewcompleted
/api/task/rejectreviewbacklog
/api/task/retryfailedqueue
/api/task/cancelbacklog, queue, paused, in_progress*, reviewcancelled

*in_progress state requires force: true parameter


Error Codes

HTTP StatusError TypeDescription
400ValidationErrorInvalid request parameters
404NotFoundErrorTask not found
409StateErrorIllegal state transition
500InternalErrorInternal server error

Implementation File Locations

FileDescription
packages/core/src/gateway/routes/task.tsGateway endpoint implementation
packages/core/src/task/ops/lifecycle.tsLifecycle operations
packages/core/src/task/ops/config.tsConfiguration operations
packages/core/src/task/ops/context-files.tsContext file operations
packages/core/src/task/ops/context-output.tsContext output
packages/core/src/task/ops/crud.tsCRUD operations
packages/core/src/task/ops/review.tsReview operations
packages/core/src/task/ops/create-pr.tsPR creation
packages/core/src/task/ops/session.tsSession records
packages/core/src/task/phase/*.tsPhase execution functions