<!-- AANCER developer pages, part 4 of 16. All parts: https://aancer.ai/dev/llms.txt -->

## Workflow templates

A workflow in AANCER is a graph of steps: a trigger, AI calls, knowledge lookups, agents, connector actions, human approvals, conditions, loops and more. A **workflow template** is a reusable, reviewed copy of a workflow. Everything that names a resource of one installation is taken out and turned into a typed **parameter**: connections, knowledge sets, agents, personas, datasets, approvers and trigger secrets. The person who deploys the template fills these in. Templates travel between installations as a pack item of kind `template`. Inside an installation you can also create templates from an existing workflow, review them and export them as a pack.

## Quick start

A webhook that posts the request to a chat channel. The chat connection is a parameter.

```json
{
  "kind": "template",
  "schemaVersion": 1,
  "id": "request-intake",
  "scope": "install",
  "spec": {
    "id": "tpl-acme-request-intake",
    "version": 1,
    "workspace": "{{param.target_workspace}}",
    "record": {
      "name": "Request intake",
      "description": "Takes a request and posts it to the team.",
      "icon": "🧩",
      "industry": "operations",
      "complexity": "starter",
      "locale": "en",
      "aiAct": { "riskClass": "unclassified", "annexIiiCategory": "none", "intendedPurpose": "", "humanOversight": "", "transparencyNote": "" },
      "compliance": { "dataCategories": [], "dataSubjects": [], "lawfulBasis": "", "retentionDays": null },
      "parameters": [
        { "id": "conn_1", "type": "connection", "label": "Chat connection", "required": true, "connector": "connector-chat" }
      ],
      "bindings": [
        { "parameterId": "conn_1", "stepId": "a", "path": "connectorAuth" }
      ],
      "translations": {},
      "flow": {
        "name": "Request intake",
        "rootStepId": "t",
        "steps": [
          { "id": "t", "type": "trigger", "name": "When called", "position": { "x": 0, "y": 0 }, "triggerType": "webhook", "nextStepId": "a" },
          { "id": "a", "type": "connector", "name": "Post", "position": { "x": 0, "y": 120 }, "connectorPiece": "connector-chat", "connectorAction": "send", "connectorInputs": { "channel": "general" } }
        ]
      },
      "builtAgainst": { "catalogHash": "", "platformVersion": "1.0.0" },
      "createdAt": "2026-11-15T00:00:00.000Z"
    }
  }
}
```

Put this item in a pack manifest and declare the workspace parameter:

```json
"parameters": [ { "id": "target_workspace", "type": "workspace", "label": "Workspace", "required": false } ]
```

`connector-chat` is a placeholder. Use the connector name of a real connector in the target installation.

## File layout

```text
acme-request-intake/
  manifest.json                  # pack manifest, one template item
  content/
    request-intake.json          # the item spec: { id, version, workspace?, record }
```

A template is one pack item. Its `spec` is inline or in `content/<name>.json`. If the administrator should choose the workspace, declare a `workspace` pack parameter (for example `target_workspace`, `required: false`) and set `spec.workspace` to `{{param.target_workspace}}`. If it stays unbound, the template is published for the whole installation.

## Field reference

JSON Schema: [template.schema.json](https://aancer.ai/dev/schemas/template.schema.json)

### Item spec

| Field | Type | Required | Rules |
|---|---|---|---|
| `id` | string | yes | 1 to 64 characters. The installation computes its own row id on import |
| `version` | integer | yes | 1 or higher |
| `workspace` | string | no | exactly `{{param.<id>}}` of a `workspace` pack parameter. A literal workspace id is refused |
| `record` | object | yes | the template record below |

### Template record

| Field | Type | Required | Rules |
|---|---|---|---|
| `name` | string | yes | 1 to 80 characters |
| `description` | string | yes | 1 to 300 characters |
| `longDescription` | string | no | detail text |
| `icon` | string | yes | 1 to 40 characters, usually an emoji |
| `industry` | string | yes | `healthcare`, `legal`, `financial`, `hr`, `manufacturing`, `retail`, `saas`, `marketing`, `operations`, `devops` |
| `industries` | string[] | no | extra tags |
| `complexity` | string | yes | `starter`, `intermediate`, `advanced` |
| `estimatedTimeSaved` | string | no | for example `"3h/week"` |
| `locale` | string | yes | at most 20 characters, for example `en` |
| `dataClassification` | string | no | free text |
| `aiAct` | object | yes | `{ riskClass, annexIiiCategory, intendedPurpose, humanOversight, transparencyNote }`. `riskClass`: `unclassified`, `minimal`, `limited`, `high`, `prohibited` |
| `compliance` | object | yes | `{ dataCategories: string[], dataSubjects: string[], lawfulBasis, retentionDays }`. `lawfulBasis`: `contract`, `consent`, `legitimate-interest`, `legal-obligation` or `""`. `retentionDays`: integer 0 to 36500, or `null` |
| `parameters` | array | yes | at most 50. See Template parameters |
| `bindings` | array | yes | which parameter fills which step field |
| `translations` | object | yes | `{ "<locale>": { name?, description?, longDescription?, parameters?: { "<paramId>": { label?, help? } } } }`. May be `{}` |
| `flow` | object | yes | `{ name, description?, rootStepId, steps }`, 2 to 200 steps |
| `builtAgainst` | object | no | `{ catalogHash, platformVersion }` |
| `createdAt` | string | yes | ISO 8601 date and time, for example `2026-11-20T00:00:00.000Z` |

Do not send `derived`. The installation computes it.

### Template parameters

| Field | Type | Required | Rules |
|---|---|---|---|
| `id` | string | yes | `^[a-z][a-z0-9_]{0,39}$`, unique |
| `type` | string | yes | `connection`, `knowledgeSet`, `agent`, `persona`, `dataset`, `approvers`, `secret`, `string`, `number`, `boolean`, `select` |
| `label` | string | yes | not empty |
| `help` | string | no | |
| `required` | boolean | no | |
| `default` | string, number or boolean | no | must match the type. Not allowed for `connection`, `knowledgeSet`, `agent`, `persona`, `dataset`, `approvers`, `secret` |
| `options` | string[] | for `select` | at least one; a `select` default must be one of them |
| `connector` | string | no | for `connection`: the connector it must belong to |

These template parameters are separate from pack parameters. Pack parameters are bound when the pack is activated. Template parameters are filled each time someone deploys the template.

### Bindings

A binding is `{ "parameterId": "...", "stepId": "...", "path": "..." }`. `path` is dot-separated. A parameter may fill only these fields:

| Path | Parameter type |
|---|---|
| `connectorAuth` | `connection` |
| `knowledgeSetId` | `knowledgeSet` |
| `agentRef`, `agentId` | `agent` |
| `personaId` | `persona` |
| `datasetId` | `dataset` |
| `approvers` | `approvers` |
| `triggerAuthFields.<key>` (trigger step only) | `secret` (a secret fills nothing else) |
| `connectorInputs.<key>` (not `connectorInputs.auth`), `triggerInputs.<key>` | `string`, `number`, `boolean`, `select` |
| `systemPrompt`, `userPromptTemplate`, `routingInstructions`, `agentGoal`, `routerQuestion`, `searchQuery`, `approvalMessage`, `approvalReasoning` | `string`, `select` |

A code step is never a binding target.

**No resource may stay in the steps.** Leave these fields out of every step and bind a parameter instead: `connectorAuth`, `knowledgeSetId`, `agentRef`, `agentId`, `personaId`, `datasetId`, `approvers`, `triggerAuthFields`, `webhookPath`, `agentApprovers`, `capturedOutput`. Text must not contain `{{connections[`.

### Workflow steps

Every step has `id`, `type`, `name` and `position {x, y}`. Optional: `description`, `nextStepId` (the next step), `continueOnFailure`, `retryOnFailure`, `retryCount`, `retryDelayMs`, `fieldModes` (`{ "<field>": "manual" | "auto" | "prompt" | "none" }`).

Exactly one step has `type: "trigger"`, and `flow.rootStepId` points at it. There must be at least one other step. Refer to earlier output with `{{trigger.body.<field>}}`, `{{<stepId>}}` or `{{<stepId>.<field>}}`.

| `type` | Fields (required in bold) |
|---|---|
| `trigger` | **`triggerType`**: `webhook`, `schedule`, `event`, `piece`. `schedule` (cron), `triggerTimezone` (IANA), `triggerAuthType` (`none`, `basic`, `header`, `hmac`), `triggerPiece`, `triggerName`, `triggerInputs`, `triggerPieceVersion` for a connector trigger |
| `aancer-ai` | `modelTier` (`local-standard`, `local-advanced`, `cloud-reasoning`), `dataClassification` (`sovereign`, `internal`, `permitted`), `systemPrompt`, `userPromptTemplate`, `maxTokens` |
| `rag` | as `aancer-ai`, plus a `knowledgeSetId` binding to a `knowledgeSet` parameter |
| `agent` | **`agentGoal`**, `agentToolRefs`, `agentMaxSteps` (1 to 50, default 10), `agentMaxBudgetUsd` (default 1.00), `agentRequireApproval` (default true), `agentOutputFields` |
| `connector` | **`connectorPiece`** (connector name), `connectorAction`, `connectorInputs` |
| `approval` | `approvalMessage`, `approvalReasoning`, `approvalTimeout` (hours, default 24), `approvalOnReject` (`stop`, `continue`), plus an `approvers` binding |
| `condition` | **`conditionExpression`**, **`branches [{id, label, nextStepId}]`** (at least one) |
| `router` | **`routingInstructions`**, **`routerBranches [{id, label, nextStepId, isDefault}]`** with exactly one default |
| `ai-router` | **`routerInput`**, **`routerQuestion`**, **`routerRoutes [{id, label, description}]`** (2 to 12, ids unique and not empty, not `otherwise`; every edge must be a declared route), `routerMode` (`single`, `multi`), `routerConfidenceFloor` (0 to 1) |
| `loop` | **`loopExpression`**, `loopBodyStepId` |
| `code` | `codeLanguage` (`javascript`; `python` is coming in this release), `codeSource`, `codeInputs {name: "{{ref}}"}`. Input and output are JSON |
| `guardrails` | `guardTarget`, `guardOnFail` (`block`, `annotate`) |
| `file-search` | `searchQuery`, `searchMode` (`hybrid`, `vector`), `searchMaxHits` (1 to 20), plus a `knowledgeSetId` binding |
| `publish` | `publishMode` (`append`, `upsert`, `replace`), `publishRows`, `whenFull` (`remove_oldest`, `fail`), plus a `datasetId` binding |
| `output` | no required fields |

A step with `dataClassification: "sovereign"` cannot use `modelTier: "cloud-reasoning"`.

**Python in the Code step (coming in this release).** The Code step offers "JavaScript" or "Python with pandas". Python steps have pandas 3.0, numpy 2.4, python-dateutil and pytz; other libraries only when an administrator has approved them for the workspace. The step runs sandboxed: no network access, no host files or commands, and workspace secrets are never passed in. Memory is limited to 1.5 GB per step by default (an administrator can change it), and the normal step time limit applies. Input and output are JSON, so return a DataFrame as records.

### AI Act fields

If the template has AI steps (`aancer-ai`, `rag`, `agent`, `router`, `ai-router`), set `aiAct.riskClass` to `minimal`, `limited` or `high` and fill `aiAct.intendedPurpose`.

AANCER treats a template as high risk when `riskClass` is `high`, or when its industry, name or description (including translations) contains one of these terms: `hr` (as a word), `rrhh`, `talent`, `employ`, `hiring`, `recruit`, `candidate`, `screen`, `performance review`, `offboard`, `onboard`, `education`, `edu` (as a word), `proctor`, `grading`, `student`, `exam`. The match is a plain substring test, so words such as "screenshot", "employee" and "example" also count. A high-risk template with AI steps needs `aiAct.annexIiiCategory` (not `none`) and `aiAct.humanOversight`, and should contain an approval step. If the declared `riskClass` is lower than this rule derives, you get the warning `TPL_RISK_DECLARED_BELOW_DERIVED` and the template is treated as high risk.

### What the installation works out for you

Do not send these. AANCER derives them from the steps: which steps run locally, in the cloud, call a connector or wait for approval; whether the template is fully sovereign, mixed or sends data to a connector; the connectors it needs; and the hosts named in connector inputs.

Next part: https://aancer.ai/dev/parts/pages/05-full-examples.md
