Skip to content
Svanja

Docs API reference

Tasks

Start background tasks, follow their events, read their results, and pause, stop or retry them.

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.

Operations

An operation is one thing you can do, like reading a task or starting one. Its effect says what it changes. Some operations that act outside Svanja or change access wait for a person's approval; the approval flow is on the API overview.

task.control Changes data in Svanja

Control a Task.

POST /tasks/{task}/actions

task.events Reads only

Replay Task events.

GET /tasks/{task}/events

task.read Reads only

Read Tasks.

GET /tasks GET /tasks/{task} GET /tasks/{task}/outputs

task.start Changes data in Svanja

Start a Task.

POST /tasks

Endpoints

Paths start at https://app.svanja.com/api/v1. Every endpoint needs an API key unless it says otherwise. A required Idempotency-Key header is listed with the parameters.

GET /tasks List tasks

Lists Tasks visible to the key's current visibility user.

Parameter In Type Required Notes
per_page query integer no Page size. Defaults to 25 and is capped at 100.
status query one of queued, running, waiting, paused, cancelling, completed, failed, cancelled no Filter tasks by status.

Status codes: 200, 401, 403, 422, 429

POST /tasks Start a task

Starts accepted background work for the key's current visibility user.

Parameter In Type Required Notes
Idempotency-Key header string no Optional key for unsafe bearer writes. Reusing the same key and same canonical body replays the original response for 24 hours; reusing it with a different body returns idempotency_conflict.
Body field Type Required Notes
title string no
brief string yes
visibility one of personal, team no
model_route string no
selected_space_id string no
expected_result string no
credit_cap_microcredits integer no
source_refs array of object no

Status codes: 202, 400, 401, 403, 409, 422, 429

GET /tasks/{task} Show a task

Shows one Task if the visibility user can currently read it.

Parameter In Type Required Notes
task path string yes Task public ULID.

Status codes: 200, 401, 403, 404, 429

GET /tasks/{task}/events Replay task events

Returns durable Task events after the submitted sequence.

Parameter In Type Required Notes
task path string yes Task public ULID.
after_sequence query integer no

Status codes: 200, 401, 403, 404, 429

GET /tasks/{task}/outputs List task outputs

Returns retained outputs visible to the key's current visibility user.

Parameter In Type Required Notes
task path string yes Task public ULID.

Status codes: 200, 401, 403, 404, 429

POST /tasks/{task}/actions Control a task

Pauses, resumes, stops, retries, or continues a controllable Task.

Parameter In Type Required Notes
task path string yes Task public ULID.
Idempotency-Key header string no Optional key for unsafe bearer writes. Reusing the same key and same canonical body replays the original response for 24 hours; reusing it with a different body returns idempotency_conflict.
Body field Type Required Notes
action one of pause, resume, resume_wait, stop, continue, retry yes
instructions string no
credit_cap_microcredits integer no

Status codes: 202, 400, 401, 403, 404, 409, 422, 429

This page as plain Markdown, for AI tools: tasks.md

Try Svanja with your own mailbox

Sign up now, and you get an email when your account is ready.