Templates
A template is a workflow saved under a name and versioned. Save the steps once, run them by name, nest one template in another, and change it by saving a new version.
A template is a workflow saved under a name. Every application runs it by name, and you change it by saving a new version. Nothing is edited in place.
The shape
{
"name": "customer-support",
"description": "Messages to an external support model",
"steps": [
{ "op": "detect.secrets.credentials", "block": true },
{ "op": "detect.prompt.injection", "block": true },
"detect.pii.entities",
"extract.language.code",
{ "op": "transform.pii.tokenize", "when": ["detect.pii.entities:flagged", "high_security:true"] }
],
"tokens": { "style": "angle" }
}
steps is a workflow, step for step. Saving adds the name and an optional description. tokens.style picks the bracket style of the tokens a tokenize emits.
Run it
Send template in place of steps, with the input and the variables the template’s conditions use:
{
"template": "customer-support@4",
"input": "Hi, I am Jane Doe. Can you check invoice #4821?",
"variables": { "high_security": true }
}
A variable you do not send is false, so a template needs no defaults. How when reads them is in workflows. The key needs the templates:run scope, and the template in its allowlist when it has one, or the workflow is refused with template_not_allowed.
Save a version
POST /v1/templates
Posting a new name creates version 1. Posting an existing name creates the next version.
{
"name": "customer-support",
"version": 4,
"ref": "customer-support@4",
"status": "active",
"created_at": "2026-11-16T10:12:44Z"
}
Pin a version
customer-supportresolves to the latest active version when the workflow runs.customer-support@4is pinned.
Every workflow with a template returns the pinned ref that ran, whichever form you sent. Send pinned refs from production keys.
Retire a version
DELETE /v1/templates/customer-support@3
The version is marked retired. A workflow naming it is refused with template_retired, and it stays readable so audit traces still resolve. The only active version cannot be retired.
Nest a template
A step can be a template, which puts that template’s steps in its place. Shared rules live in one template the others include, in the order you choose:
{
"name": "support-external",
"steps": [
{ "template": "support-base@2" },
{ "op": "transform.pii.tokenize", "when": "detect.pii.entities:flagged" }
]
}
A nested template is read at the version you name, so pin it to keep the outer template stable. Templates nest up to three deep, or the save is rejected with template_depth.
One template per destination
Your code picks the template for each destination, and the shared checks live in one base template the others nest.
| Where the data goes | Template you run |
|---|---|
| Internal model | support-internal (extracts only) |
| EU-hosted model | support-eu (tokenize personal data) |
| US-hosted model | support-external (tokenize personal data, block credentials) |
| Vector store | rag-context (redact personal data and credentials) |
| Call archive | call-archive (transcribe, tokenize personal data) |
Read
GET /v1/templates
GET /v1/templates/customer-support
GET /v1/templates/customer-support@4
GET /v1/templates/customer-support/versions
Reading a template returns its steps as saved, and its steps with every nested template expanded, as a workflow runs them. The API reference has every field.