# template.schema.json

> A view template: a small tree of native views bound to a JSON object (config-schema §6).

A view template: a small tree of native views bound to a JSON object (config-schema §6).

Raw file: https://streamliner.work/schema/v1/template.schema.json

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://streamliner.work/schema/v1/template.schema.json",
  "title": "templates/<id>.json",
  "description": "A view template: a small tree of native views bound to a JSON object (config-schema §6). The server sends data; the app owns every pixel (law 6): no HTML, CSS, scripts or remote fonts. Limits the renderer enforces: depth ≤ 12, ≤ 200 nodes, ≤ 50 items per list; a broken template renders as a plain card, never a blank chat.",
  "type": "object",
  "required": [
    "id",
    "schema",
    "root"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "$ref": "defs.schema.json#/$defs/schemaRef"
    },
    "id": {
      "$ref": "defs.schema.json#/$defs/templateId",
      "description": "Equals the file name. Named by `renderers`, `overview`, `confirm.template`, a sealed view's `template`, or a result's `card.template`."
    },
    "schema": {
      "const": "streamline.template/1",
      "description": "`streamline.template/1`."
    },
    "streamline": {
      "$ref": "defs.schema.json#/$defs/kindId",
      "description": "The streamline this card belongs to (§6.9): one of tenant.json's kinds. The Library shows it inside that streamline's editor (Cards tab), not among the shared parts. Absent: shared, for any streamline."
    },
    "root": {
      "$ref": "#/$defs/node",
      "description": "The root node; `$` is the tool's `structuredContent` (or the overview object, or `{args, preview}` for a confirmation card)."
    },
    "speech": {
      "type": "object",
      "description": "What Speak replies says for a card drawn with this template (§6.7, docs/plans/voice.md §7): `summary` in the template language. Not allowed on a template a sealed view uses (never spoken).",
      "additionalProperties": false,
      "properties": {
        "summary": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "e.g. \"Sale {{ $.id }}, total {{ $.total | money }}\"."
        }
      }
    },
    "sample": {
      "type": "object",
      "description": "Made-up data in the shape of `$` (the tool's structuredContent) that previews draw this card with: the Library's preview and Discover's listing (§6.8, 2026-10-18). Never real people's data (law 4); never sent to the model. Without it a preview invents values from the paths the template reads."
    }
  },
  "$defs": {
    "node": {
      "type": "object",
      "required": [
        "type"
      ],
      "description": "One view node: `stack`, `row`, `text`, `badge`, `money`, `image`, `list`, `keyValue`, `divider`, `spacer`, `button` (§6.1). Every node may have `when` and `padding`.",
      "properties": {
        "type": {
          "enum": [
            "stack",
            "row",
            "text",
            "badge",
            "money",
            "image",
            "list",
            "keyValue",
            "divider",
            "spacer",
            "button"
          ],
          "description": "The node type."
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "stack"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/stack"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "row"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/row"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "text"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/text"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "badge"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/badge"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "money"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/money"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "image"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/image"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "list"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/list"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "keyValue"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/keyValue"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "divider"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/divider"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "spacer"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/spacer"
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "button"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "$ref": "#/$defs/button"
          }
        }
      ]
    },
    "action": {
      "type": "object",
      "additionalProperties": false,
      "description": "Exactly one of: `tool` (a direct call, with `args` and a `fallback` text), `send`, `insert`, `openView` (with `session`), `openURL`, `download`, `copy` (§6.5).",
      "properties": {
        "tool": {
          "$ref": "defs.schema.json#/$defs/toolName",
          "description": "Call this tool with no model. It must be `direct` for this user; otherwise `fallback` is sent."
        },
        "args": {
          "type": "object",
          "description": "The tool's arguments; strings interpolate (`{{ @.sku }}`, `{{ chat.cartId }}`)."
        },
        "fallback": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "Sent as the employee's message when the tool is not direct for them."
        },
        "send": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "Send this text as the employee's own message."
        },
        "insert": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "Put this text in the composer, slots selected."
        },
        "openView": {
          "$ref": "defs.schema.json#/$defs/formId",
          "description": "Open a sealed view the streamline lists."
        },
        "session": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "`openView`: the session for the view's fetch."
        },
        "openURL": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "Open in the system browser after a tap (https only); the host must be in `imageHosts` or `support.url`'s host (a personal streamline: its `imageHosts` or its MCP servers' hosts)."
        },
        "download": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "Fetch the file into the chat after a tap (https only, the same hosts as `openURL`; no cookies, no credentials; at most 25 MB). The button then reads *Downloaded · <name>* and a second tap opens the saved copy without fetching again."
        },
        "copy": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "Copy non-sensitive text."
        }
      },
      "oneOf": [
        {
          "required": [
            "tool"
          ]
        },
        {
          "required": [
            "send"
          ]
        },
        {
          "required": [
            "insert"
          ]
        },
        {
          "required": [
            "openView"
          ]
        },
        {
          "required": [
            "openURL"
          ]
        },
        {
          "required": [
            "download"
          ]
        },
        {
          "required": [
            "copy"
          ]
        }
      ],
      "errorMessage": "a button action needs exactly one of tool, send, insert, openView, openURL, download, copy",
      "dependentRequired": {
        "args": [
          "tool"
        ],
        "fallback": [
          "tool"
        ],
        "session": [
          "openView"
        ]
      }
    },
    "body": {
      "description": "A template body as a personal streamline file holds it: `{root: node}` or a bare node.",
      "anyOf": [
        {
          "type": "object",
          "required": [
            "root"
          ],
          "additionalProperties": false,
          "properties": {
            "root": {
              "$ref": "#/$defs/node"
            },
            "id": {
              "$ref": "defs.schema.json#/$defs/templateId"
            },
            "schema": {
              "const": "streamline.template/1",
              "description": "Optional: `streamline.template/1`."
            },
            "sample": {
              "type": "object",
              "description": "Made-up data in the shape of `$` (the tool's structuredContent) that previews draw this card with: the Library's preview and Discover's listing (§6.8, 2026-10-18). Never real people's data (law 4); never sent to the model. Without it a preview invents values from the paths the template reads."
            }
          }
        },
        {
          "$ref": "#/$defs/node"
        }
      ]
    },
    "stack": {
      "type": "object",
      "description": "Vertical stack.",
      "required": [
        "type",
        "children"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "stack",
          "description": "`stack`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/node"
          },
          "description": "Child nodes, in order."
        },
        "spacing": {
          "type": "number",
          "minimum": 0,
          "maximum": 48,
          "description": "Points between children. Default 6."
        },
        "align": {
          "enum": [
            "leading",
            "center",
            "trailing"
          ],
          "description": "Horizontal alignment. Default leading."
        }
      }
    },
    "row": {
      "type": "object",
      "description": "Horizontal stack.",
      "required": [
        "type",
        "children"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "row",
          "description": "`row`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/node"
          },
          "description": "Child nodes, in order."
        },
        "spacing": {
          "type": "number",
          "minimum": 0,
          "maximum": 48,
          "description": "Points between children. Default 8."
        },
        "align": {
          "enum": [
            "top",
            "center",
            "baseline"
          ],
          "description": "Vertical alignment."
        },
        "distribute": {
          "enum": [
            "start",
            "spaceBetween"
          ],
          "description": "`spaceBetween` pushes the last child to the trailing edge."
        }
      }
    },
    "text": {
      "type": "object",
      "description": "Dynamic Type text.",
      "required": [
        "type",
        "text"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "text",
          "description": "`text`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "text": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "The text, with `{{ }}` holes."
        },
        "style": {
          "enum": [
            "title",
            "headline",
            "body",
            "callout",
            "caption",
            "footnote"
          ],
          "description": "Text style. Default body."
        },
        "weight": {
          "enum": [
            "regular",
            "medium",
            "semibold",
            "bold"
          ],
          "description": "Font weight."
        },
        "color": {
          "enum": [
            "primary",
            "secondary",
            "accent",
            "kind",
            "positive",
            "warning",
            "negative"
          ],
          "description": "Semantic color; `kind` is the streamline's color."
        },
        "lines": {
          "type": "integer",
          "minimum": 1,
          "maximum": 20,
          "description": "Maximum lines."
        },
        "mono": {
          "type": "boolean",
          "description": "Monospaced digits."
        }
      }
    },
    "badge": {
      "type": "object",
      "description": "A pill.",
      "required": [
        "type",
        "text"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "badge",
          "description": "`badge`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "text": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "The pill's text."
        },
        "tone": {
          "enum": [
            "neutral",
            "positive",
            "warning",
            "negative",
            "accent",
            "kind"
          ],
          "description": "A fixed tone."
        },
        "toneMap": {
          "type": "object",
          "required": [
            "path",
            "map"
          ],
          "additionalProperties": false,
          "description": "Tone from a value: `{path, map: {value: tone}, default}`.",
          "properties": {
            "path": {
              "$ref": "defs.schema.json#/$defs/contextPath",
              "description": "The value to look up."
            },
            "map": {
              "type": "object",
              "additionalProperties": {
                "enum": [
                  "neutral",
                  "positive",
                  "warning",
                  "negative",
                  "accent",
                  "kind"
                ]
              },
              "description": "Value → tone."
            },
            "default": {
              "enum": [
                "neutral",
                "positive",
                "warning",
                "negative",
                "accent",
                "kind"
              ],
              "description": "Tone when no entry matches. Default neutral."
            }
          }
        }
      }
    },
    "money": {
      "type": "object",
      "description": "A locale-formatted amount.",
      "required": [
        "type",
        "value"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "money",
          "description": "`money`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "value": {
          "$ref": "defs.schema.json#/$defs/contextPath",
          "description": "Path to the amount (`$.total`, `@.price`)."
        },
        "currency": {
          "type": "string",
          "description": "A path or an ISO 4217 code; default the account currency."
        },
        "style": {
          "enum": [
            "title",
            "headline",
            "body",
            "callout",
            "caption",
            "footnote"
          ],
          "description": "Text style."
        },
        "weight": {
          "enum": [
            "regular",
            "medium",
            "semibold",
            "bold"
          ],
          "description": "Font weight."
        },
        "color": {
          "enum": [
            "primary",
            "secondary",
            "accent",
            "kind",
            "positive",
            "warning",
            "negative"
          ],
          "description": "Semantic color."
        },
        "strike": {
          "type": "boolean",
          "description": "Struck through (a tag price beside an offer)."
        }
      }
    },
    "image": {
      "type": "object",
      "description": "An async image with a placeholder; a tap opens the drawn image full screen (`tap`: `none` for a decorative one). A placeholder is never tappable.",
      "required": [
        "type",
        "url"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "image",
          "description": "`image`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "url": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "Interpolated; the host must be in `imageHosts`, or an `assets/` path."
        },
        "aspect": {
          "enum": [
            "1:1",
            "4:3",
            "16:9"
          ],
          "description": "Aspect ratio."
        },
        "width": {
          "type": "number",
          "minimum": 1,
          "maximum": 1024,
          "description": "Width in points."
        },
        "corner": {
          "type": "number",
          "minimum": 0,
          "maximum": 64,
          "description": "Corner radius in points."
        },
        "tap": {
          "enum": [
            "full",
            "none"
          ],
          "description": "What a tap does: `full` (the default) opens the image full screen, from the same URL; `none` leaves a decorative image still."
        }
      }
    },
    "list": {
      "type": "object",
      "description": "Repeats `item` for each element (`@` is the current element).",
      "required": [
        "type",
        "items",
        "item"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "list",
          "description": "`list`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "items": {
          "type": "string",
          "pattern": "^(\\$|@).*\\[\\*\\]$",
          "patternErrorMessage": "a path ending [*] ($.results[*])",
          "description": "A path ending `[*]`."
        },
        "item": {
          "$ref": "#/$defs/node",
          "description": "The node drawn per element."
        },
        "max": {
          "type": "integer",
          "minimum": 1,
          "maximum": 50,
          "description": "Cap (default and limit 50)."
        },
        "more": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "Text after the cap; interpolates `count`."
        },
        "dividers": {
          "type": "boolean",
          "description": "Hairlines between items."
        }
      }
    },
    "keyValue": {
      "type": "object",
      "description": "A two-column label/value list.",
      "required": [
        "type",
        "rows"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "keyValue",
          "description": "`keyValue`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "rows": {
          "type": "array",
          "description": "The rows.",
          "items": {
            "type": "object",
            "required": [
              "label",
              "value"
            ],
            "additionalProperties": false,
            "properties": {
              "label": {
                "$ref": "defs.schema.json#/$defs/interpolated",
                "description": "Left column."
              },
              "value": {
                "$ref": "defs.schema.json#/$defs/interpolated",
                "description": "Right column, interpolated."
              },
              "when": {
                "$ref": "defs.schema.json#/$defs/when",
                "description": "Draw the row only when this holds."
              }
            }
          }
        }
      }
    },
    "divider": {
      "type": "object",
      "description": "A hairline.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "divider",
          "description": "`divider`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        }
      }
    },
    "spacer": {
      "type": "object",
      "description": "A fixed gap.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "spacer",
          "description": "`spacer`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "height": {
          "type": "number",
          "minimum": 0,
          "maximum": 200,
          "description": "Height in points."
        }
      }
    },
    "button": {
      "type": "object",
      "description": "A button: speaks for the employee, or calls a `direct` tool itself (§6.5).",
      "required": [
        "type",
        "label",
        "action"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "button",
          "description": "`button`."
        },
        "when": {
          "$ref": "defs.schema.json#/$defs/when",
          "description": "Draw this node only when the condition holds (§6.4)."
        },
        "padding": {
          "type": "number",
          "minimum": 0,
          "maximum": 24,
          "description": "Padding in points, 0–24."
        },
        "label": {
          "$ref": "defs.schema.json#/$defs/interpolated",
          "description": "The button's label."
        },
        "style": {
          "enum": [
            "primary",
            "secondary",
            "destructive"
          ],
          "description": "Button style."
        },
        "action": {
          "$ref": "#/$defs/action"
        }
      }
    }
  }
}

```
