Guides
Assistant from code
Ask Taskloader's project assistant from your code: ask, wait for the answer with long-polling, read it, and apply or dismiss its suggested changes.
On this page
Every Taskloader project has an assistant that answers questions about the project ("What is overdue, and who owns it?", "How did last week go?") with text, numbers, charts and task lists, and can suggest changes that a person applies. This guide asks it from code.
| To | You need |
|---|---|
| Ask | The assistant, projects:read and tasks:read scopes, and any role in the project. Without files:read, the answer is written without the names of files, nor hears earlier answers in the conversation that read them. |
| Read answers and conversations | assistant, projects:read and tasks:read as well, because answers quote the project. Conversations are private: each person sees only their own, and they are deleted when the person leaves the project or is removed from it. An answer that read file names needs files:read too, and every answer to a question asked in the app did: without it, get_assistant_message answers 403 insufficient_scope (its requiredScopes include files:read), and get_assistant_thread and list_assistant_messages leave such answers out (a page can hold fewer than limit). |
| Apply suggested changes | assistant plus the scope of each change you apply (tasks:write, and comments:write for comments), and the editor role or above. |
| Dismiss suggestions, delete conversations | assistant. |
Note To answer, the assistant sends the question and the project's data to Taskloader's AI provider, as it does in the app; the Privacy Policy lists exactly what. Questions count against the asker's allowance of 60 questions an hour, shared by the app and every key and connected app. One API key or connected app can ask at most 30 an hour (15 at once).
1. Ask
#POST /projects/{projectId}/assistant/questions| Field | Meaning |
|---|---|
text | The question: 1 to 4,000 characters of plain text. Line breaks (stored as \n, a Windows \r\n counts once) and tabs are fine; other control characters answer 400 validation_failed. |
threadId | Continue an earlier conversation (thr_…): the assistant sees what was said before. Leave it out to start a new one. |
today | The asker's date (YYYY-MM-DD), so "overdue" and "this week" mean what they expect. |
timeZone | The asker's IANA time zone, such as Europe/Berlin, when you do not send today. |
taskKey | A task the question is about, such as TL-012. |
Send an Idempotency-Key: a retried request then asks once, not twice.
curl https://taskloader.com/api/v1/projects/$PROJECT_ID/assistant/questions \
-H "Authorization: Bearer $TASKLOADER_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d "{\"text\":\"What is overdue, and who owns it?\",\"today\":\"$(date +%F)\"}" | tee message.json// assistant.mjs: node assistant.mjs prj_… "What is overdue, and who owns it?" (Node.js 20 or later)
import { randomUUID } from 'node:crypto';
const API = 'https://taskloader.com/api/v1';
const auth = { Authorization: `Bearer ${process.env.TASKLOADER_API_KEY}` };
const [projectId, question] = process.argv.slice(2);
async function read(response) {
const body = await response.json();
if (!response.ok) throw new Error(`${response.status} ${body.code}: ${body.detail}`);
return body;
}
const today = new Date().toLocaleDateString('en-CA'); // YYYY-MM-DD in your time zone
let message = await read(
await fetch(`${API}/projects/${projectId}/assistant/questions`, {
method: 'POST',
headers: { ...auth, 'Content-Type': 'application/json', 'Idempotency-Key': randomUUID() },
body: JSON.stringify({ text: question, today }),
}),
);
console.log(message.id, message.status); // msg_… queued# assistant.py: python3 assistant.py prj_… "What is overdue, and who owns it?"
import datetime
import os
import sys
import uuid
import requests
API = "https://taskloader.com/api/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['TASKLOADER_API_KEY']}"
project_id, question = sys.argv[1:3]
def read(response):
body = response.json()
if not response.ok:
raise RuntimeError(f"{response.status_code} {body['code']}: {body['detail']}")
return body
message = read(session.post(
f"{API}/projects/{project_id}/assistant/questions",
headers={"Idempotency-Key": str(uuid.uuid4())},
json={"text": question, "today": datetime.date.today().isoformat()},
timeout=30,
))
print(message["id"], message["status"]) # msg_… queuedTaskloader answers 202 Accepted at once, with the answer to wait for (a message with status: "queued"), a Location header pointing at it, and Retry-After: 2. The answer itself takes a few seconds.
HTTP/1.1 202 Accepted
Content-Type: application/json
Location: /api/v1/assistant/messages/msg_0b6f1d2a8c9e4f00a1b2c3d4e5f60718
Retry-After: 2
{
"object": "assistant_message",
"id": "msg_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
"threadId": "thr_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
"projectId": "prj_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
"role": "assistant",
"status": "queued",
"steps": [],
"question": null,
"answer": null,
"proposal": null,
"error": null,
"model": "openai/gpt-6-luna",
"usage": null,
"createdAt": "2026-11-18T10:00:00.123Z",
"completedAt": null
}2. Wait for the answer
#Read the message with wait=25. Taskloader holds the request until the answer is ready or failed, or 25 seconds pass, whichever comes first. Repeat until status is ready or failed.
curl "https://taskloader.com/api/v1/assistant/messages/$(jq -r .id message.json)?wait=25" \
-H "Authorization: Bearer $TASKLOADER_API_KEY" \
--max-time 40 | tee answer.json | jq '{status, answer, proposal}'while (message.status === 'queued' || message.status === 'running') {
message = await read(
await fetch(`${API}/assistant/messages/${message.id}?wait=25`, {
headers: auth,
signal: AbortSignal.timeout(40_000),
}),
);
}
if (message.status === 'failed') throw new Error('The assistant could not answer this time.');
console.log(message.answer.title);
for (const block of message.answer.blocks) if (block.type === 'text') console.log(block.markdown);while message["status"] in ("queued", "running"):
message = read(session.get(f"{API}/assistant/messages/{message['id']}", params={"wait": 25}, timeout=40))
if message["status"] == "failed":
raise SystemExit("The assistant could not answer this time.")
print(message["answer"]["title"])
for block in message["answer"]["blocks"]:
if block["type"] == "text":
print(block["markdown"])Taskloader checks for the answer every half second while it holds the request. While the answer is not ready, responses carry Retry-After: 2; without wait, poll no faster than that. Every read of a message counts against your search limit (120 a minute), with or without wait.
3. Read the answer
#A ready message has an answer:
HTTP/1.1 200 OK
Content-Type: application/json
{
"object": "assistant_message",
"id": "msg_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
"threadId": "thr_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
"projectId": "prj_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
"role": "assistant",
"status": "ready",
"steps": [
"Read the project",
"Counted overdue tasks",
"Wrote the answer"
],
"question": null,
"answer": {
"title": null,
"report": false,
"blocks": [
{
"type": "text",
"markdown": "Two tasks are overdue. TL-012 is the one to unblock first."
},
{
"type": "metrics",
"items": [
{
"label": "Overdue",
"value": 2,
"tone": "risk"
}
]
}
],
"suggestions": [
"Who has the most open tasks?"
],
"asOf": "2026-11-18T10:00:09.456Z"
},
"proposal": {
"summary": "Move the launch announcement forward",
"status": "pending",
"digest": "fypj2kPMwmILmn_PgaKh7xKt7SHYIPJzRlmmloEhZv0",
"changes": [
{
"index": 0,
"operation": "update_task",
"preview": {
"kind": "update",
"task": {
"number": 12,
"key": "TL-012",
"title": "Write the launch announcement",
"ref": "northwind/website-launch/TL-012"
},
"fields": [
{
"field": "priority",
"from": "Normal",
"to": "High",
"fromValue": "normal",
"toValue": "high"
}
],
"links": []
},
"result": null
}
]
},
"error": null,
"model": "openai/gpt-6-luna",
"usage": {
"inputTokens": 5210,
"outputTokens": 640
},
"createdAt": "2026-11-18T10:00:00.123Z",
"completedAt": "2026-11-18T10:00:09.456Z"
}| Field | Meaning |
|---|---|
title | A short heading, or null |
blocks | The answer, as a list of typed blocks (below). Render the types you know and skip the rest. |
report | true when the answer is a report, meant to be read, printed or shared on its own |
suggestions | Up to three follow-up questions the person might ask next |
asOf | When the project data behind the answer was read |
Block type | Holds |
|---|---|
text | markdown: paragraphs, lists, emphasis and links |
metrics | items, each with a label, a number value, an optional hint and a tone (neutral, risk or good) |
chart | kind (bar, stacked, donut or line), a title, an optional caption, the palette in colors, and data to draw |
tasks | A title, the tasks it lists (key, title, status and the other fields a task row shows) and how many match in all, total |
callout | A tone (insight, risk or success), a title and markdown |
table | An optional title, columns (headings) and rows (lists of text) |
New block types may be added. Metric, chart and task-list blocks are computed by Taskloader from the project, so their numbers match what the API returns. Text and table blocks are written by the AI model: treat any figure in them as the model's reading of the project.
The message also has steps, what the assistant did while answering, each at most 80 characters ("Read the project", "Searched for “launch”", "Read TL-012", "Counted overdue tasks", "Prepared 2 changes", "Wrote the answer"); usage (inputTokens, outputTokens); and model. A failed message has an error and no answer.
4. Apply or dismiss suggested changes
#When the asker is an editor, an answer can include a proposal: changes the assistant suggests, such as creating tasks, moving them or adding comments. Nothing changes until someone applies them. Answers to viewers never include one.
{
"proposal": {
"summary": "Raise the venue booking, comment on it, and move the press release to review.",
"status": "pending",
"digest": "fypj2kPMwmILmn_PgaKh7xKt7SHYIPJzRlmmloEhZv0",
"changes": [
{
"index": 0,
"operation": "update_task",
"preview": {
"kind": "update",
"task": {
"key": "TL-001",
"ref": "northwind/website-launch/TL-001",
"title": "Book the venue",
"number": 1
},
"fields": [
{
"field": "priority",
"from": "Normal",
"to": "Urgent",
"fromValue": "normal",
"toValue": "urgent"
}
],
"links": []
},
"result": null
},
{
"index": 1,
"operation": "add_comment",
"preview": {
"kind": "comment",
"task": {
"key": "TL-001",
"ref": "northwind/website-launch/TL-001",
"title": "Book the venue",
"number": 1
},
"message": "Raised: the launch depends on it."
},
"result": null
},
{
"index": 2,
"operation": "move_task",
"preview": {
"kind": "move",
"task": {
"key": "TL-002",
"ref": "northwind/website-launch/TL-002",
"title": "Draft the press release",
"number": 2
},
"fields": [
{
"field": "status",
"from": "Backlog",
"to": "In review",
"fromValue": "backlog",
"toValue": "review"
}
]
},
"result": null
}
]
}
}Each change names the operation it will run and a preview to show the person. preview.kind is create, update, move, delete, comment or checklist. A field change carries from and to for people (labels, long text cut short) and fromValue and toValue in API values (status and priority names, mem_ ids, YYYY-MM-DD dates, text). Creates and updates also list the links they add to the task: once the change is applied, Taskloader fetches each of those pages for a preview, so show them to the person too.
Show the changes to the person and apply the ones they choose, by index. Send the proposal's digest back as proposalDigest: Taskloader then applies nothing unless the proposal is still exactly what the person saw.
curl "https://taskloader.com/api/v1/assistant/messages/$(jq -r .id message.json)/proposal/apply" \
-H "Authorization: Bearer $TASKLOADER_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d "{\"changes\":[0,2],\"proposalDigest\":\"$(jq -r .proposal.digest answer.json)\"}"const result = await read(
await fetch(`${API}/assistant/messages/${message.id}/proposal/apply`, {
method: 'POST',
headers: { ...auth, 'Content-Type': 'application/json', 'Idempotency-Key': randomUUID() },
body: JSON.stringify({ changes: [0, 2], proposalDigest: message.proposal.digest }),
}),
);
for (const change of result.results)
console.log(
change.index,
change.ok ? `applied ${change.ref ?? ''}` : `${change.code}: ${change.detail}`,
);result = read(session.post(
f"{API}/assistant/messages/{message['id']}/proposal/apply",
headers={"Idempotency-Key": str(uuid.uuid4())},
json={"changes": [0, 2], "proposalDigest": message["proposal"]["digest"]},
timeout=60,
))
for change in result["results"]:
print(change["index"], "applied" if change["ok"] else f"{change['code']}: {change['detail']}"){
"object": "proposal_result",
"messageId": "msg_0b6f1d2a8c9e4f00a1b2c3d4e5f60718",
"status": "applied",
"results": [
{ "index": 0, "ok": true, "ref": "northwind/website-launch/TL-001", "version": 4 },
{
"index": 2,
"ok": false,
"code": "version_conflict",
"detail": "TL-002 changed since this was proposed, so it was left as it is."
}
]
}changeslists 1 to 40 distinct indexes from the proposal, each smaller than its number of changes; anything else is400 validation_failed. Changes you leave out cannot be applied later: one apply closes the proposal. Read back, they haveresult: null: they were not made.- Before applying anything, Taskloader checks that it is your own conversation, that you are an editor or above (
403 forbidden_roleotherwise), and that the key or app has the scope of every chosen change (403 insufficient_scope, whoserequiredScopeslists them all). Then nothing is applied. - Each change is then applied on its own, through the same operation the API offers, and reports its own result (see below), so a suggestion never overwrites newer work.
- A proposal is applied once. Applying it again, after it was dismissed, or while an apply is still running answers
409 proposal_closed, withproposalStatus. So does an apply whoseproposalDigestis not the proposal'sdigestany more (proposalStatus: "pending"): nothing is applied; read the answer again and show the person its changes. A retried request with the sameIdempotency-Keygets the first answer back once every chosen change has its result; while the changes are still being applied, it answers409 idempotency_key_in_progresswithRetry-After: 1. Retry with the same key, or read the message for each change's result. - If Taskloader runs into a problem on its side part way (a timeout, a database restart), the request answers
503 service_unavailablewithRetry-After: 60, and Taskloader finishes the changes on its own within a minute or two: then read the message for each change's result, and never apply them again. - Applied changes show in task history as made "via Taskloader assistant, applied from" your key or app, for example "via Taskloader assistant, applied from API key “Weekly review”".
What each result means
#A result is { "index": 0, "ok": true } (for a change to a task, with its ref and its new version, to send with the next change to it; comments and deletes have no version, and a key or app without tasks:read, which can only have applied comments, gets no ref, and a detail that says “the task” in place of its key), or ok: false with a code from the error reference and a detail to show the person. The codes you will meet most:
code | Why the change was skipped |
|---|---|
version_conflict | Someone changed the fields it would change since it was proposed ("TL-012 changed since this was proposed, so it was left as it is."), or, for a delete, changed the task at all ("…so it was not deleted."); or a checklist item it ticks, unticks or removes was renamed since ("TL-005’s checklist item “Outline” changed since this was proposed, so the checklist was left as it is."). |
not_found | The task was deleted meanwhile ("TL-005 no longer exists."), or the conversation was deleted while the changes were being applied ("The conversation was deleted while these changes were being applied, so this change was not made."). |
checklist_item_not_found | A checklist item it names is gone ("TL-005 has no checklist item “Outline” any more."). |
assignee_not_member | The person it would assign has left the project. |
invalid_token | Your access was revoked before or while it ran. |
forbidden_role | Your role in the project was lowered while the changes were applied. |
internal_error, service_unavailable | Taskloader ran into a problem on its side applying it, several times over a few minutes, so it was left undone or could not be confirmed (the detail says which). Make it as an ordinary task change if still wanted. |
| Any other code | See the error reference, and show detail to the person. |
A change whose task already holds the proposed values is reported ok.
To decline the suggestions, dismiss them: POST /assistant/messages/{messageId}/proposal/dismiss answers { "object": "proposal", "messageId": "msg_…", "status": "dismissed" }. A proposal that is not pending any more answers 409 proposal_closed.
Conversations
#Pass the message's threadId with the next question to continue the conversation, in the same project (a conversation from another project answers 400 validation_failed on /threadId, naming its project): the assistant sees what was said before.
| Request | Returns |
|---|---|
GET /projects/{projectId}/assistant/threads | Your conversations in the project (never other people's), the most recently active first, each with its latestAnswer: id (msg_…), status and proposalStatus |
GET /assistant/threads/{threadId} | One conversation with its latest 20 messages, oldest first, and a messagesCursor for earlier ones |
GET /assistant/threads/{threadId}/messages | Its messages, oldest first, or newest first with order=newest; pages of up to 100 |
DELETE /assistant/threads/{threadId} | Deletes the conversation and answers { "object": "assistant_thread", "id": "thr_…", "title": "…", "deleted": true } (title is null for a key without projects:read and tasks:read); again, 404; while changes from it are being applied, 409 assistant_busy with that answer's messageId (delete it once they are done) |
messagesCursor continues GET /assistant/threads/{threadId}/messages newest first. A cursor remembers its order, so you can leave order out with it; sending the opposite order answers 400 invalid_cursor.
Deleting a conversation does not give back questions from the hourly allowance.
Errors and limits
#| Status and code | Meaning | What to do |
|---|---|---|
409 assistant_busy | The assistant is still answering in this conversation, or two of your questions (in any conversation), or (deleting it) changes from it are being applied; messageId (msg_…) is that answer, when it is in this project | Wait for that answer (GET /assistant/messages/{messageId}?wait=25), then ask again, or start a new conversation; to delete, try again once the changes are applied |
429 assistant_hourly_limit | The person asked 60 questions in the last hour, across every app | Wait Retry-After seconds; tell the person |
429 rate_limited with bucket: "assistant" | This key or app asked its own hourly number of questions (30) | Wait Retry-After seconds |
503 assistant_unavailable | The assistant is not set up on this server | Do without it; retrying will not help |
409 proposal_closed | The proposed changes were already applied, are being applied, or were dismissed | Read the answer again to see each change’s result; the detail names changes that were not applied (and why) and changes that were not chosen (never made) |
404 not_found | No such conversation or message for you: conversations are private | Check the id; list your conversations with GET /projects/{projectId}/assistant/threads |
The limits page has the numbers. The hourly allowance is counted per person from the questions themselves, so deleting conversations does not reset it.