API reference
Read a task's messages
GET /api/pub/v1/tasks/{taskId}/messages, page through a task's messages, oldest first, to read a staff member's reply.
GET
https://api.dhanu.ai/api/pub/v1/tasks/{taskId}/messagesThe messages on a task, oldest first, one page at a time. This is how you read
the reply after a trigger: poll until
an assistant message appears.
Request
| Path parameter | Type | Required | Notes |
|---|---|---|---|
taskId | string | Yes |
| Parameter | Type | Required | Notes |
|---|---|---|---|
limit | integer | No | Rows per page, 1 to 100; defaults to 50. At least 1, at most 100. |
cursor | string | No | The nextCursor from the previous page, verbatim. |
curl "https://api.dhanu.ai/api/pub/v1/tasks/$TASK_ID/messages?limit=50" \
-H "Authorization: Bearer $DHANU_API_KEY"// One page
const page = await dhanu.tasks.messagesPage(taskId, { limit: 50 });
const next = await dhanu.tasks.messagesPage(taskId, { cursor: page.nextCursor });
// Or everything, following pages to the end
const all = await dhanu.tasks.messages(taskId);# One page
page = dhanu.tasks.messages_page(task_id, limit=50)
next_page = dhanu.tasks.messages_page(task_id, cursor=page.next_cursor)
# Or everything, following pages to the end
rows = dhanu.tasks.messages(task_id) Response
200 OK
{
"data": [
{ "id": "…", "role": "user", "text": "Draft minutes for today's stand-up.", "createdAt": "…" },
{ "id": "…", "role": "assistant", "text": "Here are the minutes…", "createdAt": "…" }
],
"nextCursor": null,
"hasMore": false,
"messages": [ … ]
}
Pass nextCursor back as cursor to fetch the next page; when hasMore is
false you hold the last one. messages mirrors data for clients written
before pagination and is deprecated, see
Versioning.
Errors
| Code | Status | Meaning |
|---|---|---|
invalid_api_key | 401 | The bearer key is missing or unknown. |
api_key_revoked | 401 | The key was revoked. |
api_key_expired | 401 | The key passed its expiry date. |
api_key_ip_not_allowed | 403 | The caller's IP is outside the key's allowlist. |
developer_access_revoked | 403 | The key's creator lost developer access in the workspace. |
api_key_project_scope | 403 | The key covers no active projects, or projectId is outside its scope. |
not_found | 404 | No such resource in the key's workspace. |
invalid_cursor | 422 | The cursor was not one this endpoint issued. |
The full list is on Errors.