# Routines (/docs/routines)

A Routine starts Tasks on a schedule or an event. It holds a prompt and the
settings of the Task it starts (repository, engine, environment, limits),
and one or more triggers. Every fire is a run: a new [Task](/docs/tasks)
with the routine's prompt, or a message delivered into one Task. The
`routines__*` tools read and change routines from any agent client, on the
same `/mcp` seam as everything else, so identity, organization holds,
API-key caps, approvals and activity recording apply.

The Agents area, where Tasks and Routines live, is a preview: it may change
at any time.

## Tools

| Tool                       | Use it for                                                               |
| -------------------------- | ------------------------------------------------------------------------ |
| `routines__list`           | The routines you may see, newest made first, a page at a time.           |
| `routines__get`            | One routine: its fields, its triggers and its last run.                  |
| `routines__runs`           | A routine's runs, newest first: how each was fired, its state, its Task. |
| `routines__create`         | Make a routine from a name, a prompt and optional triggers.              |
| `routines__update`         | Change the fields you give; the rest stay.                               |
| `routines__run`            | Run a routine now, paused or not.                                        |
| `routines__pause`          | Stop its triggers from firing until it is resumed.                       |
| `routines__resume`         | Let its triggers fire again, counted from now, with no backfill.         |
| `routines__archive`        | Take it out of the active list; it stops firing.                         |
| `routines__unarchive`      | Bring an archived routine back as it was.                                |
| `routines__delete`         | Delete an archived routine for good; its past runs and their Tasks stay. |
| `routines__duplicate`      | Copy it, paused, into its own space or another one.                      |
| `routines__add_trigger`    | Add a schedule, a one-time fire, a GitHub event or an API trigger.       |
| `routines__update_trigger` | Change one trigger in place; its kind stays.                             |
| `routines__remove_trigger` | Remove one trigger; fires it had waiting are skipped.                    |

The tools are free: a call costs no credits. The Tasks a routine starts run
on Boxes, billed by their running time as [Billing](/docs/billing)
describes. `routines__run` starts or wakes a Box, so it is held when the
organization has neither credits nor Box allowance left. An archived
routine does not count toward the plan's number of routines.

## Who may see and change a routine

Every routine is in one space. A member sees the routines of the spaces they
are in. A Task and a space API key see the routines of their own space and
of the everyone space. Reading a routine and its runs takes the level `view`
in its space; changing it (an update, a pause, a trigger, an archive) takes
`use`. `routines__runs` shows a run's Task and what it last said only where
you may see that Task.

A routine a Task makes goes into the Task's own space, pins the Task's
environment, and reaches no more tools than the Task does. So does a copy a
Task makes with `routines__duplicate`. A copy in another space needs `view`
on the routine and `use` in that space.

## Triggers

A routine may have several triggers of any kind; any one fires it. With none,
it runs only through `routines__run`.

| `kind`     | Fires                                | Fields                                                                                          |
| ---------- | ------------------------------------ | ----------------------------------------------------------------------------------------------- |
| `schedule` | On a cron.                           | `cron` (5 fields), `timezone` (IANA), `catchup`                                                 |
| `at`       | Once.                                | `fire_at` (epoch ms, in the future), `timezone`                                                 |
| `github`   | On a GitHub event.                   | `gh_event` (`pull_request`, `issues`, `push`, `release`), `gh_actions`, `gh_repo`, `gh_filters` |
| `api`      | On a call to the routine's fire URL. | A bearer token that a member mints in the app.                                                  |

`window_minutes` (0 to 1,440) says how late a fire may still start; without
it, the cadence decides: 15 minutes for hourly, 240 for daily, 720 for
weekly. A schedule's fires that passed their window are skipped, or, with
`catchup: "latest_once"`, the latest one runs. A `github` trigger's filters
match authors, labels, branches (with `*` and `?`), titles, and draft or
merged state.

## Run now

`routines__run` starts a run at once, even for a paused routine. `text` is
added to the prompt for this run (at most 16,000 characters are kept).
`force: true` starts it while an earlier run still goes and the overlap
policy would skip it. `idempotency_key` makes a retry answer the run the
first call started, and start none. The answer is the run's ID and state;
`routines__runs` lists it.

## Errors

| Code                                       | Meaning                                                                                |
| ------------------------------------------ | -------------------------------------------------------------------------------------- |
| `routine_not_found`, `trigger_not_found`   | No routine or trigger with that ID that you can see.                                   |
| `level_too_low`                            | Changing a routine takes `use` in its space; `view` reads it, its runs, and copies it. |
| `space_stopped`                            | The routine's space is closed, or its member left: nothing in it changes.              |
| `routine_archived`, `routine_not_archived` | The routine is archived, or `routines__delete` was asked for a live one.               |
| `routine_name_taken`                       | Another live routine of the space has that name.                                       |
| `routine_changed_since_read`               | `expected_updated_at` is older than the routine: read it again.                        |
| `plan_limit_reached`                       | The plan allows no more routines, or not this Box size.                                |
| `invalid_input`                            | A field breaks a rule; the message names it.                                           |
| `not_configured`                           | Routines, or their Tasks on a member's device, are not available here.                 |
| `unavailable`                              | The service could not be reached; retry in a minute.                                   |

## Elsewhere

[`cs routines`](/docs/cli/routines) has the same routines in a
terminal.

A member turns `routines` off for their own personal space in Dashboard → Tools,
and a team space has its own switch; CoreSpeed can turn it off for a whole
organization. Off, it hides the `routines__*` tools from `tools/list` in that space; see
[Capability controls](/docs/capability-controls).