Update Template Api V1 Workstreams Templates Template Id Patch
patch
/api/v1/workstreams/templates/{template_id}Update template
Updates the fields you send on an existing workflow template and returns the
saved template at its new version.
Only provided fields will be updated. Omitted fields remain unchanged.
Pass ``expected_version`` to write only if the WorkStream is still at the
version you reviewed; otherwise nothing is written and the response is 409.
A WorkStream whose source is managed is saved as one commit in your name,
not as a new version. Send ``expected_head`` (the head you loaded) so a save
made by someone else since is refused with 409 ``stale_head``; a change to
the definition with neither ``expected_head`` nor ``expected_version`` is
refused with 409 ``expected_head_required``. Changes to sharing, status and
runner settings are written to the row and make no commit.
**Authentication Required:** JWT Bearer token
Path parameters
template_idrequiredpath | The template's UUID. |
Query parameters
expected_headquery | The commit the caller loaded. A save of a managed WorkStream is refused with 409 `stale_head` when the working branch has moved on since; ignored for a WorkStream whose source is not managed. |
Header parameters
Idempotency-Keyheader | Names one save of a managed WorkStream. Sent again with the same key it makes no second commit and answers with the first; ignored for a WorkStream whose source is not managed. |
Request bodyapplication/json
| Field | Type | Description |
|---|---|---|
name | string | null | Template name |
description | string | null | Template description |
source_description | string | null | The definition's own text, verbatim. |
source_name | string | null | The definition's own name, verbatim. |
category | "compliance" | "advisory" | "audit" | "bookkeeping" | "tax" | "internal" | null | Template category (closed taxonomy; off-taxonomy input is mapped) |
steps | TaskStepDefinition | ToolCallStepDefinition | ArchieQueryStepDefinition | NotifyStepDefinition | ConditionalStepDefinition | LoopStepDefinition | ParallelStepDefinition | ApprovalStepDefinition | DocumentUploadStepDefinition | StageStepDefinition | GotoStepDefinition | SubWorkStreamStepDefinition | DeterministicExtractionStepDefinition | VerificationStepDefinition | EmailSendStepDefinition | WaitForReplyStepDefinition | SkillStepDefinition | AgentRunStepDefinition | WaitStepDefinition | WebhookStepDefinition | FormStepDefinition | FileStepDefinition[] | null | WDL step definitions |
tags | string[] | null | Template tags |
input_schema | object[] | null | Declared workstream inputs (array of InputDef). |
output_schema | object[] | null | Declared workstream outputs (array of OutputDef). |
inputs_required | any[] | null | Declared inputs the WorkStream needs before it can run. |
data_files | object | null | Data files kept with the WorkStream: layouts/<name>.json to a JSON object. Omit to leave them unchanged; {} removes every file. |
runner_config | object | null | Runner settings. |
execution_mode | "inline" | "containerized" | null | How the WorkStream runs. |
jurisdictions | string[] | null | Applicable jurisdictions. |
status | "draft" | "active" | "paused" | "archived" | null | Template status |
goal_spec | GoalSpecPayload | null | Goal contract scored by the deterministic goal gate. Omit to leave the existing goal untouched; the tolerances a reviewer already approved must not change just because an unrelated field did. |
spec | Spec | null | The WSS spec (decisions + compiled bindings) for the new version. Persisted with spec_hash and definition_hash on the version snapshot. Every cited document_id must be an upload in this workspace. Omit to keep the latest version's spec (definition_hash recomputed over the new steps). |
change_summary | string | null | Caller-supplied version-history note (e.g. 'Revised from cycle <id>: …'). Falls back to the auto-computed field list when omitted. |
accounting_ledger | "off" | "optional" | "required" | null | Change the Cycle Accounting Ledger capability. Omit to preserve it; use off for WorkStreams that do not need a Ledger. |
shared_with_user_ids | string[] | null | User IDs granted editor rights to this workstream definition. |
expected_head | string | null | The head of the working branch the caller loaded (`working_branch_head` of the read). A managed save is refused with 409 `stale_head` when the branch has moved on; the query parameter of the same name wins when both are sent. |
expected_version | integer | null | The version the caller read and reviewed. When given, the update is written only if the WorkStream is still at exactly this version; otherwise nothing is written and the response is 409 with error_code 'template_version_changed' and the current version. Omit for the previous last-write-wins behaviour. |
Responses
200Template updated successfully
| Field | Type | Description |
|---|---|---|
idrequired | string (uuid) | Template UUID |
slug | string | null | Human-readable URL key (e.g. 'asc-606-review'). Stable + globally unique; resolvable by GET /templates/{id}. Link the FE here, not the UUID. |
permakey | string | null | Stable opaque short id (7-char); the cross-entity permalink, also resolvable. |
namerequired | string | Template name |
description | string | null | Template description |
source_description | string | null | The definition's own text, verbatim (the audit-true record of what was authored). Disclosed behind 'The definition, as written', in mono — never the firm-facing head. NULL when the definition has no prose distinct from the interpreted description. |
source_name | string | null | The definition's own name, verbatim. Disclosed alongside source_description when it differs from the firm-facing name. |
category | "compliance" | "advisory" | "audit" | "bookkeeping" | "tax" | "internal" | null | Template category (closed taxonomy: compliance/advisory/audit/bookkeeping/tax/internal). NULL = genuinely uncategorised (no category set); 'internal' = an off-taxonomy value mapped to the catch-all bucket — the two are distinct (NULL is NOT coerced to 'internal'). |
steps | object[] | WDL step definitionsitem shapeEmpty object. |
default_config | object | Default configurationshow nestedEmpty object. |
goal_spec | GoalSpecPayload-Output | object | null | The versioned deterministic goal contract. This is definition state, not cycle output, and must round-trip through every authoring surface. |
accounting_ledger | "off" | "optional" | "required" | The WorkStream's explicit Cycle Accounting Ledger capability.offoptionalrequired |
tags | string[] | Template tags |
input_schema | object[] | Declared workstream inputs (array of InputDef: name/type/required/...).item shapeEmpty object. |
families | object[] | —item shapeEmpty object. |
data_files | object | null | The WorkStream's data files; null on the list route. |
broker_option_names | object | Maps each family_id@version choice of a select input in input_schema to its broker family's stored display name. A family with no stored name is omitted; the choice values themselves are unchanged. Filled by the single-template route only; empty elsewhere.show nestedEmpty object. |
output_schema | object[] | Declared workstream outputs for the Outputs tab (array of OutputDef: name/label/type/format/...). Empty ⇒ no Outputs tab.item shapeEmpty object. |
inputs_required | any[] | null | Declared inputs the WorkStream needs before it can run (part of the hashed definition). |
runner_config | object | null | Runner settings for the WorkStream (part of the hashed definition). {} when none. |
execution_mode | "inline" | "containerized" | null | How the WorkStream runs (part of the hashed definition). |
jurisdictions | string[] | null | Applicable jurisdictions (part of the hashed definition). |
forked_from | object | null | Provenance: parent recipe {name, version} this was forked from. NULL when not a fork. |
upstream_update | object | null | {version, note} when the fork's parent has advanced past the fork point. NULL when none/uncomputable. |
is_template | boolean | Always true for templates |
domain | string | null | DomainAgent knowledge-key backing this recipe (e.g. 'ita_2007_eis'), resolved from the linked job_definition.domain via its most-recent cycle and surfaced ONLY when it maps to a real DomainAgent persona. NULL for fixed-step recipes and generic agentic containers (the 'workstream'/'general' placeholder domains) — which are NOT WorkPlan-able. The WorkPlan-create picker filters to `domain != null`. |
statusrequired | "draft" | "active" | "paused" | "archived" | Status for workstream entities.draftactivepausedarchived |
version | integer | Template version, incremented on each update |
active_blueprint_count | integer | Number of active linked workplans for this template |
total_runs | integer | Count of cycles ever launched from this template (run count). |
total_instances | integer | Aggregate instance count across all cycles. Each backend cycle is one instance run, so this equals total_runs today; kept distinct so the FE contract is stable if job-level fan-out grouping lands later. |
last_run_at | string (date-time) | null | Start (or creation) timestamp of the most recent cycle. NULL if never run. |
last_run_state | "created" | "planning" | "queued" | "running" | "paused" | "blocked" | "completed" | "failed" | "cancelled" | "skipped" | "pending" | "needs_guidance" | "abandoned" | "debug_paused" | null | Status of the most recent cycle, for the 'last run' badge. NULL if never run. |
avg_instance_cost | number | Average customer-facing cost (GBP) across runs: mean of £19/hr x elapsed per cycle. Mirrors CycleResponse.customer_cost_gbp. |
cycle_ids | string (uuid)[] | Cycle ids that have run this template, most recent first (capped). |
needs_you_count | integer | Instances of this WorkStream parked at an approval gate, waiting on a person. APPROVALS ONLY — blocked (waiting on the client) and errored (needs a retry) are different asks and are counted elsewhere, so the orange attention number means the same thing on the list card, the WorkStream page and a cycle's triage. |
needs_you_job_id | string (uuid) | null | The batch holding the most of those approvals — the DOOR the attention chip opens, so the count is never a claim the user then has to hunt for. NULL when needs_you_count is 0, and ALSO null when the gated instances belong to no batch (a standalone run has no fan-out to open). A non-zero count with a null door is therefore expected: fall back to the WorkStream's own Cycles tab, which is always reachable — never render the count as unclickable. |
source_managed | boolean | The WorkStream is saved to git (every save is a commit). |
working_branch_head | string | null | The head of the working branch (40 lower-case hex) of a managed WorkStream: send it back as `expected_head` with the next save. |
published | boolean | null | Always false on a managed save answer: saved, not yet published. |
unpublished_saves | integer | null | Commits on the working branch that main does not yet hold; null when it could not be read. |
latest_version | integer | null | The WorkStream's own version; a save never changes it. |
head | string | null | The head after this save (a managed save only). |
save_message | string | null | "Saved. Not published: N change(s) since version V." (a managed save only). |
created_byrequired | string (uuid) | Creator user ID |
created_by_name | string | null | Creator display name |
owner_user_id | string | null | The user who owns (and alone grants edit rights on) this definition. |
shared_with_user_ids | string[] | Users the owner granted edit rights on this definition. |
created_atrequired | string (date-time) | Creation timestamp |
updated_atrequired | string (date-time) | Last update timestamp |
scope | string | Distribution scope: gallery|firm|team|user|plan (provenance pill). |
is_catalog | boolean | True for curated public library recipes (the seeded catalog). |
owning_team_id | string (uuid) | null | The team a `scope='team'` workstream belongs to — lets the FE group the My WorkStreams list under the team name (#170). NULL for firm/user-scoped rows. |
workspace_id | string (uuid) | null | Workspace ID owning this template, or NULL for catalog/curated recipes |
lint | string[] | ADVISORY structural findings for the saved step set — duplicate ids, dangling depends_on, dependency cycles, unresolvable references. Entries prefixed `warn:` are advisory by the linter's own tiering. This NEVER blocks a save and an empty list is not a guarantee: see the note on the update handler for why a hard gate would be wrong against today's stored data. |
400Invalid request data
401Unauthorized
403Not permitted to edit this WorkStream (code `not_permitted`)
404Template not found
409expected_version given and the WorkStream is at another version, or a managed save refused: `stale_head`, `expected_head_required`, `no_firm`
422A managed save refused: `content_refused`
503A managed save could not be checked: `fga_unavailable`, `could_not_check`
curl https://api.dev.arch.ie/api/v1/workstreams/templates/<template_id> \
-X PATCH \
-H "Authorization: Bearer sk_..." \
-H "Content-Type: application/json" \
-d '{
"name": null,
"description": null,
"source_description": null,
"source_name": null,
"category": null,
"steps": null,
"tags": null,
"input_schema": null,
"output_schema": null,
"inputs_required": null,
"data_files": null,
"runner_config": null,
"execution_mode": null,
"jurisdictions": null,
"status": null,
"goal_spec": null,
"spec": null,
"change_summary": null,
"accounting_ledger": null,
"shared_with_user_ids": null,
"expected_head": null,
"expected_version": null
}'