API reference
Create a task
POST /api/pub/v1/tasks, start a task from a first message, optionally assigned to a staff member.
POST
https://api.dhanu.ai/api/pub/v1/tasksStarts a task from a first message. With staffId the reply comes from that staff
member’s run; without it the workspace assistant replies. Returns at once with the
task, then read its messages,
stream them, or subscribe to the
task.message.created webhook.
The reply spends workspace credits like any other task. Everything you send is treated as untrusted text: the assistant reports on it and never obeys instructions inside it.
Request
| Field | Type | Required | Notes |
|---|---|---|---|
input | string | Yes | The first message, as plain text. At least 1 characters, up to 50000 characters. |
title | string | No | Up to 200 characters. |
staffId | string | No | Assign the task to this staff member; the reply then comes from a staff run. |
fileIds | array | No | Files (from POST /files) to attach to the message. |
curl -X POST https://api.dhanu.ai/api/pub/v1/tasks \
-H "Authorization: Bearer $DHANU_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "Summarise this week\u0027s support tickets.", "staffId": "…" }'const task = await dhanu.tasks.create({
input: "Summarise this week's support tickets.",
staffId: "…",
});task = dhanu.tasks.create(input="Summarise this week's support tickets.", staff_id="…") Response
202 Accepted
{ "task": { "id": "…", "title": "Summarise this week's support tickets.", "assigneeStaffIds": ["…"], "createdAt": "…", "updatedAt": "…" } }
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. |
invalid_request_body | 422 | The body did not match the schema; error.issues names each field. |
not_found | 404 | No such resource in the key's workspace. |