Routines API
A routine is a scheduled prompt: a name, a target agent, a schedule, and the message the agent receives when it runs.
Cohort’s routine record decides when and how a routine runs. Change a routine through these endpoints, the Routines page, or by asking an agent.
Scopes: commands:read for reads, commands:write for writes. Every route is scoped to the API key’s workspace; a routine in another workspace responds 404.
Routine Object
{
"id": "routines_abc123",
"name": "Morning sweep",
"message": "Sweep my inbox and calendar. Follow the morning-sweep skill.",
"agentName": "mara",
"schedule": { "kind": "cron", "expr": "0 9 * * *" },
"scheduleText": "0 9 * * *",
"timeZone": "America/Chicago",
"enabled": true,
"pausedForIdleAt": null,
"status": "active",
"origin": "cohort",
"createdAt": 1755600000000,
"updatedAt": 1755690000000
}Field Reference
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier |
name | string | Routine name, 1–200 characters after trimming |
message | string | The prompt the agent receives when the routine runs. Max 2,000 characters |
agentName | string | Handle of the agent the routine targets; must be an agent member of the workspace |
schedule | object | {"kind":"cron","expr":"0 9 * * *"}, {"kind":"every","everyMs":1800000}, or a one-time run {"kind":"once","runAt":1791036000000} (epoch ms) |
scheduleText | string | Human-readable rendering of schedule — accepted back on write |
timeZone | string | null | The time zone a cron schedule’s times are in (an IANA name such as America/Chicago). See Time zone. Null means UTC |
enabled | boolean | false means paused |
pausedForIdleAt | number | null | When the routine was paused because nobody had talked to an agent for a while (epoch ms). See Paused when nobody talks to an agent. Null otherwise |
status | string | active or deleted; only active routines are returned |
origin | string | agent when the agent scheduled it itself, otherwise cohort |
completedAt | number | null | For a one-time routine: when it ran. It is then paused and does not run again |
createdAt / updatedAt | number | Epoch milliseconds |
Time zone
A routine’s times are in the time zone of the person who created it, so 0 9 * * * made by someone in Chicago runs at 9:00 AM Central all year, through daylight saving changes. The zone comes from the creator’s profile. A routine an agent creates while one person is asking uses that person’s zone. When there is no person’s zone to use, the routine uses the workspace owner’s. The zone is set when the routine is created and stays with the routine: editing it later, or changing your own time zone, does not move it.
timeZone is null only when neither the creator nor the workspace owner has a time zone. Such a routine runs on UTC.
One-time routines
A routine can run once instead of on a recurring schedule, for a single future event or reminder. Send the schedule as "once at <ISO timestamp>", for example "once at 2026-10-03T09:00:00-05:00". The timestamp must include a zone (Z or an offset such as -05:00), or it is rejected. A time that has already passed is also rejected with 400, because the routine could never run. scheduleText renders the same form in UTC ("once at 2026-10-03T14:00:00.000Z").
After it runs, the routine stays in the list with completedAt set and enabled: false. It never runs again. To run it again, PATCH a new future schedule together with "enabled": true.
Paused when nobody talks to an agent
A routine an agent made (origin: "agent", or one an agent created through this API) is paused when nobody in the workspace has talked to any of its agents for a while. Talking to an agent means a chat or Room message, a text, a voice call, a task given to an agent or a comment on one, or a message on a connected channel. The pause is the ordinary one: enabled becomes false, and pausedForIdleAt says when. The routine resumes by itself the next time someone talks to an agent.
A routine a person made is never paused this way, and neither is a one-time routine. A routine you pause yourself stays paused. Pausing or resuming a routine with PATCH clears pausedForIdleAt, so your choice stands.
The 2,000-character message limit
A routine’s message can be up to 2,000 characters. A longer message is rejected with 400, never cut short. Keep the message short: longer instructions go in a skill the message names, so everything the routine runs on is visible in Cohort.
List Routines
GET /api/v1/routinesReturns the workspace’s active routines, most recently updated first.
Response
{
"data": [ { "id": "routines_abc123", "name": "Morning sweep" } ],
"meta": { "count": 1, "timestamp": 1755690000000 }
}Get Routine
GET /api/v1/routines/:idReturns one routine, including the full result of its latest run. Responds 404 for an unknown id, a deleted routine, or a routine in another workspace.
List a Routine’s Runs
GET /api/v1/routines/:id/runs?limit=10A routine owns its runs. Returns them newest first (limit 1–100, default 10) as { "data": [...], "meta": { "count", "timestamp" } }:
{
"id": "k17f3...",
"status": "error",
"startedAt": 1762567200000,
"finishedAt": 1762567212000,
"durationMs": 12000,
"message": "This routine's last run failed. Open the routine to review it before deciding whether to run it again.",
"degradedReason": null,
"missingService": null,
"result": null,
"task": { "id": "jd7a...", "number": 41, "title": "Night build failed", "status": "todo" },
"deliverables": []
}| Field | Description |
|---|---|
status | running, ok, error, or degraded (finished, but could not do its job or needs a person) |
message | Cohort’s explanation of an error or degraded run |
degradedReason | missing_connection, blocked, incomplete, or needs_person (the agent asks a person to decide or act) |
result | What the run said (Markdown). Null when it said nothing, or when the caller may not read this routine’s results (a routine an agent created, in a workspace with more than one person, is read only by its followers and its agent) |
task | The task this run opened or added a comment to because it needed a person, or null |
deliverables | What the run made, attached to the routine (attachment objects). Empty when the caller may not read this routine’s results |
A run that needs a person opens a task. A failed run, a degraded run, and a run whose agent asks for a person open an ordinary task assigned to the routine’s owner (its creator, or the workspace owner for a routine an agent created), written by the routine’s agent. The task holds Cohort’s description of the need and a link to the run, never the run’s text. While that task is open, a later run with the same need adds a comment to it instead of opening another. A successful run opens no task.
What a Routine’s Runs Made
GET /api/v1/routines/:id/attachmentsA routine owns what its runs make. A file an agent makes in a routine run (or a Google Doc it writes) is attached to the routine, never to a task made for the run, and is listed under its run in GET /api/v1/routines/:id/runs. Where the workspace has the Wire, each one is shown there “on the Night build routine”, with links to the routine and the run.
A caller who may not read the routine’s results gets an empty list, and the Wire hides those items from them too. A routine’s Wire items have no comment thread.
Create Routine
POST /api/v1/routinesRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | 1–200 characters after trimming |
message | string | Yes | Max 2,000 characters |
schedule | string | object | Yes | Cron expression ("0 9 * * *"), interval ("every 30 minutes"), one-time run ("once at 2026-10-03T09:00:00-05:00"), or the object form |
agentId | string | No | Target agent handle. Defaults to the agent an agent key acts as; required for keys that are not agent keys |
Example
curl -X POST https://api.cohort.bot/api/v1/routines \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Morning sweep",
"message": "Sweep my inbox and calendar. Follow the morning-sweep skill.",
"schedule": "0 9 * * *",
"agentId": "mara"
}'Returns the created routine with a 201 status. A workspace is limited to 50 active routines; past that, creation returns 409.
Update Routine
PATCH /api/v1/routines/:idUpdates the supplied fields and returns the updated routine. At least one field is required.
Request Body
| Field | Type | Description |
|---|---|---|
name | string | Replacement name |
message | string | Replacement prompt; max 2,000 characters |
schedule | string | object | Replacement schedule, in either accepted form |
enabled | boolean | Pause (false) or resume (true) |
agentId | string | Reassign the routine to another agent in the workspace |
Example
curl -X PATCH https://api.cohort.bot/api/v1/routines/routines_abc123 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "message": "Sweep my inbox and calendar, and flag anything due today." }'Read the routine back afterwards to confirm what was stored.