{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/softsync-ai/json-schema/softsync-ai-json-table-schema.json",
  "title": "JsonTable",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/softsync-ai-objects-api-openapi.yml#/components/schemas/JsonTable",
  "type": "object",
  "properties": {
    "apiName": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "isSystem": {
      "type": "boolean"
    },
    "isHidden": {
      "type": "boolean"
    },
    "displayName": {
      "type": "string"
    },
    "fields": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/JsonField"
      }
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "hasEmbeddings": {
      "type": "boolean"
    },
    "rules": {
      "description": "Rules every save of a record must pass, whoever or whatever saves it. Omitted keeps the current rules; an empty list removes them.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/TableRuleDto"
      }
    },
    "options": {
      "description": "How records are shown (layout) and whether they are time entries (timer). Omitted keeps the current options; null clears them.",
      "allOf": [
        {
          "$ref": "#/$defs/TableOptionsDto"
        }
      ]
    },
    "extendsTable": {
      "type": "boolean",
      "description": "Templates only: adds these fields to the base template table with the same apiName instead of declaring a new table."
    },
    "calculating": {
      "readOnly": true,
      "description": "Read only: ids of formula fields whose values are still being worked out after a formula change. Ignored on save.",
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "apiName",
    "fields"
  ],
  "$defs": {
    "AIFieldType": {
      "type": "string",
      "enum": [
        "none",
        "prompt",
        "auto"
      ],
      "description": "Type of AI generation for the field, by default is AUTO if undefined"
    },
    "DateFieldOptions": {
      "type": "object",
      "properties": {
        "isHidden": {
          "type": "boolean"
        },
        "visibleTo": {
          "description": "Makes the field private: only these people see its value (admins always do). Formulas that read it are private the same way.",
          "allOf": [
            {
              "$ref": "#/$defs/FieldVisibilityDto"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/FieldValueSource"
        },
        "prompt": {
          "type": "string",
          "description": "AI record filling prompt for the field"
        },
        "aiType": {
          "description": "Type of AI generation for the field, by default is AUTO if undefined",
          "allOf": [
            {
              "$ref": "#/$defs/AIFieldType"
            }
          ]
        },
        "format": {
          "allOf": [
            {
              "$ref": "#/$defs/DateFormat"
            }
          ]
        },
        "includeTime": {
          "type": "boolean"
        },
        "disableFuture": {
          "type": "boolean"
        },
        "disablePast": {
          "type": "boolean"
        }
      }
    },
    "DateFormat": {
      "type": "string",
      "enum": [
        "date",
        "datetime",
        "time"
      ]
    },
    "FieldKind": {
      "type": "string",
      "enum": [
        "text",
        "number",
        "date",
        "select",
        "multi_select",
        "relation",
        "user",
        "file"
      ]
    },
    "FieldOptionChoice": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "alias": {
          "type": "string"
        },
        "color": {
          "type": "string"
        }
      },
      "required": [
        "value",
        "label"
      ]
    },
    "FieldValueSource": {
      "type": "object",
      "properties": {
        "type": {
          "allOf": [
            {
              "$ref": "#/$defs/FieldValueSourceType"
            }
          ]
        },
        "format": {
          "type": "string",
          "description": "Sequence format on text fields, e.g. \"INV-{YYYY}-{#####}\". Tokens: {YYYY} {YY} {MM} and one {#…} for the zero-padded counter."
        },
        "resetEvery": {
          "allOf": [
            {
              "$ref": "#/$defs/SequenceReset"
            }
          ]
        },
        "start": {
          "type": "number",
          "description": "First number of each period"
        },
        "expression": {
          "type": "string",
          "description": "Formula, with fields in braces: \"{Qty} * {Unit price}\". Saved with field ids ({fld:<id>}) so renames never break it."
        },
        "version": {
          "type": "number",
          "description": "Bumped by the server whenever the formula changes."
        },
        "deps": {
          "type": "object",
          "additionalProperties": true,
          "description": "What the formula reads, worked out by the server on save. Anything sent is ignored."
        },
        "volatile": {
          "type": "boolean",
          "description": "True when the formula uses TODAY() or NOW(), worked out by the server on save."
        }
      },
      "required": [
        "type"
      ]
    },
    "FieldValueSourceType": {
      "type": "string",
      "enum": [
        "manual",
        "sequence",
        "formula",
        "formula-default"
      ]
    },
    "FieldVisibilityDto": {
      "type": "object",
      "properties": {
        "roles": {
          "type": "array",
          "description": "Workspace roles that see the field.",
          "items": {
            "type": "string",
            "enum": [
              "editor",
              "viewer",
              "guest"
            ]
          }
        },
        "users": {
          "description": "Ids of people who see the field.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "userFields": {
          "description": "User fields of the same object (API name or id): the person in them sees the field on that record, e.g. an employee their own salary.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "groupRoles": {
          "type": "array",
          "description": "Roles in one of the record's groups that see the field.",
          "items": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "editor",
              "viewer"
            ]
          }
        }
      }
    },
    "FileFieldOptions": {
      "type": "object",
      "properties": {
        "isHidden": {
          "type": "boolean"
        },
        "visibleTo": {
          "description": "Makes the field private: only these people see its value (admins always do). Formulas that read it are private the same way.",
          "allOf": [
            {
              "$ref": "#/$defs/FieldVisibilityDto"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/FieldValueSource"
        },
        "isMany": {
          "type": "boolean"
        },
        "maxSize": {
          "type": "number"
        },
        "allowedMimeTypes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "fileType": {
          "allOf": [
            {
              "$ref": "#/$defs/FileType"
            }
          ]
        }
      }
    },
    "FileType": {
      "type": "string",
      "enum": [
        "image",
        "video",
        "audio",
        "document",
        "any"
      ]
    },
    "JsonField": {
      "type": "object",
      "properties": {
        "apiName": {
          "type": "string"
        },
        "displayName": {
          "type": "string"
        },
        "id": {
          "type": "string",
          "description": "Field ID"
        },
        "kind": {
          "allOf": [
            {
              "$ref": "#/$defs/FieldKind"
            }
          ]
        },
        "required": {
          "type": "boolean"
        },
        "canRemove": {
          "type": "boolean"
        },
        "options": {
          "description": "Field options specific to the field kind",
          "oneOf": [
            {
              "$ref": "#/$defs/NumberFieldOptions"
            },
            {
              "$ref": "#/$defs/TextFieldOptions"
            },
            {
              "$ref": "#/$defs/DateFieldOptions"
            },
            {
              "$ref": "#/$defs/SelectFieldOptions"
            },
            {
              "$ref": "#/$defs/RelationFieldOptions"
            },
            {
              "$ref": "#/$defs/UserFieldOptions"
            },
            {
              "$ref": "#/$defs/FileFieldOptions"
            }
          ]
        },
        "description": {
          "type": "string"
        },
        "order": {
          "type": "number"
        }
      },
      "required": [
        "apiName",
        "kind",
        "options"
      ]
    },
    "LockOperation": {
      "type": "string",
      "enum": [
        "update",
        "delete",
        "restore",
        "groups"
      ],
      "description": "Lock only: what is refused while locked. Default update and delete."
    },
    "NumberFieldOptions": {
      "type": "object",
      "properties": {
        "isHidden": {
          "type": "boolean"
        },
        "visibleTo": {
          "description": "Makes the field private: only these people see its value (admins always do). Formulas that read it are private the same way.",
          "allOf": [
            {
              "$ref": "#/$defs/FieldVisibilityDto"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/FieldValueSource"
        },
        "prompt": {
          "type": "string",
          "description": "AI record filling prompt for the field"
        },
        "aiType": {
          "description": "Type of AI generation for the field, by default is AUTO if undefined",
          "allOf": [
            {
              "$ref": "#/$defs/AIFieldType"
            }
          ]
        },
        "format": {
          "allOf": [
            {
              "$ref": "#/$defs/NumberFormat"
            }
          ]
        },
        "currency": {
          "type": "string"
        },
        "decimals": {
          "type": "number"
        },
        "primaryValue": {
          "type": "boolean"
        }
      }
    },
    "NumberFormat": {
      "type": "string",
      "enum": [
        "number",
        "currency",
        "percent"
      ]
    },
    "RelationFieldOptions": {
      "type": "object",
      "properties": {
        "isHidden": {
          "type": "boolean"
        },
        "visibleTo": {
          "description": "Makes the field private: only these people see its value (admins always do). Formulas that read it are private the same way.",
          "allOf": [
            {
              "$ref": "#/$defs/FieldVisibilityDto"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/FieldValueSource"
        },
        "targetTable": {
          "type": "string"
        },
        "tableId": {
          "type": "string"
        },
        "isMany": {
          "type": "boolean"
        }
      },
      "required": [
        "targetTable"
      ]
    },
    "RuleType": {
      "type": "string",
      "enum": [
        "required",
        "unique",
        "validate",
        "lock",
        "transition",
        "visible",
        "acyclic",
        "no_overlap"
      ],
      "description": "required: fields must be filled. unique: no two records share the value. validate: `when` must be true after the save. lock: while `when` is true for the record before the save, its fields can't change. transition: only the moves in `allow` may change the status `field`. visible: only the people in `who` (and admins) see the object's records. acyclic: the one link field in `fields` points at this same object and may never lead back to the record (a page under its own child, a task that waits on itself). no_overlap: records with the same `fields` values (e.g. the same room) may not have overlapping time spans; `period` names the start and end date fields, and an empty end never ends. A `when` limits it to records it holds for, e.g. not cancelled."
    },
    "SelectFieldOptions": {
      "type": "object",
      "properties": {
        "isHidden": {
          "type": "boolean"
        },
        "visibleTo": {
          "description": "Makes the field private: only these people see its value (admins always do). Formulas that read it are private the same way.",
          "allOf": [
            {
              "$ref": "#/$defs/FieldVisibilityDto"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/FieldValueSource"
        },
        "prompt": {
          "type": "string",
          "description": "AI record filling prompt for the field"
        },
        "aiType": {
          "description": "Type of AI generation for the field, by default is AUTO if undefined",
          "allOf": [
            {
              "$ref": "#/$defs/AIFieldType"
            }
          ]
        },
        "choices": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FieldOptionChoice"
          }
        },
        "defaultValue": {
          "type": "string"
        },
        "allowCustom": {
          "type": "boolean"
        },
        "aliasName": {
          "type": "string"
        }
      }
    },
    "SequenceReset": {
      "type": "string",
      "enum": [
        "never",
        "year",
        "month"
      ]
    },
    "TableOptionsDto": {
      "type": "object",
      "properties": {
        "layout": {
          "type": "string",
          "enum": [
            "page"
          ],
          "description": "page: a record opens like a document, its long text first and full width."
        },
        "timer": {
          "description": "The object's records are time entries written by the start/stop timer. Records of every object it links to get a timer.",
          "allOf": [
            {
              "$ref": "#/$defs/TableTimerDto"
            }
          ]
        },
        "relationCard": {
          "description": "What each record shows when it is listed among another record's linked records (the Relations tab).",
          "allOf": [
            {
              "$ref": "#/$defs/TableRelationCardDto"
            }
          ]
        },
        "showInParent": {
          "type": "boolean",
          "description": "The object's records are listed, ready to open and edit, in the Details of the record each one links to (the parts of a page, the lines of an order)."
        },
        "orderField": {
          "type": "string",
          "description": "API name of a number field that puts the records in order. Lists of them show them by it, lowest first, and dragging one to a new place renumbers."
        }
      }
    },
    "TableRelationCardDto": {
      "type": "object",
      "properties": {
        "subtitle": {
          "description": "API names of fields shown on one line under the record name, at most 3.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "primary": {
          "type": "string",
          "description": "API name of the field highlighted on the right, e.g. a line total, a status or a due date."
        },
        "fields": {
          "description": "API names of fields listed with their labels below the name, at most 6.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "TableRuleDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Stable id of the rule, unique within the object."
        },
        "type": {
          "description": "required: fields must be filled. unique: no two records share the value. validate: `when` must be true after the save. lock: while `when` is true for the record before the save, its fields can't change. transition: only the moves in `allow` may change the status `field`. visible: only the people in `who` (and admins) see the object's records. acyclic: the one link field in `fields` points at this same object and may never lead back to the record (a page under its own child, a task that waits on itself). no_overlap: records with the same `fields` values (e.g. the same room) may not have overlapping time spans; `period` names the start and end date fields, and an empty end never ends. A `when` limits it to records it holds for, e.g. not cancelled.",
          "allOf": [
            {
              "$ref": "#/$defs/RuleType"
            }
          ]
        },
        "name": {
          "type": "string",
          "description": "Name shown in settings."
        },
        "message": {
          "type": "string",
          "description": "Shown to whoever is stopped by the rule."
        },
        "fields": {
          "description": "API names of the fields the rule is about. For lock, omitted means every field.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "when": {
          "type": "string",
          "description": "A formula. Rules may also use OLD(field), CHANGED(field), IS_NEW(), ACTOR(), ACTOR_HAS_ROLE(role) and ORIGIN()."
        },
        "except": {
          "description": "Lock only: fields that can still be changed.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "operations": {
          "type": "array",
          "description": "Lock only: what is refused while locked. Default update and delete.",
          "items": {
            "$ref": "#/$defs/LockOperation"
          }
        },
        "enabled": {
          "type": "boolean",
          "description": "False pauses the rule."
        },
        "field": {
          "type": "string",
          "description": "Transition only: API name of the status (choice) field."
        },
        "start": {
          "description": "Transition only: statuses a new record may start in. Omitted means any.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "allow": {
          "description": "Transition only: the allowed moves. Any other status change is refused.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/TransitionStepDto"
          }
        },
        "who": {
          "description": "Visible only: who sees the records besides admins (any entry). `{Field}` (a person field, e.g. `{Owner}`), `creator`, `role:editor|viewer|guest` or `user:<id>`.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "period": {
          "description": "No_overlap only: the start and end date fields of each record, e.g. `[\"starts_at\", \"ends_at\"]`. A record with no end never ends.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "id",
        "type"
      ]
    },
    "TableTimerDto": {
      "type": "object",
      "properties": {
        "startField": {
          "type": "string",
          "description": "API name of the date-and-time field the timer starts."
        },
        "endField": {
          "type": "string",
          "description": "API name of the date-and-time field the timer stops."
        },
        "personField": {
          "type": "string",
          "description": "API name of the person field: whose time it is."
        }
      },
      "required": [
        "startField",
        "endField",
        "personField"
      ]
    },
    "TextFieldOptions": {
      "type": "object",
      "properties": {
        "isHidden": {
          "type": "boolean"
        },
        "visibleTo": {
          "description": "Makes the field private: only these people see its value (admins always do). Formulas that read it are private the same way.",
          "allOf": [
            {
              "$ref": "#/$defs/FieldVisibilityDto"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/FieldValueSource"
        },
        "prompt": {
          "type": "string",
          "description": "AI record filling prompt for the field"
        },
        "aiType": {
          "description": "Type of AI generation for the field, by default is AUTO if undefined",
          "allOf": [
            {
              "$ref": "#/$defs/AIFieldType"
            }
          ]
        },
        "inputType": {
          "allOf": [
            {
              "$ref": "#/$defs/TextFormat"
            }
          ]
        },
        "checkDuplicates": {
          "type": "boolean",
          "description": "Check for duplicates (for frontend usage)"
        },
        "isMany": {
          "type": "boolean"
        },
        "templateVariable": {
          "type": "boolean",
          "description": "Offer this field as a variable in email templates"
        }
      }
    },
    "TextFormat": {
      "type": "string",
      "enum": [
        "text",
        "email",
        "phone",
        "url",
        "country",
        "textarea",
        "messenger",
        "instagram",
        "telegram"
      ]
    },
    "TransitionStepDto": {
      "type": "object",
      "properties": {
        "from": {
          "description": "Statuses the move starts from. \"\" means no status yet.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "to": {
          "description": "Statuses the move ends in.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "when": {
          "type": "string",
          "description": "A formula that must hold for the record after the move."
        },
        "who": {
          "description": "Who may make the move: `{Field}` (a person field on the record), `role:admin|editor|viewer`, `user:<id>` or `origin:<where the save comes from>`. Omitted means anyone who can edit.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "never": {
          "description": "Who may never make the move, even when `who` (a role included) lets them: same entries as `who`. E.g. `{Person}` so nobody approves their own timesheet.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "requireComment": {
          "type": "boolean",
          "description": "The move needs a comment (e.g. why it was rejected)."
        },
        "stamp": {
          "type": "object",
          "description": "Fields written in the same save: field API name → formula, e.g. {\"approved_by\": \"ACTOR()\", \"approved_at\": \"NOW()\"}."
        }
      },
      "required": [
        "from",
        "to"
      ]
    },
    "UserFieldOptions": {
      "type": "object",
      "properties": {
        "isHidden": {
          "type": "boolean"
        },
        "visibleTo": {
          "description": "Makes the field private: only these people see its value (admins always do). Formulas that read it are private the same way.",
          "allOf": [
            {
              "$ref": "#/$defs/FieldVisibilityDto"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/FieldValueSource"
        },
        "isMany": {
          "type": "boolean"
        },
        "restrictToWorkspace": {
          "type": "boolean"
        }
      }
    }
  }
}