Skip to content
dhanu docs
Browse pages

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.

GEThttps://api.dhanu.ai/api/pub/v1/tasks/{taskId}/messages

The 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 parameterTypeRequiredNotes
taskIdstringYes
ParameterTypeRequiredNotes
limitintegerNoRows per page, 1 to 100; defaults to 50. At least 1, at most 100.
cursorstringNoThe 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

CodeStatusMeaning
invalid_api_key401The bearer key is missing or unknown.
api_key_revoked401The key was revoked.
api_key_expired401The key passed its expiry date.
api_key_ip_not_allowed403The caller's IP is outside the key's allowlist.
developer_access_revoked403The key's creator lost developer access in the workspace.
api_key_project_scope403The key covers no active projects, or projectId is outside its scope.
not_found404No such resource in the key's workspace.
invalid_cursor422The cursor was not one this endpoint issued.

The full list is on Errors.