A task is a job the assistant runs in the background, like comparing three offers or writing a report. You can see your tasks in Tasks. These endpoints let you hand work to the assistant from a script, follow its progress, and collect the results. See Tasks for more on how tasks work.
Reading tasks requires the Tasks area, which is included in Full access and Read-only. Starting and controlling tasks requires Full access or Tasks set to Read and write. Tasks cost credits. A task started through the API uses the permissions of the person the API key belongs to, and its outward actions, like sending an email, follow that person’s settings.
POST /tasks starts a task, GET /tasks and GET /tasks/{task} list or show them, and GET /tasks/{task}/outputs returns what a task produced.
Your request needs a brief. If a task might be expensive, also include credit_cap_microcredits to set the most it can spend (1 credit is 1,000,000 microcredits):
{
"brief": "Compare the three hosting offers in the latest thread",
"credit_cap_microcredits": 50000000
}
Svanja estimates every task before starting it. If it can’t estimate the cost reliably, or if the estimate is above your threshold for asking, the task won’t start without a cap and the API returns conflict. Either send a cap or pass "task_estimate_decision": "start" to run it anyway. See Plans, credits and prices.
GET /tasks/{task}/events?after_sequence=0 returns up to 200 events after that sequence number, along with data.next_sequence. Pass that value as after_sequence on your next request to follow a task without missing anything, even after a disconnect.
POST /tasks/{task}/actions controls a task by setting action to pause, resume, resume_wait, stop, retry, or continue. Use resume to continue a task you paused, and resume_wait to continue one that is waiting, such as for an answer. If you’re working from a terminal, see svanja task.