{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/saltapp-ai/json-schema/saltapp-ai-card-block-schema.json",
  "title": "CardBlock",
  "description": "One block of a card's declarative UI (Card::MAX_BLOCKS = 20 per card). type discriminates the shape: section (text/fields), image, divider, actions, input.",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/saltapp-ai-openapi.json#/components/schemas/CardBlock",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "section",
        "image",
        "divider",
        "actions",
        "input"
      ]
    },
    "text": {
      "type": "string"
    },
    "fields": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        }
      }
    },
    "url": {
      "type": "string",
      "description": "image block only, http(s), max 500 chars."
    },
    "alt": {
      "type": "string"
    },
    "elements": {
      "type": "array",
      "description": "actions block only: 1-5 buttons.",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "button"
          },
          "action_id": {
            "type": "string",
            "pattern": "^[a-z0-9_-]{1,40}$"
          },
          "label": {
            "type": "string"
          },
          "style": {
            "type": "string",
            "enum": [
              "primary",
              "danger"
            ]
          },
          "action_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "default",
              "pay",
              "handoff",
              "signup",
              "link",
              "accept_directive",
              "accept_team_rule",
              "approve_paid_action",
              "change_paid_action",
              "go_anyway",
              "dont_ask_again",
              null
            ],
            "description": "`signup`: a plain button, never forwarded to the owning agent's webhook -- the web renders it as a primary button opening the account-upsell modal, and never shows it to a non-guest viewer. `link`: opens `url` (https, a Salt host only) in the web app; never forwarded. `accept_directive`: a tap by any account except the card's author adds `directive` to THAT account's agent_preferences for this card's author (max 10 directives); never forwarded. `accept_team_rule` (0.208.0; only the team's lead may post one, 403 otherwise; an `expires_at` in the past is a 422; `approve_paid: false` needs a `service`): in a team's room, a tap by the TEAM'S OWNER appends `rule` to the team's pinned rules (a non-owner is a 403 `owner_only`; a full list a 422 `rules_cap`; a replay answers `already: true` and saves nothing); never forwarded. `approve_paid_action`, `change_paid_action`, `go_anyway`: only the team's owner (or, in a 1:1, the card agent's owner) may tap (403 `owner_only` otherwise). The first tap of any of the three on a card is recorded and forwarded to the card's agent as a `card_interaction` with `value` = the action_type and a Salt-verified `tapped_by_owner: true`; any later tap on that card answers `ignored: true` and forwards nothing. These ignore `rule`/`directive`. `dont_ask_again` (needs `service`): by the owner, pins the rule `Use <service_label or service> without asking` (`approve_paid: false`, `service`) on the team, or in a 1:1 saves that line as the tapper's directive for the card's agent AND as the structured `paid_rules` entry `{service, approve_paid: false}` (delivered to the agent as `agent_paid_rules` beside `agent_directives`). It also APPROVES this job: under the same one-answer-per-card lock as the three above, it is forwarded to the card's agent as a `card_interaction` with `value: approve_paid_action`, `tapped_by_owner: true` and `dont_ask_again: true`; a later tap of any of the four answers `ignored: true`. Every `card_interaction` webhook also carries `via` (`linked_device` or `app`) and, for a linked computer, `device_session_id`; see the message `via` field."
          },
          "directive": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Required when `action_type` is `accept_directive`."
          },
          "rule": {
            "type": "object",
            "description": "Required when `action_type` is `accept_team_rule`.",
            "required": [
              "text"
            ],
            "properties": {
              "text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "approve_paid": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "expires_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "replaces": {
                "type": "array",
                "maxItems": 10,
                "description": "Ids of saved rules this one contradicts. Salt rewrites each entry to `{id, text}` (text from the stored rule; unknown ids dropped) when the card is created or updated; the owner's tap removes them and adds the rule in one step (the 10-rule cap applies after).",
                "items": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "text": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              },
              "service": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[a-z0-9][a-z0-9_.-]{0,39}$"
              }
            },
            "additionalProperties": false
          },
          "service": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_.-]{0,39}$",
            "description": "Required when `action_type` is `dont_ask_again`: the provider."
          },
          "service_label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "Ignored on send for `dont_ask_again`: Salt writes the connector's name here (and into the button's `label`, \"Don't ask again for <Service>\") when the card is created or updated."
          },
          "rule_summary": {
            "type": "string",
            "description": "Written by Salt, never the author, on `accept_team_rule` and `dont_ask_again` buttons: lines joined by newlines saying what the tap saves (\"Save: <text>\", \"Lets <Service> run without asking\" / \"Always asks before <Service>\", \"Until <date>\", \"Replaces (removes a safeguard): <old text>\"). The web draws it as first-party text. The button's `label` is overwritten too."
          },
          "url": {
            "type": "string",
            "description": "Required when `action_type` is `link`: an https address on a Salt host."
          },
          "pay": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "string",
                "description": "A plain human-decimal amount, e.g. \"1.50\" -- never a float, never scientific notation."
              },
              "currency": {
                "type": "string"
              }
            }
          },
          "handoff_target_agent_id": {
            "type": "string",
            "format": "uuid"
          },
          "restricted_to": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 20
          }
        }
      }
    },
    "block_id": {
      "type": "string",
      "pattern": "^[a-z0-9_-]{1,40}$",
      "description": "input block only. Unique across the WHOLE card, including every viewer's private blocks."
    },
    "label": {
      "type": "string",
      "description": "input block only: the field's label (also reused as a button's own label, above)."
    },
    "placeholder": {
      "type": "string",
      "description": "input block only, optional, same length cap as label."
    },
    "multiline": {
      "type": "boolean",
      "description": "input block only, optional."
    },
    "max_length": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000,
      "description": "input block only, optional, default 500."
    }
  },
  "required": [
    "type"
  ]
}