Agent Routines API
Scheduled and event-triggered routines that run an agent on their own.
List routines
Returns the routines newest first, each with its triggers and run count. The `applicationId` query parameter is optional: when omitted, it is derived from the agent; when given, it must match the application the agent belongs to.
Create routine
The routine needs at least one trigger: `SCHEDULED` (cron, at most every 5 minutes), `API` (on demand via `POST /api/v1/agents/{agentId}/routines/{routineId}/run/`) or `DOCUMENT_EVENT` (fires on document import). An enabled API trigger is added automatically when none is given, so every routine can be run on demand. Cloud Scheduler jobs are created for enabled scheduled triggers.
Get routine with its runs
Returns the routine together with its triggers and its runs, newest first. Use it to poll the status of runs queued via `POST /api/v1/agents/{agentId}/routines/{routineId}/run/`.
Update routine
Partial update: only the provided fields change. When `triggers` is given it replaces the whole set, entries with an id update that trigger, entries without an id are created, and existing triggers left out of the list are deleted. Cloud Scheduler jobs are reconciled to match the resulting scheduled triggers, disabled ones are paused rather than deleted.
Delete routine
Permanently deletes the routine together with its triggers and removes the Cloud Scheduler jobs of its scheduled triggers.
Queue routine run
Requires `Authorization: ApiKey <key>` with the `FULL` or `ROUTINE` scope; session cookies are rejected. The routine must be enabled and have an enabled API trigger. Accepts an optional JSON body `{ text?: string }` (max 10k chars) that is passed to the routine as a prefix to the saved prompt. Answers `202` once the run is queued; the spawned thread and execution ids appear on the run row once the worker finishes.