# API Reference

A small REST API for driving the Task Manager from your own code: create a task, start it, and pull back its status and results.

## Authentication

Every request needs an API key sent as a Bearer token. Create one under **Settings → API**, then include it on every request:

```
Authorization: Bearer tm_live_...
```

Keys aren't scoped yet — anyone with a key can create, start, and read any task. Treat it like a password and store it server-side, not in a public client.

## Base URL

All endpoints are relative to your own deployment's origin, e.g. `http://localhost:3000/api/v1`.

## Errors

Errors return a non-2xx status with a JSON body shaped like:

```json
{
  "error": {
    "message": "No task found with id '...'.",
    "code": "not_found"
  }
}
```

## Create a task

`POST /api/v1/tasks`

Creates a task. By default it's queued immediately (`autoStart: true`) and the worker picks it up on its next poll (within ~5s). Pass `autoStart: false` to create it disabled and start it later with the start endpoint below.

Review-only tickets: pass `reviewOnly: true` to create a reminder to review work done somewhere else (a commit pushed by hand, another Claude session) instead of an agent task. It goes straight to In Review (`status: 'completed'`, `reviewStatus: 'in_review'`), the worker never picks it up and it spends no tokens. The description says what to review and why (e.g. the commit message); attach what to look at in `reviewMetadata`. Run options (`repos`, `autoStart: false`, schedules, teams, dependencies, subtasks) are rejected on it. Approving moves it to Done as usual. Request changes is refused (409) — there's no agent run to continue, so create a normal task on the referenced branch instead. Start/re-run is refused the same way.

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string | yes | What the agent should do. The only required field. |
| `title` | string |  | Short title. Derived from the description when omitted. |
| `context` | string |  | Extra background/instructions kept separate from the description. |
| `repos` | array |  | Repos to check out: [{ alias, url, branch? }]. Required unless outputType is 'file', 'design' or 'result'. |
| `outputType` | string |  | 'repository' (default), 'file', 'design', or 'result' (agent's answer shown inline on the task page — no files or commits). |
| `priority` | string |  | 'low' \| 'normal' (default) \| 'high' \| 'urgent'. |
| `effort` | string |  | 'low' \| 'medium' \| 'high' \| 'xhigh' \| 'max'. Omit to use the provider default. |
| `model` | string |  | Override model id. Omit to use the configured default. |
| `toolAccess` | object |  | Per-task external tool access, e.g. { "github-cli": true } to let the agent use the GitHub CLI, or false to deny it. Tools left out follow Settings → Agent Tools. |
| `labels` | array |  | Freeform string labels, e.g. ["bug", "backend"]. |
| `pushToMain` | boolean |  | Push directly to the default branch instead of opening a PR. |
| `createPR` | boolean |  | Open a pull request when the task finishes. |
| `targetBranch` | string |  | Branch to base work/PRs off of. Defaults to the repo's default branch. |
| `tokenBudget` | number |  | Kill the task if it exceeds this many tokens. |
| `costBudget` | number |  | Kill the task if estimated cost exceeds this (USD). |
| `allowSubtasks` | boolean |  | Let the agent split the work into follow-up tasks of its own, created when it finishes (e.g. one task per item it discovered). Subtasks inherit this task's repos and settings and can't create further subtasks. Defaults to false. |
| `autoStart` | boolean |  | Queue immediately. Defaults to true; pass false to start it later. |
| `notes` | string |  | Private notes on the task (not shown to the agent). |
| `reviewOnly` | boolean |  | true = a review-only ticket: created straight into In Review, never run by an agent. See above. |
| `reviewMetadata` | object |  | Review-only tickets: { repo?, branch?, commits?, prUrl? }, all optional. repo: a saved repo's URL or any Git URL; branch: a branch name; commits: an array of commit SHAs (7–40 hex chars, short or full, stored as given); prUrl: an http(s) link to the PR. A bad value is a 400 naming the field, e.g. 'reviewMetadata.commits'. |

**Example request body**

```json
{
  "description": "Add a health check endpoint at /api/health that returns { ok: true }.",
  "repos": [
    {
      "alias": "app",
      "url": "https://github.com/your-org/your-repo.git"
    }
  ],
  "priority": "normal",
  "createPR": true
}
```

**Example response (201)**

```json
{
  "data": {
    "id": "clx1a2b3c0000",
    "title": "Add a health check endpoint at /api/health...",
    "description": "Add a health check endpoint at /api/health that returns { ok: true }.",
    "status": "pending",
    "outputType": "repository",
    "priority": "normal",
    "effort": null,
    "repos": [
      {
        "alias": "app",
        "url": "https://github.com/your-org/your-repo.git",
        "branch": null
      }
    ],
    "branchName": null,
    "commitSha": null,
    "prUrl": null,
    "prNumber": null,
    "createdAt": "2026-08-01T12:00:00.000Z",
    "updatedAt": "2026-08-01T12:00:00.000Z"
  }
}
```

## Start a task

`POST /api/v1/tasks/{id}/start`

Queues a task for the worker: sets it enabled, status 'pending', and clears any retry/schedule delay so it's picked up on the very next poll. Mainly for tasks created with `autoStart: false`, but works on any non-running task — including kicking a failed/paused one back into the queue. Returns 409 if the task is already running.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Task id, from the create-task response. |

**Example response (200)**

```json
{
  "data": {
    "id": "clx1a2b3c0000",
    "status": "pending",
    "updatedAt": "2026-08-01T12:00:05.000Z"
  }
}
```

## Get a task

`GET /api/v1/tasks/{id}`

Fetches a task's current status and results: branch/commit/PR info for repository tasks, generated files for file/design tasks, and token/cost usage. Pass `?logs=true` to include the full run log.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Task id. |

**Query parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `logs` | boolean |  | Include the full TaskLog history. Defaults to false. |

**Example response (200)**

```json
{
  "data": {
    "id": "clx1a2b3c0000",
    "status": "completed",
    "outputType": "repository",
    "branchName": "task/clx1a2b3c0000",
    "commitSha": "a1b2c3d",
    "prUrl": "https://github.com/your-org/your-repo/pull/42",
    "prNumber": 42,
    "inputTokens": 18342,
    "outputTokens": 2110,
    "estimatedCost": 0.41,
    "files": [],
    "updatedAt": "2026-08-01T12:04:32.000Z"
  }
}
```

## Update a task

`PATCH /api/v1/tasks/{id}`

Edits a task's ticket fields — title, description, context, priority, labels and notes — and, on a review-only ticket, its `reviewMetadata`. Only the fields you send change; inside `reviewMetadata` only the keys you send change, and `null`, `""` or `[]` clears one. Description and context can't change while the task is running. Run settings (repos, provider, schedule, …) are edited from the UI or the MCP update_task tool.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Task id. |

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string |  | New title. Empty falls back to the start of the description. |
| `description` | string |  | New description. Can't be empty. |
| `context` | string |  | New context; null clears it. |
| `priority` | string |  | 'low' \| 'normal' \| 'high' \| 'urgent'. |
| `labels` | array |  | Replaces the labels; null or [] clears them. |
| `notes` | string |  | Replaces the notes; null clears them. |
| `reviewMetadata` | object |  | Review-only tickets: { repo?, branch?, commits?, prUrl? } — same rules as on create. |

**Example request body**

```json
{
  "reviewMetadata": {
    "commits": [
      "65948886",
      "a1b2c3d4e5"
    ],
    "prUrl": "https://github.com/your-org/your-repo/pull/42"
  }
}
```

**Example response (200)**

```json
{
  "data": {
    "id": "clx1a2b3c0000",
    "title": "Show the executive summary read-only until the poster chooses Edit",
    "status": "completed",
    "reviewStatus": "in_review",
    "reviewOnly": true,
    "reviewMetadata": {
      "repo": "git@github.com:your-org/your-repo.git",
      "branch": "develop",
      "commits": [
        "65948886",
        "a1b2c3d4e5"
      ],
      "prUrl": "https://github.com/your-org/your-repo/pull/42"
    }
  }
}
```

## List tasks

`GET /api/v1/tasks`

Lists tasks, most recent first. Recurring templates are excluded.

**Query parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `q` | string |  | Free text found in the title, description or context, or a commit SHA / PR URL (review metadata and agents' commits and PRs). |
| `reviewOnly` | boolean |  | true = only review-only tickets; false = only agent tasks. |
| `status` | string |  | Filter to one status, e.g. 'pending', 'running', 'completed', 'failed'. |
| `limit` | number |  | Max results, 1-100. Defaults to 20. |

**Example response (200)**

```json
{
  "data": [
    {
      "id": "clx1a2b3c0000",
      "title": "Add a health check endpoint",
      "status": "completed"
    }
  ]
}
```

## List a task's output files

`GET /api/v1/tasks/{id}/files`

Lists the files a task produced in its workspace. Defaults to the `output` directory, where file and design tasks write their results. Pass `?recursive=true` to walk the whole tree in one call instead of a request per directory level.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Task id. |

**Query parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `path` | string |  | Directory to list, relative to the workspace. Defaults to 'output'. |
| `recursive` | boolean |  | Walk subdirectories too. Defaults to false. |

**Example response (200)**

```json
{
  "data": {
    "path": "output",
    "entries": [
      {
        "name": "findings.json",
        "path": "output/findings.json",
        "type": "file",
        "size": 8213,
        "modifiedAt": "2026-08-01T12:04:32.000Z"
      }
    ]
  }
}
```

## Read a task's output file

`GET /api/v1/tasks/{id}/files/content`

Returns the contents of one text file from a task's workspace. This is how a caller that created a file-output task collects the result: poll GET /api/v1/tasks/{id} until the status is terminal, then read the file the task was asked to write. Binary files and anything over 5MB are refused.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Task id. |

**Query parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `path` | string | yes | File path relative to the workspace, e.g. 'output/findings.json'. |

**Example response (200)**

```json
{
  "data": {
    "path": "output/findings.json",
    "content": "{\"findings\": []}",
    "size": 17,
    "modifiedAt": "2026-08-01T12:04:32.000Z"
  }
}
```
