Tasks
Tasks are independently managed tasks that can participate in a Chain. Chain membership does not transfer a Task's lifecycle: physical Chain cleanup detaches the Task and preserves its own files. Delete a Task separately when needed. Generated task content also remains subject to its producing run's original context permissions; moving or sharing it does not remove those limits. See Chain retention and Project context.
Tasks support multiple views: tree, matrix, calendar, and gantt. Executing a Task requires an applicable executable source.
Endpoints
These are the published Task API routes. Every request requires an access token; AI execution and Agent binding also require their applicable permissions.
| Method | Path | Description |
|---|---|---|
| POST | /bits | Create a task, optionally in a Chain or Project |
| POST | /bits/insert-all | Bulk create tasks |
| GET | /bits/tree | Read the flat Task graph |
| GET | /bits/matrix | Read grouped matrix tasks |
| GET | /bits/calendar | Read scheduled tasks within a required date range |
| GET | /bits/gantt | Read Project-grouped tasks within a required date range |
| GET | /bits/gantt/:chainyId | Read one Project's tasks within a required date range |
| GET | /bits/:id | Get a task |
| PATCH | /bits/:id | Update a task |
| DELETE | /bits/:id | Delete a task |
| POST | /bits/:id/execute | Execute a task through AI |
| POST | /bits/:bitId/executions | Bind an Agent to a task |
| POST | /bits/:bitId/events | Record a completion event |
| GET | /chains/:chainId/events | Read a Chain's completion events |
| POST | /bits/:bitId/relations/connect | Connect two tasks |
Developer token access
A developer token can call these routes directly as a Bearer token when it carries the matching scope. Every other Bit route refuses a developer token with 403, whatever scopes it carries.
| Scope | Routes |
|---|---|
bits:read | GET /bits/:id, GET /bits/tree, GET /bits/calendar, GET /bits/gantt/:chainyId |
bits:write | POST /bits, PATCH /bits/:id (including Project placement, completion and assignees) |
A token without the required scope receives 403. Deleting or executing a Bit is not available to developer tokens; use a signed-in session for those.
Task Execution Context
A Task's execution can consume authorized file context. Context access rules remain effective; attaching a resource does not broaden who can read it. Direct AI execution also requires active paid subscription coverage and the applicable AI permissions. Without active coverage, the request is rejected with 403 and error code subscription_inactive.
Create Task
Request
All fields are optional. A Task can exist without a Chain or Project. The examples attach one to an existing Chain; omit chainId for a standalone task.
| Field | Type | Required | Description |
|---|---|---|---|
id | UUID | No | Optional caller-generated ID. Retrying with the same ID returns the existing Task. |
title | string | No | Title, up to 1,024 characters. |
note | string | No | Task content, up to 10 MiB (10,485,760 bytes) of UTF-8 text. |
pages | object[] | No | Ordered notebook, at most 200 pages. Page content takes precedence over note. |
chainId | UUID | No | Optional Chain membership. A Chain holds at most 1,000 Tasks: creating one into a full Chain is refused with 422 and the error code chain_step_limit_exceeded, and nothing is created. |
chainyId | UUID | No | Optional Project association. |
parentId | UUID | No | Parent Task for nesting. |
priority | string | No | p1, p2, p3, or p4. |
status | string | No | pending, completed, skipped, failed, archived, or deleted; defaults to pending. |
publishState | string | No | draft or published; defaults to published. |
scheduledDate | string or null | No | Start date, YYYY-MM-DD. |
scheduledTime | string or null | No | Start time, HH:mm or HH:mm:ss. |
scheduledToDate | string or null | No | End date, YYYY-MM-DD. |
scheduledToTime | string or null | No | End time, HH:mm or HH:mm:ss. |
isAllDay | boolean | No | All-day schedule. Defaults to true when no start time is supplied. |
waitingOn | string or null | No | human, external, system, approval, dependency, or event. |
waitingExpectedBy | string or null | No | ISO 8601 date-time. |
stageId | UUID | No | Kanban stage. |
stageOrder | integer | No | Stage position, at least zero. |
x, y | integer | No | Layout coordinates. |
viewKey | string | No | Layout view. |
assigneeIds | UUID[] | No | Up to 20 distinct assignee IDs (UUID v4). Supersedes the older single assigneeId. |
assigneeId | UUID | No | Deprecated single-assignee field; prefer assigneeIds. |
A notebook page requires id (UUID), title (up to 1,024 characters), content, and ISO 8601 createdAt and updatedAt. Its optional attachments array contains at most 200 strings. The titles and contents of all pages together hold up to 10 MiB of UTF-8 text.
When creating or updating a Task, a note, or its pages together, larger than 10 MiB is refused with 413 and error code bits.text_too_large, and a request body larger than 12 MiB with 413. Saving a large note also counts toward your account: a save that would take your notes past your account's storage allocation is refused with 403 and storage_quota_exceeded, and exceeding the hourly write budget for large notes is refused with 429 and bits.text_write_budget_exhausted, whose retryAfterSeconds says when to try again. While other large notes are being saved, the request may receive 503 with a Retry-After header; retry after that many seconds.
An all-day schedule does not include times. A timed schedule supplies the start date/time and end date/time, with the end no earlier than the start. Without a start date, leave every schedule date/time unset.
Response
Selected fields from the created Task; IDs and revisions are illustrative. Detail responses also include edit capability, publication, assignment and completion metadata.
{
"data": {
"id": "00000000-0000-4000-8000-000000000001",
"title": "Study verb conjugations - present tense",
"chainId": "00000000-0000-4000-8000-000000000010",
"note": "Focus on regular -ar, -er, -ir verb conjugations",
"priority": "p2",
"status": "pending",
"parentId": null,
"scheduledDate": "2030-03-18",
"scheduledTime": null,
"scheduledToDate": "2030-03-18",
"scheduledToTime": null,
"isAllDay": true,
"pages": [],
"createdBy": { "kind": "human", "agentId": null },
"revision": 1
}
}createdBy records who created the Task. The server sets it when the Task is created and it never changes: a create or update request that sends createdBy is refused with 400. kind is, for example, human for a person using Chainabit or the API, chao_automated for Chao working without an agent, or mcp_client for an external app connected through MCP. agentId is null when the creator is not an agent.
Code Examples
The examples already use the API address. Set TOKEN to your access token and CHAIN_ID to the data.id returned by Create Chain. Chain membership is optional; remove that field when creating an independent Task.
curl -X POST https://api.chainabit.com/api/v1/bits \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Study verb conjugations - present tense",
"chainId": "'"$CHAIN_ID"'",
"note": "Focus on regular -ar, -er, -ir verb conjugations",
"priority": "p2",
"scheduledDate": "2030-03-18",
"scheduledToDate": "2030-03-18",
"isAllDay": true
}'Bulk Create Tasks
Request
Supply titles for simple title-only creation or bits for complete create objects. Each array accepts at most 40 entries. Optional top-level chainId and chainyId apply common membership to the batch; omit them for independent tasks. If the batch would take the Chain past 1,000 Tasks, the whole request is refused with 422 and the error code chain_step_limit_exceeded, and no task is inserted.
Response
For three newly inserted tasks:
{
"data": {
"insertedCount": 3,
"insertedIds": [
"00000000-0000-4000-8000-000000000002",
"00000000-0000-4000-8000-000000000003",
"00000000-0000-4000-8000-000000000004"
],
"skippedTitles": [],
"duplicates": []
}
}Code Examples
These examples reuse CHAIN_ID from Create Task.
curl -X POST https://api.chainabit.com/api/v1/bits/insert-all \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"chainId": "'"$CHAIN_ID"'",
"bits": [
{
"title": "Practice listening comprehension"
},
{
"title": "Write 5 sentences in Spanish"
},
{
"title": "Read a news article in Spanish"
}
]
}'Tree View
Request
Authenticated read of the Task graph. The response is a flat bits array plus relations, rather than nested children arrays.
Response
{
"data": {
"bits": [
{
"id": "00000000-0000-4000-8000-000000000001",
"title": "Study verb conjugations - present tense",
"parentId": null,
"childCount": 0,
"status": "pending",
"priority": "p2"
}
],
"relations": []
},
"meta": {
"limit": 20,
"offset": 0,
"total": 1,
"hasNextPage": false
}
}Code Examples
curl "https://api.chainabit.com/api/v1/bits/tree" \
-H "Authorization: Bearer $TOKEN"Matrix View
Response
Quadrant names are grouping labels. They do not execute or delete a task.
{
"data": {
"matrix": {
"DO": [],
"SCHEDULE": [
{
"id": "00000000-0000-4000-8000-000000000001",
"title": "Study verb conjugations - present tense",
"priority": "p2"
}
],
"DELEGATE": [],
"DELETE": [],
"INBOX": [],
"ARCHIVE": []
},
"totals": {
"all": 1,
"byQuadrant": {
"DO": 0,
"SCHEDULE": 1,
"DELEGATE": 0,
"DELETE": 0,
"INBOX": 0,
"ARCHIVE": 0
}
}
},
"meta": {
"limit": 20,
"offset": 0,
"total": 1,
"hasNextPage": false
}
}Code Examples
curl "https://api.chainabit.com/api/v1/bits/matrix" \
-H "Authorization: Bearer $TOKEN"Calendar View
Request
from and to are required ISO date-times or YYYY-MM-DD dates. Optional chainyId restricts the read to a Project.
Response
A flat array of scheduled Tasks, with pagination metadata:
{
"data": [
{
"id": "00000000-0000-4000-8000-000000000001",
"title": "Study verb conjugations - present tense",
"scheduledDate": "2030-03-18",
"scheduledToDate": "2030-03-18",
"scheduledTime": null,
"scheduledToTime": null,
"isAllDay": true
}
],
"meta": {
"limit": 20,
"offset": 0,
"total": 1,
"hasNextPage": false
}
}Code Examples
curl "https://api.chainabit.com/api/v1/bits/calendar?from=2030-03-01&to=2030-03-31" \
-H "Authorization: Bearer $TOKEN"Gantt View
Request
from and to are required ISO date-times or YYYY-MM-DD dates. The Project-scoped variant uses /bits/gantt/:chainyId, where chainyId is a readable Project's ID. Both reads apply the same date range.
Response
The global response groups tasks by Project. Independent tasks appear in a group whose id is null. The scoped read returns one Project group.
{
"data": [
{
"id": null,
"title": "No Project",
"status": null,
"visibility": null,
"colorHex": null,
"targetDate": null,
"bits": [
{
"id": "00000000-0000-4000-8000-000000000001",
"title": "Study verb conjugations - present tense",
"chainyId": null,
"parentId": null,
"status": "pending",
"isAllDay": true,
"scheduledDate": "2030-03-18",
"scheduledTime": null,
"scheduledToDate": "2030-03-18",
"scheduledToTime": null,
"completedAt": null
}
]
}
],
"meta": {
"limit": 50,
"offset": 0,
"total": 1,
"hasNextPage": false
}
}Code Examples
curl "https://api.chainabit.com/api/v1/bits/gantt?from=2030-03-01&to=2030-03-31" \
-H "Authorization: Bearer $TOKEN"For a Project-scoped read, set CHAINY_ID from Create Project:
curl "https://api.chainabit.com/api/v1/bits/gantt/$CHAINY_ID?from=2030-03-01&to=2030-03-31" \
-H "Authorization: Bearer $TOKEN"Task Completion Events
Record self-attested completion evidence for an accessible Task. An event does not change the Task's status or make the task independently verified. The service derives the current authorized Chain membership, including no membership for a standalone Task.
Endpoints
| Method | Path | Description | Auth |
|---|---|---|---|
| GET | /chains/:chainId/events | List accessible completion events for a Chain | JWT |
| POST | /bits/:bitId/events | Record self-attested completion evidence | JWT |
Record Completion Event
Request
| Field | Type | Required | Description |
|---|---|---|---|
source | string | Yes | Client source label, 1–64 characters; these examples use user. |
signatureHash | string | Yes | Client signature, 1–256 characters. It does not grant verification. |
chainId | UUID or null | No | Optional assertion of the Task's current Chain membership. Omit to derive it. A supplied mismatch is rejected. |
periodId | UUID | No | Period belonging to the Task's current Chain. Not applicable to standalone Tasks. |
previousEventHash | string | No | Previous client signature, 1–256 characters. |
completedAt | string | No | ISO 8601 timestamp; defaults to the current time. |
evidenceMetadata | object | No | Client evidence, such as notes. This does not grant verification. |
Response
Selected returned fields; this endpoint uses the following field names:
{
"data": {
"id": "00000000-0000-4000-8000-000000000050",
"bit_id": "00000000-0000-4000-8000-000000000001",
"chain_id": "00000000-0000-4000-8000-000000000010",
"completed_at": "2030-03-17T14:30:00.000Z",
"source": "user",
"signature_hash": "study-session-2030-03-17",
"evidence_metadata": {
"notes": "Completed the present tense study session"
}
}
}Code Examples
Set BIT_ID to the data.id from Create Task. These examples work with a standalone Task or one associated with a Chain.
curl -X POST https://api.chainabit.com/api/v1/bits/$BIT_ID/events \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"source": "user",
"signatureHash": "study-session-2030-03-17",
"completedAt": "2030-03-17T14:30:00Z",
"evidenceMetadata": {
"notes": "Completed the present tense study session"
}
}'List Events for a Chain
Set CHAIN_ID to the Chain whose events you can access. Optional limit accepts 1–50, and offset starts at zero. Results are ordered by completion time, newest first.
Response
Selected fields of the returned event array:
{
"data": [
{
"id": "00000000-0000-4000-8000-000000000050",
"bit_id": "00000000-0000-4000-8000-000000000001",
"chain_id": "00000000-0000-4000-8000-000000000010",
"completed_at": "2030-03-17T14:30:00.000Z",
"source": "user",
"signature_hash": "study-session-2030-03-17"
}
]
}Code Examples
curl https://api.chainabit.com/api/v1/chains/$CHAIN_ID/events \
-H "Authorization: Bearer $TOKEN"Task Execution Profiles
An execution profile binds an authorized Agent instance to a Task. It defines execution mode and limits. Creating the binding does not itself execute the Task.
Endpoints
| Method | Path | Description | Auth |
|---|---|---|---|
| POST | /bits/:bitId/executions | Create an Agent execution binding | JWT + Agent management permission |
Create Execution Profile
Request
| Field | Type | Required | Description |
|---|---|---|---|
agentInstanceId | UUID | Yes | An Agent instance you are permitted to bind. |
executionMode | string | No | auto or scheduled_agent; defaults to auto. |
modelId | UUID | No | Entitled model override. Otherwise an active default is selected. |
featureKey | string | No | Applicable billing feature. |
retryPolicy | object | No | Retry configuration. |
timeoutSeconds | integer | No | Timeout, at least zero. |
maxRetries | integer | No | Retry limit, at least zero. |
priority | integer | No | Execution priority, at least zero. |
isActive | boolean | No | Whether the binding is active. |
acknowledgeBilledUnattended | boolean | With scheduled_agent | true, sent after the person has seen that the Agent will run the Task on its own and that those runs are billed. See Billed unattended execution. |
Set BIT_ID from Create Task and AGENT_INSTANCE_ID to an Agent instance you are permitted to manage. GET /agents/instances/available returns available instances with their id; binding one also requires the applicable Task, Agent and workspace permissions.
Billed unattended execution
scheduled_agent lets the Agent run the Task on its own, without you present, and those runs are billed. The request succeeds only from a signed-in session that sends acknowledgeBilledUnattended: true after the person has seen that notice. Without it, or from a caller that cannot show the notice (the Chainabit CLI and MCP clients), the API answers 403 with the error code approval_required and creates nothing. The person approves it in the Chainabit web app, or asks Chao to do it. auto is not affected.
{
"error": {
"code": "approval_required",
"message": "Show the billed unattended notice and confirm it before continuing.",
"details": { "implications": ["runs_unattended", "runs_are_billed"] }
}
}A request that confirms the notice:
curl -X POST https://api.chainabit.com/api/v1/bits/$BIT_ID/executions \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"agentInstanceId": "'"$AGENT_INSTANCE_ID"'",
"executionMode": "scheduled_agent",
"acknowledgeBilledUnattended": true,
"isActive": true
}'Response
Selected returned fields; this endpoint uses the following field names:
{
"data": {
"id": "00000000-0000-4000-8000-000000000020",
"bit_id": "00000000-0000-4000-8000-000000000001",
"agent_instance_id": "00000000-0000-4000-8000-000000000030",
"execution_mode": "auto",
"retry_policy": {},
"timeout_seconds": null,
"max_retries": 0,
"priority": 100,
"is_active": true
}
}Code Examples
curl -X POST https://api.chainabit.com/api/v1/bits/$BIT_ID/executions \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"agentInstanceId": "'"$AGENT_INSTANCE_ID"'",
"executionMode": "auto",
"isActive": true
}'Task Relations
Define a directed relationship between two accessible Tasks. A blocking relation can prevent its target from proceeding. Blocking dependency, sequence, and conditional relations require both Tasks to belong to the same Chain, or both to be standalone. Relationships that create a dependency cycle are rejected.
Endpoints
| Method | Path | Description | Auth |
|---|---|---|---|
| POST | /bits/:bitId/relations/connect | Connect two Tasks | JWT |
Connect Two Tasks
Request
| Field | Type | Required | Description |
|---|---|---|---|
fromBitId | UUID | Yes | Source Task; use the same ID in the path. |
toBitId | UUID | Yes | Target Task. |
relationType | string | Yes | dependency, sequence, parallel, conditional, ai_trigger, or reference; these examples use dependency. |
isBlocking | boolean | No | Whether the relationship blocks its target; defaults to true. |
weight | integer | No | Optional relationship weight. |
metadata | object | No | Optional relationship metadata. |
BIT_ID identifies the source and TARGET_BIT_ID identifies another accessible Task.
Response
{
"data": {
"id": "00000000-0000-4000-8000-000000000040",
"fromBitId": "00000000-0000-4000-8000-000000000001",
"toBitId": "00000000-0000-4000-8000-000000000002",
"relationType": "dependency",
"isBlocking": true,
"createdAt": "2030-03-17T12:00:00.000Z",
"updatedAt": "2030-03-17T12:00:00.000Z"
}
}Code Examples
curl -X POST https://api.chainabit.com/api/v1/bits/$BIT_ID/relations/connect \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"fromBitId": "'"$BIT_ID"'",
"toBitId": "'"$TARGET_BIT_ID"'",
"relationType": "dependency",
"isBlocking": true
}'