query | object | Defines the filtering conditions and grouping parameters for an insights request. Holds predicate, params, ancestors, and group_by together (not mutually exclusive). | ancestors |
query.predicate | string | Filters the dataset before the metric computation. The predicate syntax is similar to an SQL WHERE clause and can include parameterized arguments. | enterprise_12345678:book:amount >= :value |
query.params | object | Must include a key for each placeholder, where the key matches the placeholder name without the : prefix. Value types must match the field types used in the predicate. Required only if the predicate contains parameter placeholders (for example, :param). | { "value": 100 } |
query.ancestors | array of objects | Filters results based on item ancestry. Each object needs an id and type (such as folder). Returns items contained within any of the specified ancestors. The user must have access to all provided ancestors, otherwise the request is rejected. If empty or omitted, insights are computed across all accessible items (root context, 0). | [{ "id": "123", "type": "folder" }] |
query.group_by | array of objects | Specifies how data is grouped. Each entry defines a grouping field and an optional bucket limit. Only a single group-by field is currently supported. Grouping is applied after filters and before metric computation. Grouping on high-cardinality fields can error; keep cardinality below 10,000. | |
[{ "field": "enterprise_12345678:book:category", "bucket_limit": 5 }] | | | |
query.group_by[].field | string | Fully qualified field name to group by. Supported fields include metadata and item properties (see supported field types). | enterprise_12345678:book:category |
query.group_by[].bucket_limit | integer | Maximum number of buckets to return for the grouping. Defaults to 5, maximum allowed value is 10. | 5 |
metrics | object (map) | A set of named metrics to compute. Each entry maps a user-defined alias to a metric operation applied to a field. Metrics are evaluated after filters (and grouping, if specified). Maximum 10 metrics in a request. | See examples below. |
metrics.<alias>.type | string | Aggregation function to apply. Supported values: sum, avg, min, max, count. | count |
metrics.<alias>.field | string | Fully qualified field name on which the metric is computed. | enterprise_12345678:product:category |