Custom agents API reference
Routes, request fields, permissions and error codes for custom agents, their versions, conversations, runs, triggers, overrides and policies.
This page lists the custom agents API. For how agents behave and when to use each feature, read Custom agents. For authentication, base paths and tenant scope, read API fundamentals.
Paths below are relative to the workspace:
/api/v1/vegaflow/orgs/{org_id}/workspaces/{workspace_id}Conventions
- Concurrency. Routes that replace a versioned resource take the current resource version in
If-Match. A stale version returns 412. - Idempotency. Asking a question and starting a run require a UUID
Idempotency-Key. Repeating a run start with the same key returns the same run. - Paging. List routes use a keyset
cursorandlimit(1–100) unless noted. - Visibility. Users who may not see a conversation or run receive 404.
- Permissions. Agent permissions are
read,use,edit,publishandadmin. See Permissions for what each one allows.
Agents
| Route | Notes |
|---|---|
POST /agents | Create an agent. Needs workspace-level edit; the creator receives admin on the new agent. |
GET /agents | List agents the caller can read. Supports search, cursor and limit. |
GET /agents/{id} | Metadata, current version ID and number, draft summary, effective permissions and destructive_overrides_active. |
PATCH /agents/{id} | Change display metadata in the draft. |
GET /agents/catalog | Grantable platform tools, workspace connections and connector actions, reviewed MCP tools, enabled skills, model-profile names, and the agents you can call as tools (agents). |
POST /agents/{id}/disable | Refuse new runs. Needs publish. |
POST /agents/{id}/enable | Allow runs again. Needs publish. |
DELETE /agents/{id} | Needs admin. Returns 409 while runs are active. |
POST /agents body:
| Field | Description |
|---|---|
name | Required. Starts with a lowercase letter; 1–64 lowercase letters, digits, underscores or hyphens. Unique within the workspace; vega_ai is reserved. |
display_name, description, icon | Optional display metadata. |
draft | Initial definition using vega.agent/v1.1. |
List items and GET /agents/{id} include a draft summary: resource version, digest, updater and update time. The full definition comes from GET /agents/{id}/draft.
Drafts and versions
| Route | Notes |
|---|---|
GET /agents/{id}/draft | Read the full draft definition and its resource version. |
PUT /agents/{id}/draft | Replace the draft. Needs edit and If-Match. Drafts may be incomplete. |
POST /agents/{id}/draft/validate | Return validation errors with paths. Needs edit. |
POST /agents/{id}/versions | Publish the draft. Needs publish, If-Match with the draft resource version, and optional notes. |
GET /agents/{id}/versions | List published versions. Draft snapshots are excluded. |
GET /agents/{id}/versions/{version_id} | Read one version. |
PUT /agents/{id}/current-version | Select the current release with {"version_id": "uuid"}. Needs publish. |
Each version has a sequential number, a digest, its publisher, publication time and notes. Publishing an unchanged digest returns the existing version.
Definition fields
These definition fields are referred to across the custom agents docs:
| Field | Description |
|---|---|
triggers | How runs of a published version may start: chat, api, schedule, event, agent. |
tools.agents[] | Up to 10 other agents to call: agent (name), mode (tool or task), optional version (published version number) and description. |
tools.core | The tools that load up front; the rest are left to tool search. When omitted, platform and agent tools load up front (at most 30 in all). |
output.schema | JSON Schema the final answer must satisfy in runs without a chat. |
approval.assignees | Up to 20 {"type": "user" | "group", "id": "uuid"} entries that decide approvals for runs without a chat. |
approval.on_expiry | reject (default) or fail. |
Permissions
| Route | Notes |
|---|---|
GET /agents/{id}/permissions | List grants. |
POST /agents/{id}/permissions | Grant to users, groups and roles using the standard permissions request schema. Needs admin. |
DELETE /agents/{id}/permissions | Revoke a grant. Needs admin. |
Unknown permissions and service-principal entries return 422 with field paths.
Conversations and questions
| Route | Notes |
|---|---|
POST /agents/{id}/conversations | Start a conversation. Body: version (published version UUID, "draft", or omitted for the current version) and optional approval_mode. |
GET /agents/{id}/conversations/{conversation_id} | Read a conversation. |
GET /agents/{id}/conversations/{conversation_id}/questions | List questions. |
POST /agents/{id}/conversations/{conversation_id}/questions | Ask. Requires Idempotency-Key. Owner only. |
GET /agents/{id}/questions/{question_id} | Read a question. |
POST /agents/{id}/questions/{question_id}/cancel | Cancel. Owner only. |
POST /agents/{id}/questions/{question_id}/messages | Steer a running question. Owner only. |
GET /agents/{id}/questions/{question_id}/events | SSE stream, or JSON replay with Accept: application/json. Supports cursor and Last-Event-ID. |
Question and event schemas match Turing question events. Permission needed to start a conversation:
| Version | Needs |
|---|---|
| Current published version | use |
| Older published version | use plus edit or publish |
"draft" | edit and a valid draft |
Event requests recheck permissions before waiting. A revocation takes effect on the next request after the current wait window, at most 25 seconds. Conversation listing and forking are not available for custom agents.
Background tasks
| Route | Notes |
|---|---|
GET /agents/{id}/conversations/{conversation_id}/tasks | List the conversation's tasks, newest first. limit 1–100, default 50. Needs read access to the conversation. |
GET /agents/{id}/conversations/{conversation_id}/tasks/{task_id} | One task, with its result when you can see the task run's content. |
POST /agents/{id}/conversations/{conversation_id}/tasks/{task_id}/cancel | Cancel a task. Needs the conversation's owner or an agent admin. |
Each task has a follow_up: pending, started, coalesced, or skipped_<reason> (for example skipped_unattended or skipped_version_changed).
Every finished task publishes vegaflow.agent_task.completed on the workspace event bus with task_id, agent_id, run_id, conversation_id and status. The output is not included.
Runs
| Route | Notes |
|---|---|
POST /agents/{id}/runs | Start a run without a chat. Needs use. Requires Idempotency-Key. Returns 202 with the run summary. |
GET /agents/runs | List runs across the workspace's custom agents. |
GET /agents/{id}/runs | List one agent's runs. |
GET /agents/{id}/runs/{run_id} | Run summary. Poll until the run ends. |
GET /agents/{id}/runs/{run_id}/trace | Ordered run steps. Runs with more than 500 steps page with cursor. |
POST /agents/{id}/runs body:
| Field | Description |
|---|---|
input | Any JSON value, at most 256 KiB. |
message | Optional text, at most 32 KiB. |
version | Optional published version number. Defaults to the current version; draft is refused. |
approval_mode | ask (default) or auto. |
Run list filters (both lists are newest first): agent_id (workspace list only), status, trigger (chat, api, schedule, event, agent, task_completion), root_run_id, run_as_user_id, version (a number or draft), from and to on request time, labels (tainted, sensitive) and has_approval. Built-in Turing runs are not included.
Run summary
| Field | Description |
|---|---|
| Status, trigger, pinned version, run-as user, timings | Always present. |
| Token totals | Input, output, cache read and cache write. |
cost_usd | null when unpriced; cost_partial is set when only some calls are priced. |
| Approval count and wait time, trust labels, error | Always present. |
input, output | Runs without a chat. Shown to the run-as user only. output is the validated output. |
trigger_id | Scheduled and event runs. |
root_run_id, depth | Every run. |
parent_run_id | Runs started by another agent. |
descendant_usage | Tokens and cost of the runs this run called and waited for. |
task_id | A background task's run. |
task_ids | A question the agent asked itself after tasks finished. |
Trace steps
The trace lists, in order: the question; model calls (profile, model, attempt, outcome, tokens, cost, compaction); tool calls; approvals; data access; label changes; the answer; and errors.
Each tool call step has the tool, source, effect, connection, policy decision with reasons and policy versions, approval state and decider, and output trust. Code-mode calls nest under their parent. Agent calls add child_run (called agent, version, run ID and status), plus task_id when the call started a background task.
The run owner sees content: question, answer, thinking, tool arguments, and result previews of up to 8 KiB per step. An agent admin viewing another user's run gets redacted: true: no question or answer text, an arguments digest instead of arguments, and table names and row counts instead of SQL.
Triggers
Schedules and event triggers share these routes. kind cannot change after creation.
| Route | Notes |
|---|---|
GET /agents/{id}/triggers | Needs read. |
GET /agents/{id}/triggers/{trigger_id} | Needs read. |
POST /agents/{id}/triggers | Needs publish. The caller becomes the owner, and the owner needs use. |
PUT /agents/{id}/triggers/{trigger_id} | Save changes with If-Match. See owner rules. |
DELETE /agents/{id}/triggers/{trigger_id} | Needs publish. Runs already started carry on. |
POST /agents/{id}/triggers/{trigger_id}/run-now | Start a run immediately. Owner only, with publish. Schedules only. |
POST /agents/{id}/triggers/{trigger_id}/take-ownership | Needs admin. Resets approval_mode to ask. |
GET /agents/{id}/triggers/{trigger_id}/firings | Starts, newest first, with cursor and limit. Event firings carry event_id. |
Firing outcomes: started (with the run ID), skipped_limit, skipped_overlap, or refused with a code. A refused start pauses the trigger and sets paused_reason.
Schedule fields
| Field | Description |
|---|---|
name | Trigger name. |
version_mode | current (follows new publishes) or pinned with pinned_version_id. |
input, message | Stored input and optional message for each run. |
approval_mode | ask or auto. |
enabled | Turn the trigger on or off. |
schedule.schedule_kind | cron, interval (with interval_seconds) or calendar. |
schedule.timezone | Defaults to UTC. |
schedule.overlap_policy | SKIP (default) or ALLOW. |
schedule.missed_run_policy | SKIP (default), LATEST or CATCH_UP. |
Event trigger fields
Send kind: "event". input and schedule are refused.
| Field | Description |
|---|---|
event_match.types | 1–10 type globs. * matches one segment, or every remaining segment when it comes last. |
event_match.subject | Optional: urn, urn_prefix or kinds. |
event_match.targets_any | Optional URNs matched against the event's data.targets. |
event_match.condition | Optional CEL expression over event, data and subject. |
input_template | Optional JSON object rendered for each event; any value may be {"$cel": "<expr>"}. Without it, the input is the event's id, type, time, data and source, with the subject in metadata. |
message, version_mode, approval_mode, enabled | As for schedules. |
Event triggers fire only while platform events are on for the workspace: GET and PUT /pipeline-triggers/settings, field platform_events_enabled.
DESTRUCTIVE overrides
| Route | Notes |
|---|---|
GET /agents/{id}/destructive-overrides | Needs read. Lists active overrides; include_revoked=true adds revoked ones. |
POST /agents/{id}/destructive-overrides | Needs admin and the caller's own access to the tool. One active override per tool; a duplicate returns 409. |
DELETE /agents/{id}/destructive-overrides/{override_id} | Needs admin. Revokes from the next call. Revoked overrides stay listed. |
POST body:
| Field | Description |
|---|---|
tool | A tool key with no wildcards. Must be a DESTRUCTIVE grant of the current published version, on a connection with ai_access=allowed_destructive. |
acknowledgement | Exactly run <tool> without approval in unattended runs. |
A call an override allows is recorded as an approval with decision_via: "destructive_override" and the override's ID in the decision reasons.
Policies
| Route | Notes |
|---|---|
POST /agents/policies | Create a policy. |
POST /agents/policies/compile | Return the Cedar text and any issues without saving. |
GET /agents/policies | List policies you can read. |
GET /agents/policies/{policy_id} | One policy, with an ETag. |
PUT /agents/policies/{policy_id} | Save a new version with If-Match. |
GET /agents/policies/{policy_id}/versions | List versions. |
POST /agents/policies/{policy_id}/versions/{version}/restore | Save an old version as the newest one. |
DELETE /agents/policies/{policy_id} | Stop the policy at once, including for running runs. Versions stay for audit. |
An agent policy needs admin on that agent. A workspace policy needs workspace-level agent admin.
POST /agents/policies body:
| Field | Description |
|---|---|
name, enabled | Required. |
agent_id | Optional. Omit for a workspace policy. |
kind | form (a preset with fields, compiled to Cedar and stored with it) or cedar (raw Cedar text; workspace-level agent admins only). Cedar permits may carry @auto_approve or @approval. |
Form presets are auto_approve, require_approval (named tools or an effect class), deny (named tools or connections), row_limit (max_rows) and exempt_rule_of_two. See Policies for what each does.
Tool keys
Policies and overrides name tools with these keys:
| Tool | Key |
|---|---|
| Platform tool | Its name, such as vegadb.query. |
| Connector action | connector_action/{connection}/{connector}/{action} |
| MCP tool | mcp/{connection}/{tool} |
| Another agent | agent/<agent_id> |
| Task tools | task/status, task/wait, task/result, task/cancel |
A full tool ID with an @version or @digest suffix is accepted and matched without the suffix, so policies keep applying when an action or MCP tool changes.
Decision log
GET /agents/decisions lists policy decisions for custom agents' tool calls, newest first. Filters: agent_id, outcome (allow, approval, deny), tool, from and to. It needs admin on at least one agent and shows only decisions for agents you administer.
Each entry names the run, tool, effect, outcome, reasons, matching policies with their versions, and whether the Rule of Two applied. Entries follow the normal retention policy.
Error codes
| Status | Code | Cause |
|---|---|---|
| 403 | AGENT_RUN_AS_UNSUPPORTED | A service principal tried to start a run. |
| 403 | AGENT_TRIGGER_OWNER_REQUIRED | A non-owner tried to change what a trigger runs as. |
| 409 | AGENT_VERSION_CHANGED | A use-only owner asked or steered after the current version changed. Message: "This agent's version changed; start a new conversation." |
| 409 | AGENT_CONVERSATION_NOT_CHAT | Asking into or steering the conversation of a run without a chat. |
| 409 | — | Duplicate active DESTRUCTIVE override, or deleting an agent with active runs. |
| 412 | AGENT_POLICY_VERSION_CONFLICT | Stale policy version. Other stale If-Match versions also return 412. |
| 422 | AGENT_TRIGGER_NOT_ENABLED | The version does not list the trigger. Also reported at tools.agents[i] when a called agent does not list agent. |
| 422 | AGENT_UNATTENDED_PERSONAL_CONNECTION | A run without a chat uses a version that grants a personal connection. |
| 422 | AGENT_EVENT_RUN_NOW_UNSUPPORTED | Run-now on an event trigger. |
| 422 | AGENT_OVERRIDE_ACK_REQUIRED | Wrong acknowledgement phrase. The expected phrase is in detail. |
| 422 | AGENT_OVERRIDE_TOOL_INVALID | The override's tool is not an eligible DESTRUCTIVE grant. |
| 422 | AGENT_TOOL_CYCLE, AGENT_TOOL_DEPTH | Publishing or selecting a version would create a call loop or nest more than three agents deep. |
| 422 | AGENT_POLICY_INVALID | Invalid policy, with field paths. |
| 429 | AGENT_RUN_LIMIT | The workspace limit on runs without a chat was reached. Honor Retry-After. |
| — | AGENT_PUBLISH_AUTHORITY | Reported at tools.agents[i] by validation and publication when the publisher lacks use on a called agent. |
| — | AGENT_OUTPUT_INVALID | The answer did not satisfy output.schema; the run ends FAILED. |
| — | AGENT_APPROVAL_EXPIRED | An approval expired with on_expiry: fail; the run ends FAILED. |
| — | AGENT_USE_REQUIRED | A trigger start was refused because the owner no longer holds use. Recorded in paused_reason. |
| — | AGENT_EVENT_NOT_OBSERVABLE | The trigger owner can no longer see the matched events. The trigger pauses. |
| — | AGENT_EVENT_TEMPLATE_FAILED | A condition or template failed on an event. That start is refused; the trigger stays on. |
| — | AGENT_CHILD_INTERACTION_UNSUPPORTED | A called agent asked for something other than an approval. |
| — | AGENT_TASK_LIMIT | Tool error: too many background tasks running. |
| — | AGENT_TASK_NESTING_UNSUPPORTED | Listed in a trace's withheld_tools when task tools are withheld inside a task. |
A dash in the Status column means the code appears in a run, trigger, trace or validation result rather than as an HTTP response.