Workflow templates
A workflow template is a ready-made automation that ships with the gateway. Installing one creates ordinary custom agents and a workflow definition that runs them, with the model and toolset you choose. After the install the agents and the definition are yours. You can edit them, run the definition and upgrade when the gateway ships a newer version of the template.
Workflow templates need a Spanway enterprise license that includes the workflow_templates, custom_agents and workflow_definitions features. Running an installed workflow also needs workflow_runner. Without them every /v1/workflow_templates route answers 403.
Scenario
A payments team wants automated first pass code review on its pull requests but has nobody free to design the agents. They install the code review template from the catalog, pick their own model and a toolset with repository read tools, and ten minutes later a run reviews a pull request. When the catalog ships a better version of the template, the team upgrades in one click and keeps its model, name and sharing.
Steps
-
In the Admin UI open Workflow Runs under Agentic, switch to the Templates tab and read the Catalog. See what ... installs shows the agents, their instructions and the steps.
-
Click Install ..., fill Model, Name (optional), Who can use it and Toolset id (optional), and click Install template. From the API send one
Idempotency-Keyper install so a retry does not install twice.curl -X POST http://localhost:4000/v1/workflow_templates/install \-H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \-H "Idempotency-Key: install-code-review-1" \-d '{"template": "code_review","model": "my-model","model_overrides": {"consolidator": "my-cheaper-model"},"toolset_id": "ts_01J...","name": "Payments code review","visibility": "team","owner_team_id": "team-payments"}' -
Run it. In the Installed table click Run ..., pick Run as key, fill the inputs the workflow asks for and click Start run, or run the installed definition from the API.
curl -X POST http://localhost:4000/v1/workflows/definitions/run \-H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \-d '{"workflow_id": "wf_01J...", "version": 1,"input": {"repository": "example-org/example-service", "pull_request": "42"}}' -
When the Status column says Update available for ..., click the install's name and Upgrade to the current template, or call
POST /v1/workflow_templates/installs/upgradewith theinstall_id.
Expected result
The install answers 200 with the install, the custom agents it created and the saved workflow.
{
"install": {"install_id": "wti_01J...", "template": "code_review", "digest": "sha256:...", "status": "ready", "name": "Payments code review", "visibility": "team", "owner_team_id": "team-payments", "model": "my-model", "model_overrides": {"consolidator": "my-cheaper-model"}, "toolset_id": "ts_01J...", "agents": {"reviewer": {"agent_id": "ca_01J...", "revision": 1}, "consolidator": {"agent_id": "ca_01K...", "revision": 1}}, "workflow_id": "wf_01J...", "workflow_version": 1, "update_available": false},
"missing_optional_connectors": []
}
The agents appear on the Custom agents tab, the workflow on the Saved workflows tab, and a run of it reviews the pull request and reports its findings as the workflow output.
The catalog
| Template | What it does | Connectors it can use |
|---|---|---|
support_triage | Triages a support ticket by category, severity and urgency, then drafts a reply for a human agent to review and send. Input ticket. | Optional: Linear or Atlassian to find duplicate and known issues, Notion or Google Drive to find help articles. |
incident_investigation | The Lens investigator reads the agent traces you can see in Lens for a reported symptom, then a second agent writes an incident summary for responders. Input symptom. Needs agent tracing. | Optional: Sentry for related errors, GitHub, GitLab or Azure DevOps to read suspected code. |
code_review | Reviews a pull request for correctness and security in parallel, then merges both reviews into one ranked list of findings. Inputs repository and pull_request. | Required: GitHub, GitLab or Azure DevOps read tools. |
dsar_intake | Sorts a data subject request by type, identity check and statutory clock, then drafts an acknowledgement and a fulfilment checklist for the privacy team to review and send. Input request. | None. |
tool_run_review | Checks a requested tool run, such as a refund or a production change, against the policy text you pass and writes a short decision packet for a human approver. Inputs tool_run and policy. | None. |
eval_gate | Compares a candidate eval report with your baseline and answers with a first line of Verdict: pass or Verdict: fail plus the regressions that decided it. Inputs baseline_report, candidate_report and thresholds. | None. |
The tool_run_review template only prepares the decision. To make the decision binding, put a human approval policy on the step that runs the tool, so that step waits in awaiting_approval until an approver reads the packet and decides. In CI, run eval_gate from a job after your eval suite and fail the job when the run output does not start with Verdict: pass.
Every template is read-only. The template format cannot name a model, a write tool, a toolset, a skill or a retry, so installing a template never gives an agent more power than its toolset's read tools. Each agent's instructions tell it to treat tickets, traces, diffs and tool results as untrusted data and never to follow instructions found in them.
GET /v1/workflow_templates/list returns each template with its agents, the connectors it can use, its input contract and a digest. GET /v1/workflow_templates/info?name= returns one template in full, including every agent's instructions.
Install a template
curl -X POST http://localhost:4000/v1/workflow_templates/install \
-H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \
-H "Idempotency-Key: install-code-review-1" \
-d '{
"template": "code_review",
"model": "my-model",
"model_overrides": {"consolidator": "my-cheaper-model"},
"toolset_id": "ts_01J...",
"name": "Payments code review",
"visibility": "team",
"owner_team_id": "team-payments"
}'
| Field | Meaning |
|---|---|
template | The template name from the catalog. |
model | The model every agent uses. Your key must be able to call it. |
model_overrides | A different model for some agents, by agent key. |
toolset_id | An MCP toolset you hold a grant on. Only proxy admins create toolsets, templates never do. |
name | The install's name, up to 60 characters. Defaults to the template title. Each agent is named <name> / <agent title>. |
visibility, owner_team_id | private (default), team or org, with the same rules as custom agents. |
Everything is checked before anything is written. The install is refused when your key cannot call a model, when you cannot place agents in that scope, when the toolset does not exist or you hold no grant on it, when a template with Lens tools is installed on a gateway without agent tracing, or when the toolset has no read-only tool from a connector the template requires. A missing required connector answers 400 and names the connectors that would satisfy it. Connectors the template can use but does not require come back in missing_optional_connectors, so you know which agents will work with less context.
A connector counts as met when the toolset holds at least one tool whose server matches one of the listed connector catalogue entries and the catalog marks that tool read-only, which is the same rule that decides what a custom agent is shown at run time.
The install writes its row first, then creates the agents and the definition and marks the install ready. If any step fails, the agents already created are deleted and the row is removed. Sending the same Idempotency-Key again with the same body returns the first install with the Idempotent-Replayed: true header, and sending it with a different body answers 422. Keys are scoped to the calling virtual key.
The response holds the install with its workflow_id and workflow_version, the agents it created by key with their agent_id and revision, and the installer's choices.
Run an installed workflow
An install is an ordinary definition, so it runs like any other:
curl -X POST http://localhost:4000/v1/workflows/definitions/run \
-H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \
-d '{"workflow_id": "wf_01J...", "version": 1,
"input": {"repository": "example-org/example-service", "pull_request": "42"}}'
The run uses the calling key, checks every agent against it and shows up on the Workflow Runs page and in the run ledger like any other run. Each step's timeout is the agent's max_wall_seconds plus a minute, and step budgets add up to no more than the run budget. A step runs once and is never retried.
A trigger can start an installed workflow too. Its input contract has its own fields rather than the trigger envelope, so give the trigger an input_mapping that fills them, for example {"ticket": "payload.fields.ticket"} for a form trigger.
Upgrade an install
When the gateway ships a newer version of a template, update_available is true on the install.
curl -X POST http://localhost:4000/v1/workflow_templates/installs/upgrade \
-H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \
-d '{"install_id": "wti_01J...", "overwrite_edited": false}'
The upgrade keeps the installer's model, overrides, toolset, name and visibility and takes each agent's instructions, built-in tools and limits from the new version. Agents that appear only in the new version are created, agents that no longer appear are deleted, and the definition gets a new version that targets the upgraded agents. Earlier versions of the definition keep their plan, but the agents are upgraded in place, so a run of an older version uses the upgraded agents. A step of an older version that targets an agent the upgrade deleted fails when it runs.
If someone edited one of the install's agents after it was installed, the upgrade answers 409 and names the edited agents. Send "overwrite_edited": true to replace those edits. Each agent is only updated if nobody changed it since the upgrade read it, and only one upgrade or uninstall can hold an install at a time. When a non-admin upgrade changes an agent that a proxy admin had given write tools, the write tools are switched off as with any other change to what the agent does, and write_tools_dropped lists those agents. A proxy admin's upgrade keeps them. An install that never finished installing cannot be upgraded and answers 409, so uninstall it and install it again.
An upgrade that stops part way, for example because someone edited an agent at the same moment, answers with what stopped it and leaves the install on its old version. Run it again with overwrite_edited to finish it.
Uninstall
curl -X POST http://localhost:4000/v1/workflow_templates/installs/delete \
-H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \
-d '{"install_id": "wti_01J..."}'
Uninstalling deletes every agent the install created, then the install. The workflow definition is only deleted when a proxy admin uninstalls, because deleting a definition is a proxy admin action. When anyone else uninstalls, the definition stays in place with workflow_deleted set to false, and a proxy admin can delete it from the definitions page. Past runs stay readable to whoever started them. It answers 409 while another definition pins the install's definition, and changes nothing. Every workflow trigger that starts the install's workflow is turned off with disabled_reason set to template_uninstalled and an audit row, since its agents are gone and its fires could no longer run. Point such a trigger at another definition before you turn it back on. An install that stopped while it was being created (for example because the gateway restarted) can be uninstalled once its ten-minute lock has passed, which deletes the agents it had created and, for a proxy admin, the definition it had saved.
Admin UI
The Templates tab of the Workflow Runs page under Agentic lists the catalog with the connectors each template needs or can use. See what it installs opens the full template, with each agent's instructions and the steps the workflow runs. Install opens a sheet for the model, name, visibility and toolset, and sends one Idempotency-Key per sheet, so a retried click does not install twice. The Installed table shows each install's status, its agents, its workflow and version, and whether an update is available. An install's name opens its detail sheet. When the catalog holds a newer version of the template, the sheet offers Upgrade to the current template, with a checkbox to also replace agents you edited since install. Left unchecked, an edited agent stops the upgrade so your edits are never lost. Run on a ready install opens a form built from the workflow's input contract, with the key the run uses and an optional run budget, and needs the workflow_runner feature. Uninstall asks for a confirmation first. Read-only roles see the catalog and installs but no install, run, upgrade or uninstall button. Without the workflow_templates, custom_agents and workflow_definitions features, the tab names the missing features.
Who can do what
Installs use the same scopes as custom agents and definitions.
| Action | Who |
|---|---|
| See the catalog | Any user with access to agents |
| Install privately | Any user whose role can write |
| Install for a team | An admin of that team or a proxy admin |
Install for an organization (org) | Proxy admins |
| See an install | Its owner, members of its team for team installs, members of its organization for org installs, proxy admins and admin viewers |
| Upgrade or uninstall | Its owner, an admin of its team or a proxy admin |
An org install belongs to the installer's organization, as owner_organization_id, and so do the agents and the definition it creates. An org install that belongs to no organization, including every one made before this change, is visible only to its owner, proxy admins and admin viewers until an upgrade by someone in an organization gives it that organization.
An install you cannot see answers 404, the same as one that does not exist. With custom roles, installing, upgrading and uninstalling need both custom_agents.write and workflows.write, because they create and change custom agents and a workflow definition. The reads are in both the custom_agents and workflows domains. Installs, upgrades and uninstalls each write an audit row against the install, and the agents and definition they create, change or delete write their own audit rows.
| Method | Path | Purpose |
|---|---|---|
| GET | /v1/workflow_templates/list | The template catalog |
| GET | /v1/workflow_templates/info?name= | One template in full |
| GET | /v1/workflow_templates/installs/list | Installs you can see |
| GET | /v1/workflow_templates/installs/info?install_id= | One install |
| POST | /v1/workflow_templates/install | Install a template |
| POST | /v1/workflow_templates/installs/upgrade | Upgrade an install to the catalog's version |
| POST | /v1/workflow_templates/installs/delete | Uninstall |
Data subject requests
Installs are configuration, so no retention period deletes them. Erasing a user through data subject requests keeps their installs, because the agents and workflow belong to a team as much as to the installer, replaces their user id with the pseudonym as owner and editor, and drops the idempotency keys their virtual keys sent. Exports include the installs they own or changed.
Errors
| Status | What it means | Fix |
|---|---|---|
| 403 license message | The license lacks workflow_templates, custom_agents or workflow_definitions. | Add the features to the license or ask sales@spanway.ai. |
| 403 "Your role can read workflow templates but not install them" | A read only role tried to install, upgrade or uninstall. | Use a role with custom_agents.write, or pick a visibility you may use. |
| 404 "Template ... is not in the catalog" | The template name is wrong. | Copy the name from GET /v1/workflow_templates/list. |
| 404 on an install | The install does not exist or is not visible to you. | Check the Installed table. |
| 409 on upgrade | An agent of the install was edited since install and the upgrade would overwrite it. | Tick Also replace agents I edited since install, or send replace_edited_agents: true. |
| 409 "Template install ... is already current" | The install already runs the catalog version. | Nothing to upgrade. |
| 409 "Template install ... is being changed; try again later" | Another upgrade or uninstall of this install is running. | Wait a minute and try again. |
| 409 "Another workflow definition pins this install's workflow" on uninstall | A saved workflow calls the installed one from a step. | Remove that step first. |
| 409 "Template ... is no longer in the catalog" on upgrade | The template was removed from this gateway's catalog. | Keep the install as it is, or uninstall it. |
| 400 | The model is not one you can call, the owner team is not one you administer, a model_overrides key is not an agent of the template, or the toolset lacks a connector the template needs. | Pick a model from your model list and a team you administer, and check the connectors the message names. |
| 422 "Idempotency-Key was already used with a different request" | The same Idempotency-Key came with a different body. | Use a new key for a new install. |
| 422 a field list | The request body breaks its shape, for example an unknown field. | Fix the field the detail names. |
Related
- Workflow Runs page describes the Templates tab.
- Custom agents are what a template installs.
- Workflow definitions hold the installed workflow and its versions.
- Workflow triggers start the installed workflow from a webhook or schedule.
- MCP provides the toolsets the agents use.