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 cursor and limit (1–100) unless noted.
  • Visibility. Users who may not see a conversation or run receive 404.
  • Permissions. Agent permissions are read, use, edit, publish and admin. See Permissions for what each one allows.

Agents

RouteNotes
POST /agentsCreate an agent. Needs workspace-level edit; the creator receives admin on the new agent.
GET /agentsList 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/catalogGrantable 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}/disableRefuse new runs. Needs publish.
POST /agents/{id}/enableAllow runs again. Needs publish.
DELETE /agents/{id}Needs admin. Returns 409 while runs are active.

POST /agents body:

FieldDescription
nameRequired. Starts with a lowercase letter; 1–64 lowercase letters, digits, underscores or hyphens. Unique within the workspace; vega_ai is reserved.
display_name, description, iconOptional display metadata.
draftInitial 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

RouteNotes
GET /agents/{id}/draftRead the full draft definition and its resource version.
PUT /agents/{id}/draftReplace the draft. Needs edit and If-Match. Drafts may be incomplete.
POST /agents/{id}/draft/validateReturn validation errors with paths. Needs edit.
POST /agents/{id}/versionsPublish the draft. Needs publish, If-Match with the draft resource version, and optional notes.
GET /agents/{id}/versionsList published versions. Draft snapshots are excluded.
GET /agents/{id}/versions/{version_id}Read one version.
PUT /agents/{id}/current-versionSelect 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:

FieldDescription
triggersHow 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.coreThe 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.schemaJSON Schema the final answer must satisfy in runs without a chat.
approval.assigneesUp to 20 {"type": "user" | "group", "id": "uuid"} entries that decide approvals for runs without a chat.
approval.on_expiryreject (default) or fail.

Permissions

RouteNotes
GET /agents/{id}/permissionsList grants.
POST /agents/{id}/permissionsGrant to users, groups and roles using the standard permissions request schema. Needs admin.
DELETE /agents/{id}/permissionsRevoke a grant. Needs admin.

Unknown permissions and service-principal entries return 422 with field paths.

Conversations and questions

RouteNotes
POST /agents/{id}/conversationsStart 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}/questionsList questions.
POST /agents/{id}/conversations/{conversation_id}/questionsAsk. Requires Idempotency-Key. Owner only.
GET /agents/{id}/questions/{question_id}Read a question.
POST /agents/{id}/questions/{question_id}/cancelCancel. Owner only.
POST /agents/{id}/questions/{question_id}/messagesSteer a running question. Owner only.
GET /agents/{id}/questions/{question_id}/eventsSSE 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:

VersionNeeds
Current published versionuse
Older published versionuse 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

RouteNotes
GET /agents/{id}/conversations/{conversation_id}/tasksList 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}/cancelCancel 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

RouteNotes
POST /agents/{id}/runsStart a run without a chat. Needs use. Requires Idempotency-Key. Returns 202 with the run summary.
GET /agents/runsList runs across the workspace's custom agents.
GET /agents/{id}/runsList one agent's runs.
GET /agents/{id}/runs/{run_id}Run summary. Poll until the run ends.
GET /agents/{id}/runs/{run_id}/traceOrdered run steps. Runs with more than 500 steps page with cursor.

POST /agents/{id}/runs body:

FieldDescription
inputAny JSON value, at most 256 KiB.
messageOptional text, at most 32 KiB.
versionOptional published version number. Defaults to the current version; draft is refused.
approval_modeask (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

FieldDescription
Status, trigger, pinned version, run-as user, timingsAlways present.
Token totalsInput, output, cache read and cache write.
cost_usdnull when unpriced; cost_partial is set when only some calls are priced.
Approval count and wait time, trust labels, errorAlways present.
input, outputRuns without a chat. Shown to the run-as user only. output is the validated output.
trigger_idScheduled and event runs.
root_run_id, depthEvery run.
parent_run_idRuns started by another agent.
descendant_usageTokens and cost of the runs this run called and waited for.
task_idA background task's run.
task_idsA 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.

RouteNotes
GET /agents/{id}/triggersNeeds read.
GET /agents/{id}/triggers/{trigger_id}Needs read.
POST /agents/{id}/triggersNeeds 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-nowStart a run immediately. Owner only, with publish. Schedules only.
POST /agents/{id}/triggers/{trigger_id}/take-ownershipNeeds admin. Resets approval_mode to ask.
GET /agents/{id}/triggers/{trigger_id}/firingsStarts, 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

FieldDescription
nameTrigger name.
version_modecurrent (follows new publishes) or pinned with pinned_version_id.
input, messageStored input and optional message for each run.
approval_modeask or auto.
enabledTurn the trigger on or off.
schedule.schedule_kindcron, interval (with interval_seconds) or calendar.
schedule.timezoneDefaults to UTC.
schedule.overlap_policySKIP (default) or ALLOW.
schedule.missed_run_policySKIP (default), LATEST or CATCH_UP.

Event trigger fields

Send kind: "event". input and schedule are refused.

FieldDescription
event_match.types1–10 type globs. * matches one segment, or every remaining segment when it comes last.
event_match.subjectOptional: urn, urn_prefix or kinds.
event_match.targets_anyOptional URNs matched against the event's data.targets.
event_match.conditionOptional CEL expression over event, data and subject.
input_templateOptional 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, enabledAs 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

RouteNotes
GET /agents/{id}/destructive-overridesNeeds read. Lists active overrides; include_revoked=true adds revoked ones.
POST /agents/{id}/destructive-overridesNeeds 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:

FieldDescription
toolA tool key with no wildcards. Must be a DESTRUCTIVE grant of the current published version, on a connection with ai_access=allowed_destructive.
acknowledgementExactly 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

RouteNotes
POST /agents/policiesCreate a policy.
POST /agents/policies/compileReturn the Cedar text and any issues without saving.
GET /agents/policiesList 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}/versionsList versions.
POST /agents/policies/{policy_id}/versions/{version}/restoreSave 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:

FieldDescription
name, enabledRequired.
agent_idOptional. Omit for a workspace policy.
kindform (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:

ToolKey
Platform toolIts name, such as vegadb.query.
Connector actionconnector_action/{connection}/{connector}/{action}
MCP toolmcp/{connection}/{tool}
Another agentagent/<agent_id>
Task toolstask/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

StatusCodeCause
403AGENT_RUN_AS_UNSUPPORTEDA service principal tried to start a run.
403AGENT_TRIGGER_OWNER_REQUIREDA non-owner tried to change what a trigger runs as.
409AGENT_VERSION_CHANGEDA use-only owner asked or steered after the current version changed. Message: "This agent's version changed; start a new conversation."
409AGENT_CONVERSATION_NOT_CHATAsking into or steering the conversation of a run without a chat.
409—Duplicate active DESTRUCTIVE override, or deleting an agent with active runs.
412AGENT_POLICY_VERSION_CONFLICTStale policy version. Other stale If-Match versions also return 412.
422AGENT_TRIGGER_NOT_ENABLEDThe version does not list the trigger. Also reported at tools.agents[i] when a called agent does not list agent.
422AGENT_UNATTENDED_PERSONAL_CONNECTIONA run without a chat uses a version that grants a personal connection.
422AGENT_EVENT_RUN_NOW_UNSUPPORTEDRun-now on an event trigger.
422AGENT_OVERRIDE_ACK_REQUIREDWrong acknowledgement phrase. The expected phrase is in detail.
422AGENT_OVERRIDE_TOOL_INVALIDThe override's tool is not an eligible DESTRUCTIVE grant.
422AGENT_TOOL_CYCLE, AGENT_TOOL_DEPTHPublishing or selecting a version would create a call loop or nest more than three agents deep.
422AGENT_POLICY_INVALIDInvalid policy, with field paths.
429AGENT_RUN_LIMITThe workspace limit on runs without a chat was reached. Honor Retry-After.
—AGENT_PUBLISH_AUTHORITYReported at tools.agents[i] by validation and publication when the publisher lacks use on a called agent.
—AGENT_OUTPUT_INVALIDThe answer did not satisfy output.schema; the run ends FAILED.
—AGENT_APPROVAL_EXPIREDAn approval expired with on_expiry: fail; the run ends FAILED.
—AGENT_USE_REQUIREDA trigger start was refused because the owner no longer holds use. Recorded in paused_reason.
—AGENT_EVENT_NOT_OBSERVABLEThe trigger owner can no longer see the matched events. The trigger pauses.
—AGENT_EVENT_TEMPLATE_FAILEDA condition or template failed on an event. That start is refused; the trigger stays on.
—AGENT_CHILD_INTERACTION_UNSUPPORTEDA called agent asked for something other than an approval.
—AGENT_TASK_LIMITTool error: too many background tasks running.
—AGENT_TASK_NESTING_UNSUPPORTEDListed 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.

Vegalake, VegaDB and VegaFlow are trademarks or registered trademarks of Vegalake Inc.

On this page