Skip to content
dhanu docs
Browse pages

API reference

Create a task

POST /api/pub/v1/tasks, start a task from a first message, optionally assigned to a staff member.

POSThttps://api.dhanu.ai/api/pub/v1/tasks

Starts 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

FieldTypeRequiredNotes
inputstringYesThe first message, as plain text. At least 1 characters, up to 50000 characters.
titlestringNoUp to 200 characters.
staffIdstringNoAssign the task to this staff member; the reply then comes from a staff run.
fileIdsarrayNoFiles (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

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.
invalid_request_body422The body did not match the schema; error.issues names each field.
not_found404No such resource in the key's workspace.