Agent Routines
Scheduled and event-triggered routines that run an agent on their own.
List routines of an agent
Returns the routines newest first, each with its triggers and run count. `applicationId` must match the application the agent belongs to: a missing value coerces to `0` and matches nothing.
Create a routine for an agent
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 a routine of an agent 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 a routine of an agent
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 a routine of an agent
Permanently deletes the routine together with its triggers and removes the Cloud Scheduler jobs of its scheduled triggers.
Queue an on-demand run of a routine
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.