Skip to main content

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​

ScopeEndpoints
tasks:readGET /primitives/tasks, GET /primitives/tasks/:id, GET /primitives/tasks/:id/permissions
tasks:writePOST /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 open between fires. After each fire dueAt advances to the next slot, fireCount increments, and the fire is recorded. Every fire is a fire record of its own and every one is kept: GET /primitives/tasks/:id/fires pages 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, runId and agentId. The schedule moves on to its next slot; a one-shot task becomes failed. fireRepair is STAN's repair of the latest failed fire: {state, taskFiredAt, failedAt, reason, runId?, agentId?, agentName?, summary?, repairedAt?, notificationId?}, state one of pending, 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/complete on a recurring task closes the task's open fire record (status: "done", completedAt set) and advances dueAt to the next slot.
  • One fire, one completion. fireCount equals the number of fires. Completing a fire that is already complete records nothing and answers alreadyComplete: true: the same agent run (runId) completing it again, a task that is already done, or a failed fire whose retry already completed it. While STAN repairs a failed fire (fireRepair.state pending or repairing), the retry's completion completes that fire: its record turns done with completedRunId, 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: fireCount increments and lastFiredAt is the claim time. A task with no dueAt or nextDueAt is intent-only and no heartbeat runs it on its own.
  • skip_next: true causes the next fire to advance dueAt without invoking any workflow, then resets to false.
  • POST /primitives/tasks/:id/end-recurrence is terminal -- the recurring task moves to status done and recurrenceEndedAt is 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

ParameterTypeRequiredDescription
statusstringNoOnly tasks in this status: open / fired / done / failed / cancelled. Without it, done, failed and cancelled tasks are left out unless includeCompleted=true
kindstringNorecurring (tasks with a recurrence) or oneoff (tasks without one)
tagsstringNoComma-separated tag list; a task must carry all of them
linkedIdsstringNoComma-separated agent and pool IDs; a task must belong to all of them
qstringNoCase-insensitive substring match on description and notes
includeCompletedbooleanNotrue also returns done, failed and cancelled tasks (default false). Has no effect when status is set
dueOnlybooleanNotrue returns only tasks whose time has arrived (dueAt or nextDueAt at or before now); tasks with neither are left out (default false)
triggerTypestringNoheartbeat or scheduled: only tasks with this trigger type. A task created without one counts as scheduled when its recurrence kind is cron, otherwise heartbeat
sortstringNo-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)
limitintegerNoMax results (default 50, max 200)
cursorstringNometa.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)

ParameterTypeRequiredDescription
kindstringNorecurring or oneoff
statusstringNoOnly this status
tagsstringNoComma-separated tags; a task must carry all of them
linkedIdsstringNoOnly tasks linked to all these ids
includeCompletedbooleanNoCount done, failed and cancelled tasks too
qstringNoSubstring match on description and notes
dueOnlybooleanNoOnly tasks due now
triggerTypestringNoheartbeat 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": "..." }
}
FieldDescription
totalHow many the list holds with these filters.
byStatusEach status with how many tasks have it.
byTriggerTypeHow each fires: heartbeat (an agent works it) or scheduled (the platform fires it).
firesHow many times they fired, added up.
failingThe 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"
}
}
FieldTypeRequiredDescription
descriptionstringYesOne-line task description
dueAtstringNoISO timestamp the one-shot task is due (ignored for recurring tasks -- first fire is computed from recurrence)
linkedIdsstring[]YesThe ID of the one agent that works the task (one of yours), plus any pool IDs
triggerTypestringNoheartbeat (the agent completes it when it next wakes) or scheduled (fired at its exact time). Default: scheduled for a cron recurrence, otherwise heartbeat
sharedWithstring[]NoUser IDs to share the task with
isPublicbooleanNoMake the task readable across the organization (default false)
subjectRefobjectNo{kind, id, app?} -- what the task is about
subjectIdstringNoYour 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
createdByAgentstringNoAgent that authored the task
assignedToAgentstringNoA label the Task Due trigger of the task's agent can filter on (exact match)
notesstringNoFree-form notes
tagsstring[]NoDiscoverability tags
recurrenceobjectNoRecurrence 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

ParameterTypeRequiredDescription
idstringYesTask 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

ParameterTypeRequiredDescription
idstringYesTask ID

Request Body

FieldTypeRequiredDescription
descriptionstringNoOne-line task description
dueAtstring | nullNoISO timestamp the task is due (one-shot only); null removes it
assignedToAgentstring | nullNoTask Due trigger label (see create); null removes it
linkedIdsstring[]NoReplace the agent and pools the task belongs to: still exactly one of the task owner's agents, else 400 validation-error
subjectRefobject | nullNo{kind, id, app?}; null removes it
notesstring | nullNoFree-form notes
tagsstring[]NoDiscoverability tags
recurrenceobject | nullNoReplace 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

ParameterTypeRequiredDescription
idstringYesTask 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

ParameterTypeRequiredDescription
idstringYesTask ID

Query Parameters

ParameterTypeRequiredDescription
qstringNoOnly fires whose status, failure reason or run or execution id contains this text
sortstringNoOne of occurredAt (default -occurredAt), firedAt, completedAt, status; - for descending
limitnumberNoResults per page (default 50, max 200)
cursorstringNometa.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​

ParameterTypeRequiredDescription
idstringYesThe task ID

Query Parameters​

ParameterTypeRequiredDescription
windowstringNo24h (hourly points), 7d or 30d (daily UTC points). 30d when left out.
granularitystringNohourly 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": "..." }
}
FieldDescription
firesFires in the point. The statuses below add up to it.
firedRunning now.
noSubscriberNo agent was there to take it.
done, failed, cancelledHow it ended.

Whoever may read the task may read it.

Errors​

StatusCodeWhen
400validation-errorA window or granularity it does not offer.
404not-foundNo 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

ParameterTypeRequiredDescription
idstringYesTask ID

Request Body

FieldTypeRequiredDescription
executionIdstringNoExecution that handled the fire -- written into the closed fire record
runIdstringNoAgent run that completed the fire -- written into the closed fire record as completedRunId; the same run completing the task again is already complete
notesstringNoCompletion 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

ParameterTypeRequiredDescription
idstringYesTask ID

Request Body

FieldTypeRequiredDescription
reasonstringNoFree-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

ParameterTypeRequiredDescription
idstringYesTask 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

ParameterTypeRequiredDescription
idstringYesTask 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.

MethodPathDoesScope
GET/api/v1/primitives/tasks/:id/permissionsOwner, members (userId, role) and visibilitytasks:read
POST/api/v1/primitives/tasks/:id/permissions/membersShare with a user: { "userId", "role": "editor" | "user" }tasks:write
DELETE/api/v1/primitives/tasks/:taskId/permissions/members/:userIdStop sharing with a usertasks: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

ParameterTypeRequiredDescription
idstringYesTask id

Request Body

FieldTypeRequiredDescription
claimantIdstringYesYour 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:

ValueMeaning
openTask is scheduled and waiting for its next fire. Default for recurring tasks between fires.
firedOne-shot task has been dispatched to its workflow but has not yet completed.
doneTerminal success state. For recurring tasks, set only by end-recurrence.
failedTerminal failure state. failureReason is set.
cancelledTerminal -- user-initiated cancellation.

RecurrenceKind​

Enum string. Valid values:

ValueDescription
noneNot recurring (one-shot). Equivalent to omitting recurrence.
dailyFires every day at timeOfDay (in timezone).
weeklyFires every dayOfWeek at timeOfDay.
monthlyFires every dayOfMonth at timeOfDay.
cronFires 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
}
FieldTypeRequiredDescription
kindstringYesOne of RecurrenceKind
timeOfDaystringNoHH:MM 24-hour clock (used by daily / weekly / monthly)
dayOfWeekintegerNo0–6 (Sunday=0). Required for weekly.
dayOfMonthintegerNo1–31. Required for monthly.
cronstringNoCron expression. Required for cron.
timezonestringNoIANA timezone (e.g. America/Los_Angeles); defaults to UTC.
untilstring | nullNoISO timestamp at which recurrence stops automatically.
maxFiresinteger | nullNoStop after N total fires.

TaskSubjectRef​

{
"kind": "report",
"id": "rpt_001",
"app": "compliance-suite"
}
FieldTypeRequiredDescription
kindstringYesFree-form subject type (e.g. report, ticket, document)
idstringYesSubject identifier within its kind
appstringNoOriginating 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.

FieldTypeRequiredDescription
_idstringYesFire record ID
taskIdstringYesThe task that fired
occurredAtstringYesWhen the fire happened: firedAt, or completedAt for a one-time task completed by hand before it ran. Fires are ordered by it
firedAtstring | nullNoWhen the task fired (the scheduler dispatched it, or an agent claimed it)
completedAtstring | nullNoWhen the fire reached its outcome
statusstringYesfired (a run still open) / no_subscriber (nothing ran it) / done / failed / cancelled
failureReasonstring | nullNoWhy a failed fire failed
executionIdstring | nullNoWorkflow execution that ran the fire
workflowIdstring | nullNoThe workflow of executionId (its run page); absent once that run is no longer kept
runId / agentIdstring | nullNoThe agent run of a failed fire, and the agent
completedRunIdstring | nullNoThe agent run that completed the fire (a failed fire's retry, when STAN repaired it)