form.schema.json

A sealed form, hosted page or sealed view (config-schema §5).

All pages ↓

form.schema.json JSON · 101 lines · Validates forms/<id>.json Raw file
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://streamliner.work/schema/v1/form.schema.json",
  "title": "forms/<id>.json",
  "description": "A sealed form, hosted page or sealed view (config-schema §5). Law 4: sensitive data never touches the model. A form posts straight from the device to the organization's endpoint; a hosted page is the processor's own page; a view fetches sensitive data straight from the organization. The model only ever receives the receipt, filtered by `receipt.keep`.",
  "type": "object",
  "required": ["id", "kind"],
  "additionalProperties": false,
  "properties": {
    "$schema": { "$ref": "defs.schema.json#/$defs/schemaRef" },
    "id": { "$ref": "defs.schema.json#/$defs/formId", "description": "Equals the file name; listed in a streamline's `forms[]` or `views[]`." },
    "streamline": { "$ref": "defs.schema.json#/$defs/kindId", "description": "The streamline this form belongs to (§5): one of tenant.json's kinds. The Library shows it inside that streamline's editor (Forms tab), not among the shared parts. Absent: shared, for any streamline." },
    "kind": { "enum": ["form", "hosted", "view"], "description": "`form`: a native sealed form posted device → organization. `hosted`: the processor's page in SFSafariViewController (card-not-present cards; MCP URL-mode elicitation). `view`: sensitive data fetched and shown, never given to the model." },
    "title": { "$ref": "defs.schema.json#/$defs/interpolated", "description": "Interpolates `context.*` (non-sensitive values the tool supplied)." },
    "subtitle": { "$ref": "defs.schema.json#/$defs/interpolated", "description": "One line on where the data goes. Interpolates `context.*`." },
    "presentation": { "enum": ["sheet", "inline"], "description": "`sheet`: a card in the chat that opens a modal. `inline`: fields drawn in the chat card (≤ 3 fields)." },
    "fields": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/field" }, "description": "`form`: the fields, in order. Keys must be unique." },
    "submit": {
      "type": "object",
      "description": "`form`: where the values go, straight from the device.",
      "required": ["url"],
      "additionalProperties": false,
      "properties": {
        "url": { "$ref": "defs.schema.json#/$defs/sealedUrl", "description": "The organization's sensitive-data endpoint (tokenizer, credit partner). https, or relative to the config host for demo." },
        "auth": { "enum": ["oauth", "password", "api-key", "none", "user-token"], "description": "As for MCP: the user's credential for the connection of the server that opened the form (or a one-time token the tool supplied)." },
        "resource": { "type": "string", "format": "uri", "description": "For `oauth`: the audience the token must be for." },
        "label": { "$ref": "defs.schema.json#/$defs/interpolated", "description": "The submit button's label." },
        "include": { "type": "array", "uniqueItems": true, "items": { "const": "session" }, "description": "`session`: echo the tool's one-time session id, so the endpoint can tie the capture to the job." }
      }
    },
    "receipt": {
      "type": "object",
      "description": "What the model may learn.",
      "required": ["keep"],
      "additionalProperties": false,
      "properties": {
        "keep": {
          "type": "object",
          "minProperties": 1,
          "description": "Key → regex: the only keys that enter the model-facing history, and only when the value matches in full. Anything else in the endpoint's answer is dropped.",
          "propertyNames": { "type": "string", "pattern": "^[A-Za-z0-9_]{1,64}$" },
          "additionalProperties": { "type": "string", "minLength": 1, "description": "A regex the whole value must match (anchor it with ^…$)." }
        }
      }
    },
    "card": {
      "type": "object",
      "description": "Text of the chat card before and after.",
      "additionalProperties": false,
      "properties": {
        "pending": { "type": "string", "description": "While the form is open." },
        "done": { "$ref": "defs.schema.json#/$defs/interpolated", "description": "After; interpolates the filtered receipt." }
      }
    },
    "allowedHosts": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "defs.schema.json#/$defs/hostName" }, "description": "`hosted`: hosts the run-time URL may use; anything else is refused. The app shows the full host before opening." },
    "button": { "type": "string", "description": "`hosted`: the button that opens the page." },
    "fetch": {
      "type": "object",
      "description": "`view`: where the data comes from (GET with a short-lived token for the employee and the session).",
      "required": ["url"],
      "additionalProperties": false,
      "properties": {
        "url": { "$ref": "defs.schema.json#/$defs/sealedUrl", "description": "The organization's endpoint." },
        "auth": { "enum": ["oauth", "password", "api-key", "none", "user-token"], "description": "As for `submit.auth`." },
        "resource": { "type": "string", "format": "uri", "description": "For `oauth`: the token's audience." },
        "include": { "type": "array", "uniqueItems": true, "items": { "const": "session" }, "description": "`session`: send the tool's session id." }
      }
    },
    "template": { "$ref": "defs.schema.json#/$defs/templateId", "description": "`view`: the template that draws it." },
    "expiresAfterSeconds": { "type": "integer", "minimum": 5, "maximum": 3600, "description": "`view`: the card collapses to Hidden after this; reopening fetches again. Default 120." },
    "allowCopy": { "type": "boolean", "description": "`view`: long-press copy. Default false." }
  },
  "allOf": [
    { "if": { "properties": { "kind": { "const": "form" } } }, "then": { "required": ["title", "fields", "submit", "receipt"] } },
    { "if": { "properties": { "kind": { "const": "hosted" } } }, "then": { "required": ["title", "allowedHosts", "receipt"] } },
    { "if": { "properties": { "kind": { "const": "view" } } }, "then": { "required": ["fetch", "template"] } }
  ],
  "$defs": {
    "field": {
      "type": "object",
      "description": "One field. Sensitive types get the right keyboard, masking while not focused, no autocorrect or keyboard learning, and stay out of the pasteboard history.",
      "required": ["key", "label", "type"],
      "additionalProperties": false,
      "properties": {
        "key": { "type": "string", "pattern": "^[A-Za-z0-9_]{1,64}$", "description": "The value's key in the POST body." },
        "label": { "type": "string", "minLength": 1, "description": "The field's label." },
        "type": { "enum": ["text", "number", "money", "date", "choice", "toggle", "phone", "email", "postalCode", "cardNumber", "expiry", "cvc", "ssn", "image", "signature"], "description": "`cardNumber`, `expiry` and `cvc` exist only for demo accounts (configcheck refuses them elsewhere; real card data goes through a hosted page or the terminal)." },
        "required": { "type": "boolean", "description": "Must be filled before submit." },
        "value": { "$ref": "defs.schema.json#/$defs/interpolated", "description": "Prefill, interpolated against `context.*`." },
        "readOnly": { "type": "boolean", "description": "Shown, not editable." },
        "validate": { "type": "string", "description": "`luhn`, or a regex the value must match." },
        "options": { "type": "array", "minItems": 1, "items": { "type": "string" }, "description": "`choice`: the options." },
        "camera": { "type": "boolean", "description": "`image`: offer the camera." },
        "autocapitalize": { "enum": ["none", "words", "sentences", "characters"], "description": "Keyboard capitalisation." },
        "placeholder": { "type": "string", "description": "Hint inside the empty field." }
      },
      "if": { "properties": { "type": { "const": "choice" } } },
      "then": { "required": ["options"] }
    }
  }
}

← All Schemas