Tasks
Tasks are user-owned work for an agent. Every task belongs to exactly one of its owner's agents, named in linkedIds (with any pools): there is no task without an agent, and deleting the agent deletes its tasks, their fire records and the notifications about them. Tasks can be one-shot (dueAt) or recurring (daily / weekly / monthly / cron). The platform fires a due task on its agent; this API lets you create, manage, and observe tasks programmatically.
All endpoints require authentication via X-API-Key header and the appropriate scope.
Scopes
| Scope | Endpoints |
|---|---|
tasks:read | GET /primitives/tasks, GET /primitives/tasks/:id, GET /primitives/tasks/:id/permissions |
tasks:write | POST /primitives/tasks, PATCH /primitives/tasks/:id, DELETE /primitives/tasks/:id, POST /primitives/tasks/:id/complete, POST /primitives/tasks/:id/cancel, POST /primitives/tasks/:id/skip-next, POST /primitives/tasks/:id/end-recurrence, POST /primitives/tasks/:id/permissions/members, DELETE /primitives/tasks/:taskId/permissions/members/:userId, PATCH /primitives/tasks/:id/permissions |
Lifecycle
- One-shot tasks (no recurrence): status moves
open→fired→done/cancelled/failed. Terminal states cannot transition further. - Recurring tasks: status stays
openbetween fires. After each firedueAtadvances to the next slot,fireCountincrements, and the fire is recorded. Every fire is a fire record of its own and every one is kept:GET /primitives/tasks/:id/firespages through them. - A fire whose run ends without the task done (the agent's run failed or ended without completing it, no agent or workflow could run it, or its run never reported an outcome) is a fire record with
status: "failed",failureReason,runIdandagentId. The schedule moves on to its next slot; a one-shot task becomesfailed.fireRepairis STAN's repair of the latest failed fire:{state, taskFiredAt, failedAt, reason, runId?, agentId?, agentName?, summary?, repairedAt?, notificationId?},stateone ofpending,repairing,fixed(the retry completed the task),notified(STAN could not fix it; the owner got a notification with what failed and why). POST /primitives/tasks/:id/completeon a recurring task closes the task's open fire record (status: "done",completedAtset) and advancesdueAtto the next slot.- One fire, one completion.
fireCountequals the number of fires. Completing a fire that is already complete records nothing and answersalreadyComplete: true: the same agent run (runId) completing it again, a task that is alreadydone, or a failed fire whose retry already completed it. While STAN repairs a failed fire (fireRepair.statependingorrepairing), the retry's completion completes that fire: its record turnsdonewithcompletedRunId, and since the fire was counted when it failed and the schedule already moved on, nothing is counted or advanced again. - Agent heartbeat: an agent claims a due heartbeat task before it works it (
claimedBy,claimedAt). Completing it counts that run:fireCountincrements andlastFiredAtis the claim time. A task with nodueAtornextDueAtis intent-only and no heartbeat runs it on its own. skip_next: truecauses the next fire to advancedueAtwithout invoking any workflow, then resets tofalse.POST /primitives/tasks/:id/end-recurrenceis terminal -- the recurring task moves to statusdoneandrecurrenceEndedAtis set.
Task Object
{
"_id": "task_abc123",
"ownerId": "user_456",
"ownerName": "Alice Example",
"organizationId": "org_789",
"linkedIds": ["wf_321"],
"agentId": "wf_321",
"agentName": "Compliance Bot",
"sharedWith": [],
"isPublic": false,
"description": "Run the weekly compliance report",
"subjectRef": {
"kind": "report",
"id": "rpt_001",
"app": "compliance-suite"
},
"createdByAgent": null,
"assignedToAgent": "agent_compliance_bot",
"status": "open",
"triggerType": "heartbeat",
"dueAt": "2026-05-23T09:00:00Z",
"firedAt": null,
"completedAt": null,
"failureReason": null,
"notes": "Email the PDF to legal@example.com",
"recurrence": {
"kind": "weekly",
"timeOfDay": "09:00",
"dayOfWeek": 6,
"dayOfMonth": null,
"cron": null,
"timezone": "America/Los_Angeles",
"until": null,
"maxFires": null
},
"nextDueAt": "2026-05-23T09:00:00Z",
"lastFiredAt": "2026-05-16T09:00:00Z",
"fireCount": 4,
"recurrenceEndedAt": null,
"skipNext": false,
"tags": ["compliance", "weekly"],
"createdAt": "2026-04-01T09:00:00Z",
"updatedAt": "2026-05-16T09:04:12Z"
}
GET /api/v1/primitives/tasks
List tasks the caller can read, with filters and pagination, latest changed first unless sort says otherwise. Each task names the agent it belongs to: agentId (the one agent among its linkedIds) and agentName, as GET /primitives/tasks/:id does.
Scope: tasks:read
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
status | string | No | Only tasks in this status: open / fired / done / failed / cancelled. Without it, done, failed and cancelled tasks are left out unless includeCompleted=true |
kind | string | No | recurring (tasks with a recurrence) or oneoff (tasks without one) |
tags | string | No | Comma-separated tag list; a task must carry all of them |
linkedIds | string | No | Comma-separated agent and pool IDs; a task must belong to all of them |
q | string | No | Case-insensitive substring match on description and notes |
includeCompleted | boolean | No | true also returns done, failed and cancelled tasks (default false). Has no effect when status is set |
dueOnly | boolean | No | true returns only tasks whose time has arrived (dueAt or nextDueAt at or before now); tasks with neither are left out (default false) |
triggerType | string | No | heartbeat or scheduled: only tasks with this trigger type. A task created without one counts as scheduled when its recurrence kind is cron, otherwise heartbeat |
sort | string | No | -updatedAt (default, latest changed first), updatedAt, dueAt (soonest due first, by nextDueAt or dueAt; a task with no due time last), -dueAt, createdAt or -createdAt. Another is refused (400) |
limit | integer | No | Max results (default 50, max 200) |
cursor | string | No | meta.nextCursor of the previous page; omit for the first page |
Response 200 OK
{
"data": [ /* task summaries */ ],
"meta": {
"total": 12,
"limit": 50,
"nextCursor": null,
"requestId": "req_abc123"
}
}
Each item is a task summary: every field of the task except fireRepair (STAN's repair of its latest failed fire) and the execution claim (claimedBy, claimedAt), with agentId and agentName. notes and subjectRef stay: an agent's heartbeat runs its due tasks from this list. GET /api/v1/primitives/tasks/:id returns the full task.
Example
curl -H "X-API-Key: $STRONGLY_API_KEY" \
-H "Content-Type: application/json" \
"https://<your-instance>/api/v1/primitives/tasks?status=open&limit=20"
GET /api/v1/primitives/tasks/stats
Count the tasks GET /api/v1/primitives/tasks lists, with the same filters (finished ones only with includeCompleted): every one the list holds for you with these filters, not a page, counted by the database. Each by<Field> is a list of rows, one per value with how many have it ({ "<field>": value, "total": n }), most first; a value the records leave out is null.
Scope: tasks:read
Query Parameters (the list's own filters)
| Parameter | Type | Required | Description |
|---|---|---|---|
kind | string | No | recurring or oneoff |
status | string | No | Only this status |
tags | string | No | Comma-separated tags; a task must carry all of them |
linkedIds | string | No | Only tasks linked to all these ids |
includeCompleted | boolean | No | Count done, failed and cancelled tasks too |
q | string | No | Substring match on description and notes |
dueOnly | boolean | No | Only tasks due now |
triggerType | string | No | heartbeat or scheduled |
Response 200 OK
{
"data": { "total": 5, "byStatus": [ { "status": "open", "total": 5 } ], "byTriggerType": [ { "triggerType": "scheduled", "total": 3 }, { "triggerType": "heartbeat", "total": 2 } ], "fires": 41, "failing": 1 },
"meta": { "requestId": "..." }
}
| Field | Description |
|---|---|
total | How many the list holds with these filters. |
byStatus | Each status with how many tasks have it. |
byTriggerType | How each fires: heartbeat (an agent works it) or scheduled (the platform fires it). |
fires | How many times they fired, added up. |
failing | The tasks whose latest failed fire STAN has not fixed. |
POST /api/v1/primitives/tasks
Create a new task. Pass recurrence to create a recurring task; omit it for a one-shot.
Scope: tasks:write
Request Body
{
"description": "Run the weekly compliance report",
"dueAt": "2026-05-23T09:00:00Z",
"linkedIds": ["wf_321"],
"assignedToAgent": "agent_compliance_bot",
"subjectRef": {
"kind": "report",
"id": "rpt_001",
"app": "compliance-suite"
},
"notes": "Email the PDF to legal@example.com",
"tags": ["compliance", "weekly"],
"recurrence": {
"kind": "weekly",
"timeOfDay": "09:00",
"dayOfWeek": 6,
"timezone": "America/Los_Angeles"
}
}
| Field | Type | Required | Description |
|---|---|---|---|
description | string | Yes | One-line task description |
dueAt | string | No | ISO timestamp the one-shot task is due (ignored for recurring tasks -- first fire is computed from recurrence) |
linkedIds | string[] | Yes | The ID of the one agent that works the task (one of yours), plus any pool IDs |
triggerType | string | No | heartbeat (the agent completes it when it next wakes) or scheduled (fired at its exact time). Default: scheduled for a cron recurrence, otherwise heartbeat |
sharedWith | string[] | No | User IDs to share the task with |
isPublic | boolean | No | Make the task readable across the organization (default false) |
subjectRef | object | No | {kind, id, app?} -- what the task is about |
subjectId | string | No | Your app's own id for whom the task is about (a person's id, say; 1 to 200 letters, digits and _ . : -). DELETE /apps/:appId/agent-subjects/:id deletes every task tagged with it on the app's agents. A task an agent creates during a message your app tagged with subjectId carries it too |
createdByAgent | string | No | Agent that authored the task |
assignedToAgent | string | No | A label the Task Due trigger of the task's agent can filter on (exact match) |
notes | string | No | Free-form notes |
tags | string[] | No | Discoverability tags |
recurrence | object | No | Recurrence spec -- see TaskRecurrence |
Response 201 Created
{
"data": { "taskId": "task_abc123" },
"meta": { "requestId": "req_abc123" }
}
Example
curl -X POST \
-H "X-API-Key: $STRONGLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"description": "Run the weekly compliance report",
"linkedIds": ["wf_321"],
"recurrence": { "kind": "weekly", "timeOfDay": "09:00", "dayOfWeek": 6, "timezone": "America/Los_Angeles" }
}' \
https://<your-instance>/api/v1/primitives/tasks
Returns 400 validation-error if description is missing, recurrence is invalid, triggerType is not heartbeat or scheduled, or linkedIds does not name exactly one of your agents (no agent, a plain workflow, two agents, or another user's agent). The detail says which.
GET /api/v1/primitives/tasks/:id
Get a single task by ID.
Scope: tasks:read
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID |
Response 200 OK
Returns the full Task object.
Example
curl -H "X-API-Key: $STRONGLY_API_KEY" \
-H "Content-Type: application/json" \
https://<your-instance>/api/v1/primitives/tasks/task_abc123
PATCH /api/v1/primitives/tasks/:id
Update a task. Only the fields supplied are changed.
Scope: tasks:write
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
description | string | No | One-line task description |
dueAt | string | null | No | ISO timestamp the task is due (one-shot only); null removes it |
assignedToAgent | string | null | No | Task Due trigger label (see create); null removes it |
linkedIds | string[] | No | Replace the agent and pools the task belongs to: still exactly one of the task owner's agents, else 400 validation-error |
subjectRef | object | null | No | {kind, id, app?}; null removes it |
notes | string | null | No | Free-form notes |
tags | string[] | No | Discoverability tags |
recurrence | object | null | No | Replace the recurrence spec; pass null to convert to one-shot |
Response 200 OK
The task, as GET /primitives/tasks/:id shows it.
DELETE /api/v1/primitives/tasks/:id
Delete a task and its fire records. Irreversible.
Scope: tasks:write
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID |
Response 204 No Content
Example
curl -X DELETE \
-H "X-API-Key: $STRONGLY_API_KEY" \
-H "Content-Type: application/json" \
https://<your-instance>/api/v1/primitives/tasks/task_abc123
GET /api/v1/primitives/tasks/:id/fires
The task's fires, newest first unless sorted: one fire record per fire, every fire kept. fireCount on the task is how many there are. Pages like every list: limit and cursor (meta.nextCursor of the previous page); meta.total is the number of fires that match.
Scope: tasks:read · STAN tool: list_task_fires
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | No | Only fires whose status, failure reason or run or execution id contains this text |
sort | string | No | One of occurredAt (default -occurredAt), firedAt, completedAt, status; - for descending |
limit | number | No | Results per page (default 50, max 200) |
cursor | string | No | meta.nextCursor of the previous page |
Response 200 OK
{
"data": [
{
"_id": "f_8c1d",
"taskId": "task_abc123",
"occurredAt": "2026-05-16T09:00:00Z",
"firedAt": "2026-05-16T09:00:00Z",
"completedAt": "2026-05-16T09:04:12Z",
"status": "done",
"executionId": "exec_aaa111",
"workflowId": "wf_7k2m",
"createdAt": "2026-05-16T09:00:00Z",
"updatedAt": "2026-05-16T09:04:12Z"
}
],
"meta": { "total": 4, "limit": 50, "nextCursor": null, "requestId": "req_1" }
}
GET /api/v1/primitives/tasks/:id/time-series
A task's fires over time, from its fire log: each fire counted once, in the hour or day it occurred, by its status. Each fire itself is in GET /api/v1/primitives/tasks/:id/fires.
Every series has the same shape: the window, its granularity, start (the start of the first point) and end (now), and points, one for every hour or UTC day of the window, from the one its start falls in to the current one (so far). A quiet point counts zero and averages nothing (null).
Scope: tasks:read
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The task ID |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
window | string | No | 24h (hourly points), 7d or 30d (daily UTC points). 30d when left out. |
granularity | string | No | hourly for 24h, daily for 7d and 30d; the window's when left out. Another is refused (400). |
Response 200 OK
{
"data": {
"window": "30d",
"granularity": "daily",
"start": "2026-09-21T00:00:00Z",
"end": "2026-10-21T13:40:00Z",
"points": [
{ "timestamp": "2026-10-17T00:00:00Z", "fires": 2, "fired": 0, "noSubscriber": 0, "done": 1, "failed": 1, "cancelled": 0 }
]
},
"meta": { "requestId": "..." }
}
| Field | Description |
|---|---|
fires | Fires in the point. The statuses below add up to it. |
fired | Running now. |
noSubscriber | No agent was there to take it. |
done, failed, cancelled | How it ended. |
Whoever may read the task may read it.
Errors
| Status | Code | When |
|---|---|---|
400 | validation-error | A window or granularity it does not offer. |
404 | not-found | No such task, or one you may not see. |
POST /api/v1/primitives/tasks/:id/complete
Mark the task done. On a one-shot task this is terminal (status: "done"). On a recurring task this closes its open fire record and advances dueAt to the next slot -- the task stays open. A fire has one completion: completing a fire that is already complete records nothing and answers alreadyComplete: true (see Lifecycle).
Scope: tasks:write
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
executionId | string | No | Execution that handled the fire -- written into the closed fire record |
runId | string | No | Agent run that completed the fire -- written into the closed fire record as completedRunId; the same run completing the task again is already complete |
notes | string | No | Completion notes; replaces the task's notes |
Response 200 OK
The task, as GET /primitives/tasks/:id shows it: status done for a one-off task; a recurring one has its nextDueAt. alreadyComplete is true when the fire was already complete and nothing was recorded, else false.
POST /api/v1/primitives/tasks/:id/cancel
Mark the task as cancelled. Terminal for both one-shot and recurring tasks.
Scope: tasks:write
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
reason | string | No | Free-form cancellation reason -- written to failureReason |
Response 200 OK: the task.
The task moves to status: "cancelled".
Example
curl -X POST \
-H "X-API-Key: $STRONGLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "reason": "Compliance report no longer required" }' \
https://<your-instance>/api/v1/primitives/tasks/task_abc123/cancel
POST /api/v1/primitives/tasks/:id/skip-next
Skip the next scheduled fire of a recurring task. Sets skip_next: true -- at the next scheduled slot, dueAt advances without invoking any workflow, and skipNext resets to false.
Scope: tasks:write
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID |
Response 200 OK: the task, its nextFireAt moved past the skipped fire.
Example
curl -X POST \
-H "X-API-Key: $STRONGLY_API_KEY" \
-H "Content-Type: application/json" \
https://<your-instance>/api/v1/primitives/tasks/task_abc123/skip-next
Returns 400 validation-error if the task has no recurrence (one-shot tasks cannot be skipped).
POST /api/v1/primitives/tasks/:id/end-recurrence
Stop a recurring task. Terminal -- moves the task to status: "done" and sets recurrenceEndedAt to the server time of the call. No future fires will occur.
Scope: tasks:write
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID |
Response 200 OK: the task.
The task moves to status: "done" and recurrenceEndedAt is set.
Example
curl -X POST \
-H "X-API-Key: $STRONGLY_API_KEY" \
-H "Content-Type: application/json" \
https://<your-instance>/api/v1/primitives/tasks/task_abc123/end-recurrence
Returns 400 validation-error if the task has no recurrence.
Sharing
Who can reach a task is the platform's one sharing shape: its owner, its members
(role editor can use and change it, user can only use it) and its visibility
(public: every user can find and use it; on
Strongly Cloud, every user of its organization). Changing it stays with its owner and editors.
| Method | Path | Does | Scope |
|---|---|---|---|
| GET | /api/v1/primitives/tasks/:id/permissions | Owner, members (userId, role) and visibility | tasks:read |
| POST | /api/v1/primitives/tasks/:id/permissions/members | Share with a user: { "userId", "role": "editor" | "user" } | tasks:write |
| DELETE | /api/v1/primitives/tasks/:taskId/permissions/members/:userId | Stop sharing with a user | tasks:write |
| PATCH | /api/v1/primitives/tasks/:id/permissions | { "visibility": "public" | "private" } | tasks:write |
Each, except a member's removal (204), answers the permissions as they are now:
{
"data": {
"resourceId": "<task id>",
"owner": "<user id>",
"members": [{ "userId": "<user id>", "role": "user" }],
"visibility": "private"
},
"meta": { "requestId": "req_abc123" }
}
POST /api/v1/primitives/tasks/:id/claim
Claim a task's current occurrence before doing it, so a task linked to several agents is done once. The claim lapses when its occurrence ends.
Scope: tasks:write
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task id |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
claimantId | string | Yes | Your agent's id |
Response 200 OK: the task, its claimedBy you, when you won the claim (do the task); claiming again as the winner returns it again.
Error 409 Conflict: another agent has this occurrence (skip it); detail names it.
Schemas
TaskStatus
Enum string. Valid values:
| Value | Meaning |
|---|---|
open | Task is scheduled and waiting for its next fire. Default for recurring tasks between fires. |
fired | One-shot task has been dispatched to its workflow but has not yet completed. |
done | Terminal success state. For recurring tasks, set only by end-recurrence. |
failed | Terminal failure state. failureReason is set. |
cancelled | Terminal -- user-initiated cancellation. |
RecurrenceKind
Enum string. Valid values:
| Value | Description |
|---|---|
none | Not recurring (one-shot). Equivalent to omitting recurrence. |
daily | Fires every day at timeOfDay (in timezone). |
weekly | Fires every dayOfWeek at timeOfDay. |
monthly | Fires every dayOfMonth at timeOfDay. |
cron | Fires per arbitrary cron expression in timezone. |
TaskRecurrence
{
"kind": "weekly",
"timeOfDay": "09:00",
"dayOfWeek": 6,
"dayOfMonth": null,
"cron": null,
"timezone": "America/Los_Angeles",
"until": null,
"maxFires": null
}
| Field | Type | Required | Description |
|---|---|---|---|
kind | string | Yes | One of RecurrenceKind |
timeOfDay | string | No | HH:MM 24-hour clock (used by daily / weekly / monthly) |
dayOfWeek | integer | No | 0–6 (Sunday=0). Required for weekly. |
dayOfMonth | integer | No | 1–31. Required for monthly. |
cron | string | No | Cron expression. Required for cron. |
timezone | string | No | IANA timezone (e.g. America/Los_Angeles); defaults to UTC. |
until | string | null | No | ISO timestamp at which recurrence stops automatically. |
maxFires | integer | null | No | Stop after N total fires. |
TaskSubjectRef
{
"kind": "report",
"id": "rpt_001",
"app": "compliance-suite"
}
| Field | Type | Required | Description |
|---|---|---|---|
kind | string | Yes | Free-form subject type (e.g. report, ticket, document) |
id | string | Yes | Subject identifier within its kind |
app | string | No | Originating app slug -- used for cross-app references |
TaskFireRecord
One fire of a task, as GET /primitives/tasks/:id/fires lists it. Every fire is a record of its own and every one is kept.
| Field | Type | Required | Description |
|---|---|---|---|
_id | string | Yes | Fire record ID |
taskId | string | Yes | The task that fired |
occurredAt | string | Yes | When the fire happened: firedAt, or completedAt for a one-time task completed by hand before it ran. Fires are ordered by it |
firedAt | string | null | No | When the task fired (the scheduler dispatched it, or an agent claimed it) |
completedAt | string | null | No | When the fire reached its outcome |
status | string | Yes | fired (a run still open) / no_subscriber (nothing ran it) / done / failed / cancelled |
failureReason | string | null | No | Why a failed fire failed |
executionId | string | null | No | Workflow execution that ran the fire |
workflowId | string | null | No | The workflow of executionId (its run page); absent once that run is no longer kept |
runId / agentId | string | null | No | The agent run of a failed fire, and the agent |
completedRunId | string | null | No | The agent run that completed the fire (a failed fire's retry, when STAN repaired it) |