Skip to main content
Query insights API lets you compute aggregated insights (sums, averages, counts, and more) over items that match a metadata-based query. The system applies the specified filters first, then performs aggregation based on the provided grouping criteria, if any. To get insights, call the POST https://api.box.com/2.0/query/insights endpoint.

Parameters

To make a call, you must pass the following parameters. The request body has two top-level fields: query and metrics. Mandatory parameters are in bold.

Metric names

Each key in the metrics object is an alias defined by you for the metric. Naming convention
  • Must be a non-empty string
  • Must be unique within the request
  • Maximum length: 256 characters
  • Allowed characters: letters (a–z, A–Z), digits (0–9), and special characters _, -, and .
  • Must not start with a digit or special character
  • Whitespace and other special characters are not allowed
Behavior
  • If group_by is not specified, metrics are computed over the entire filtered dataset (ungrouped aggregation).
  • If metrics is an empty object (), a default totalResultCount count metric is returned over the filtered dataset (see Total document count example).

Examples

Total contract value

Get total contract value and counts for top 3 contract types created in June 2025. Request:
Response:

Overall average, minimum, maximum contract value

Get overall average, minimum, and maximum contract value for contracts created in June 2025. Request:
Response:

Total document count

Get total document count only by passing an empty metrics object. Request:
Response:

Response fields

Insight entry types

Bucket ordering

For requests with group_by, bucket ordering is implicit and always descending by item count (the number of documents in each bucket). The largest buckets are returned first. This ordering cannot be customized. For the Enum and Taxonomy fields, deleted options can temporarily appear in top groups while the deletion job is in progress. Such groups have their keys shown as [DELETED].

Error codes

The list below is not exhaustive, additional error codes and details can be introduced as the API evolves.
Last modified on July 26, 2026