> ## Documentation Index
> Fetch the complete documentation index at: https://tally.outhebox.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON Schema

> The JSON Schema documents generated from the tally-protocol wire schemas.

`schemas/*.json` are generated from the Zod schemas and shipped with the package for adapters written in other languages:

```ts theme={null}
import queryRequest from 'tally-protocol/schemas/query-request.json' with { type: 'json' }
```

`toJsonSchema(name)` returns the same document at runtime.

> [accordion] query-request.json
>
> ```json theme={null}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "properties": {
>     "version": {
>       "type": "number",
>       "const": 1
>     },
>     "filter": {
>       "$ref": "#/$defs/Filter"
>     },
>     "sort": {
>       "type": "array",
>       "items": {
>         "$ref": "#/$defs/Sort"
>       }
>     },
>     "group": {
>       "$ref": "#/$defs/Group"
>     },
>     "page": {
>       "anyOf": [
>         {
>           "type": "object",
>           "properties": {
>             "offset": {
>               "type": "integer",
>               "minimum": 0,
>               "maximum": 9007199254740991
>             },
>             "limit": {
>               "type": "integer",
>               "minimum": 1,
>               "maximum": 9007199254740991
>             }
>           },
>           "required": ["offset", "limit"],
>           "additionalProperties": false
>         },
>         {
>           "type": "object",
>           "properties": {
>             "cursor": {
>               "type": "string"
>             },
>             "limit": {
>               "type": "integer",
>               "minimum": 1,
>               "maximum": 9007199254740991
>             }
>           },
>           "required": ["limit"],
>           "additionalProperties": false
>         }
>       ]
>     },
>     "aggregates": {
>       "type": "array",
>       "items": {
>         "type": "object",
>         "properties": {
>           "column": {
>             "type": "string",
>             "minLength": 1
>           },
>           "fn": {
>             "type": "string",
>             "enum": ["sum", "avg", "min", "max", "count", "distinct"]
>           }
>         },
>         "required": ["column", "fn"],
>         "additionalProperties": false
>       }
>     },
>     "facets": {
>       "type": "array",
>       "items": {
>         "type": "string",
>         "minLength": 1
>       }
>     }
>   },
>   "required": ["version", "sort"],
>   "additionalProperties": false,
>   "$defs": {
>     "Filter": {
>       "oneOf": [
>         {
>           "type": "object",
>           "properties": {
>             "type": {
>               "type": "string",
>               "const": "and"
>             },
>             "filters": {
>               "type": "array",
>               "items": {
>                 "$ref": "#/$defs/Filter"
>               }
>             }
>           },
>           "required": ["type", "filters"],
>           "additionalProperties": false
>         },
>         {
>           "type": "object",
>           "properties": {
>             "type": {
>               "type": "string",
>               "const": "or"
>             },
>             "filters": {
>               "type": "array",
>               "items": {
>                 "$ref": "#/$defs/Filter"
>               }
>             }
>           },
>           "required": ["type", "filters"],
>           "additionalProperties": false
>         },
>         {
>           "type": "object",
>           "properties": {
>             "type": {
>               "type": "string",
>               "const": "not"
>             },
>             "filter": {
>               "$ref": "#/$defs/Filter"
>             }
>           },
>           "required": ["type", "filter"],
>           "additionalProperties": false
>         },
>         {
>           "type": "object",
>           "properties": {
>             "type": {
>               "type": "string",
>               "const": "condition"
>             },
>             "column": {
>               "type": "string",
>               "minLength": 1
>             },
>             "op": {
>               "type": "string",
>               "enum": [
>                 "eq",
>                 "neq",
>                 "lt",
>                 "lte",
>                 "gt",
>                 "gte",
>                 "between",
>                 "contains",
>                 "notContains",
>                 "startsWith",
>                 "endsWith",
>                 "in",
>                 "notIn",
>                 "empty",
>                 "notEmpty",
>                 "within"
>               ]
>             },
>             "value": {}
>           },
>           "required": ["type", "column", "op"],
>           "additionalProperties": false
>         },
>         {
>           "type": "object",
>           "properties": {
>             "type": {
>               "type": "string",
>               "const": "search"
>             },
>             "text": {
>               "type": "string"
>             }
>           },
>           "required": ["type", "text"],
>           "additionalProperties": false
>         },
>         {
>           "type": "object",
>           "properties": {
>             "type": {
>               "type": "string",
>               "const": "flag"
>             },
>             "name": {
>               "type": "string",
>               "minLength": 1
>             }
>           },
>           "required": ["type", "name"],
>           "additionalProperties": false
>         }
>       ]
>     },
>     "Sort": {
>       "type": "object",
>       "properties": {
>         "column": {
>           "type": "string",
>           "minLength": 1
>         },
>         "direction": {
>           "type": "string",
>           "enum": ["asc", "desc"]
>         }
>       },
>       "required": ["column", "direction"],
>       "additionalProperties": false
>     },
>     "Group": {
>       "type": "object",
>       "properties": {
>         "column": {
>           "type": "string",
>           "minLength": 1
>         },
>         "granularity": {
>           "type": "string",
>           "enum": ["day", "week", "month", "quarter", "year"]
>         }
>       },
>       "required": ["column"],
>       "additionalProperties": false
>     }
>   }
> }
> ```

> [accordion] query-response.json
>
> ```json theme={null}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "properties": {
>     "rows": {
>       "type": "array",
>       "items": {
>         "$ref": "#/$defs/RowData"
>       }
>     },
>     "total": {
>       "type": "integer",
>       "minimum": 0,
>       "maximum": 9007199254740991
>     },
>     "matched": {
>       "type": "integer",
>       "minimum": 0,
>       "maximum": 9007199254740991
>     },
>     "cursor": {
>       "type": "string"
>     },
>     "groups": {
>       "type": "array",
>       "items": {
>         "$ref": "#/$defs/GroupSummary"
>       }
>     },
>     "aggregates": {
>       "type": "object",
>       "propertyNames": {
>         "type": "string"
>       },
>       "additionalProperties": {}
>     },
>     "facets": {
>       "type": "object",
>       "propertyNames": {
>         "type": "string"
>       },
>       "additionalProperties": {
>         "$ref": "#/$defs/Facet"
>       }
>     }
>   },
>   "required": ["rows"],
>   "additionalProperties": false,
>   "$defs": {
>     "RowData": {
>       "type": "object",
>       "propertyNames": {
>         "type": "string"
>       },
>       "additionalProperties": {}
>     },
>     "GroupSummary": {
>       "type": "object",
>       "properties": {
>         "key": {
>           "type": "string"
>         },
>         "value": {},
>         "count": {
>           "type": "integer",
>           "minimum": 0,
>           "maximum": 9007199254740991
>         },
>         "aggregates": {
>           "type": "object",
>           "propertyNames": {
>             "type": "string"
>           },
>           "additionalProperties": {}
>         }
>       },
>       "required": ["key", "value", "count", "aggregates"],
>       "additionalProperties": false
>     },
>     "Facet": {
>       "oneOf": [
>         {
>           "type": "object",
>           "properties": {
>             "kind": {
>               "type": "string",
>               "const": "histogram"
>             },
>             "min": {},
>             "max": {},
>             "bins": {
>               "type": "array",
>               "items": {
>                 "type": "object",
>                 "properties": {
>                   "start": {},
>                   "end": {},
>                   "count": {
>                     "type": "integer",
>                     "minimum": 0,
>                     "maximum": 9007199254740991
>                   }
>                 },
>                 "required": ["start", "end", "count"],
>                 "additionalProperties": false
>               }
>             }
>           },
>           "required": ["kind", "min", "max", "bins"],
>           "additionalProperties": false
>         },
>         {
>           "type": "object",
>           "properties": {
>             "kind": {
>               "type": "string",
>               "const": "terms"
>             },
>             "terms": {
>               "type": "array",
>               "items": {
>                 "type": "object",
>                 "properties": {
>                   "value": {},
>                   "count": {
>                     "type": "integer",
>                     "minimum": 0,
>                     "maximum": 9007199254740991
>                   }
>                 },
>                 "required": ["value", "count"],
>                 "additionalProperties": false
>               }
>             },
>             "distinct": {
>               "type": "integer",
>               "minimum": 0,
>               "maximum": 9007199254740991
>             }
>           },
>           "required": ["kind", "terms", "distinct"],
>           "additionalProperties": false
>         }
>       ]
>     }
>   }
> }
> ```

> [accordion] mutation-request.json
>
> ```json theme={null}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "properties": {
>     "version": {
>       "type": "number",
>       "const": 1
>     },
>     "mutations": {
>       "type": "array",
>       "items": {
>         "$ref": "#/$defs/Mutation"
>       }
>     }
>   },
>   "required": ["version", "mutations"],
>   "additionalProperties": false,
>   "$defs": {
>     "Mutation": {
>       "type": "object",
>       "properties": {
>         "id": {
>           "type": "string",
>           "minLength": 1
>         },
>         "label": {
>           "type": "string"
>         },
>         "at": {
>           "type": "number"
>         },
>         "changes": {
>           "type": "array",
>           "items": {
>             "type": "object",
>             "properties": {
>               "key": {
>                 "type": ["string", "number"]
>               },
>               "column": {
>                 "type": "string",
>                 "minLength": 1
>               },
>               "from": {},
>               "to": {}
>             },
>             "required": ["key", "column", "from", "to"],
>             "additionalProperties": false
>           }
>         },
>         "inserted": {
>           "type": "array",
>           "items": {
>             "type": "object",
>             "properties": {
>               "row": {
>                 "$ref": "#/$defs/RowData"
>               },
>               "index": {
>                 "type": "integer",
>                 "minimum": 0,
>                 "maximum": 9007199254740991
>               }
>             },
>             "required": ["row"],
>             "additionalProperties": false
>           }
>         },
>         "deleted": {
>           "type": "array",
>           "items": {
>             "type": "object",
>             "properties": {
>               "row": {
>                 "$ref": "#/$defs/RowData"
>               },
>               "index": {
>                 "type": "integer",
>                 "minimum": 0,
>                 "maximum": 9007199254740991
>               }
>             },
>             "required": ["row", "index"],
>             "additionalProperties": false
>           }
>         }
>       },
>       "required": ["id", "label", "at", "changes", "inserted", "deleted"],
>       "additionalProperties": false
>     },
>     "RowData": {
>       "type": "object",
>       "propertyNames": {
>         "type": "string"
>       },
>       "additionalProperties": {}
>     }
>   }
> }
> ```

> [accordion] mutation-result.json
>
> ```json theme={null}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "properties": {
>     "accepted": {
>       "type": "boolean"
>     },
>     "rows": {
>       "type": "array",
>       "items": {
>         "$ref": "#/$defs/RowData"
>       }
>     },
>     "errors": {
>       "type": "array",
>       "items": {
>         "type": "object",
>         "properties": {
>           "key": {
>             "type": ["string", "number"]
>           },
>           "column": {
>             "type": "string"
>           },
>           "message": {
>             "type": "string"
>           }
>         },
>         "required": ["message"],
>         "additionalProperties": false
>       }
>     }
>   },
>   "required": ["accepted"],
>   "additionalProperties": false,
>   "$defs": {
>     "RowData": {
>       "type": "object",
>       "propertyNames": {
>         "type": "string"
>       },
>       "additionalProperties": {}
>     }
>   }
> }
> ```

> [accordion] row-patch.json
>
> ```json theme={null}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "properties": {
>     "upserts": {
>       "type": "array",
>       "items": {
>         "$ref": "#/$defs/RowData"
>       }
>     },
>     "deletes": {
>       "type": "array",
>       "items": {
>         "type": ["string", "number"]
>       }
>     }
>   },
>   "additionalProperties": false,
>   "$defs": {
>     "RowData": {
>       "type": "object",
>       "propertyNames": {
>         "type": "string"
>       },
>       "additionalProperties": {}
>     }
>   }
> }
> ```

> [accordion] schema-response.json
>
> ```json theme={null}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "properties": {
>     "version": {
>       "type": "number",
>       "const": 1
>     },
>     "columns": {
>       "type": "array",
>       "items": {
>         "$ref": "#/$defs/Column"
>       }
>     },
>     "capabilities": {
>       "$ref": "#/$defs/Capabilities"
>     },
>     "key": {
>       "type": "string"
>     }
>   },
>   "required": ["version", "columns", "capabilities"],
>   "additionalProperties": false,
>   "$defs": {
>     "Column": {
>       "type": "object",
>       "properties": {
>         "id": {
>           "type": "string",
>           "minLength": 1,
>           "maxLength": 200
>         },
>         "type": {
>           "type": "string",
>           "minLength": 1,
>           "maxLength": 200
>         },
>         "label": {
>           "type": "string"
>         },
>         "description": {
>           "type": "string"
>         },
>         "aliases": {
>           "type": "array",
>           "items": {
>             "type": "string",
>             "minLength": 1
>           }
>         },
>         "options": {
>           "type": "array",
>           "items": {
>             "type": "object",
>             "properties": {
>               "value": {
>                 "type": "string"
>               },
>               "label": {
>                 "type": "string"
>               },
>               "color": {
>                 "type": "string"
>               }
>             },
>             "required": ["value"],
>             "additionalProperties": false
>           }
>         },
>         "format": {
>           "type": "object",
>           "properties": {
>             "currency": {
>               "type": "string",
>               "minLength": 3,
>               "maxLength": 3
>             },
>             "fractionDigits": {
>               "type": "integer",
>               "minimum": 0,
>               "maximum": 20
>             },
>             "compact": {
>               "type": "boolean"
>             },
>             "signed": {
>               "type": "boolean"
>             },
>             "prefix": {
>               "type": "string"
>             },
>             "suffix": {
>               "type": "string"
>             },
>             "dateStyle": {
>               "type": "string",
>               "enum": ["short", "medium", "long"]
>             },
>             "durationUnit": {
>               "type": "string",
>               "enum": ["seconds", "milliseconds", "minutes"]
>             }
>           },
>           "additionalProperties": false
>         },
>         "editable": {
>           "type": "boolean"
>         },
>         "sortable": {
>           "type": "boolean"
>         },
>         "filterable": {
>           "type": "boolean"
>         },
>         "groupable": {
>           "type": "boolean"
>         },
>         "searchable": {
>           "type": "boolean"
>         },
>         "width": {
>           "type": "number",
>           "exclusiveMinimum": 0
>         },
>         "minWidth": {
>           "type": "number",
>           "exclusiveMinimum": 0
>         },
>         "maxWidth": {
>           "type": "number",
>           "exclusiveMinimum": 0
>         },
>         "flex": {
>           "type": "number",
>           "minimum": 0
>         },
>         "align": {
>           "type": "string",
>           "enum": ["start", "end"]
>         },
>         "wrap": {
>           "type": "boolean"
>         },
>         "pin": {
>           "type": "string",
>           "enum": ["left", "right"]
>         },
>         "hidden": {
>           "type": "boolean"
>         },
>         "group": {
>           "type": "string"
>         },
>         "card": {
>           "type": "string",
>           "enum": ["title", "badge", "metric", "meta", "hidden"]
>         },
>         "subtitle": {
>           "type": "string",
>           "minLength": 1,
>           "maxLength": 200
>         },
>         "avatar": {
>           "type": "boolean"
>         },
>         "sparkline": {
>           "type": "string",
>           "minLength": 1,
>           "maxLength": 200
>         },
>         "relative": {
>           "type": "boolean"
>         },
>         "aggregate": {
>           "type": "string",
>           "enum": ["sum", "avg", "min", "max", "count", "distinct"]
>         },
>         "tree": {
>           "type": "boolean"
>         },
>         "rollup": {
>           "type": "boolean"
>         },
>         "ai": {
>           "type": "boolean"
>         }
>       },
>       "required": ["id", "type"],
>       "additionalProperties": false
>     },
>     "Capabilities": {
>       "type": "object",
>       "properties": {
>         "filter": {
>           "type": "boolean"
>         },
>         "sort": {
>           "type": "boolean"
>         },
>         "group": {
>           "type": "boolean"
>         },
>         "search": {
>           "type": "boolean"
>         },
>         "aggregates": {
>           "type": "boolean"
>         },
>         "facets": {
>           "type": "boolean"
>         },
>         "pagination": {
>           "type": "string",
>           "enum": ["none", "offset", "cursor"]
>         },
>         "mutate": {
>           "type": "boolean"
>         },
>         "live": {
>           "type": "boolean"
>         }
>       },
>       "required": [
>         "filter",
>         "sort",
>         "group",
>         "search",
>         "aggregates",
>         "facets",
>         "pagination",
>         "mutate",
>         "live"
>       ],
>       "additionalProperties": false
>     }
>   }
> }
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.