Skip to main content

Query Basics

The Query API returns aggregated metrics based on how you group the data. Every query requires:
ParameterDescription
groupByHow to aggregate data (TOPIC, SESSION, GAP, etc.)
instanceIdWhich instance to query
dateRange.startStart of time range (ISO 8601)
dateRange.endEnd of time range (ISO 8601)
timeGranularityTime bucketing (ALL, HOUR, DAY, WEEK, MONTH)
fieldsWhich metrics to return

Group By Options

ValueReturnsUse Case
TOPICOne row per topicWhat are users talking about?
SESSIONOne row per conversationDrill into specific conversations
END_USEROne row per userUser-level engagement
GAPOne row per gapWhat’s my AI missing?
CSAT_DSATOne row per signal typeHow do users feel?
REPEATED_REQUESTOne row per repeated requestWhere do users struggle?

Time Granularity

ValueBehavior
ALLSingle aggregation across entire date range
HOUROne row per hour per group
DAYOne row per day per group
WEEKOne row per week per group
MONTHOne row per month per group
Use ALL for totals, other values for trend analysis.

Sorting

Sort results by any numeric field:
sort.field=sessions&sort.order=DESC
Available sort orders: ASC, DESC

Filtering

By Entity IDs

Filter results by related entities:
# Sessions or end users about specific topics
topicIds=topic-uuid-1,topic-uuid-2

# Sessions with specific signals
signalIds=signal-uuid

# Sessions with specific gaps
gapIds=gap-uuid

# Sessions with specific repeated requests
repeatedRequestIds=rr-uuid
topicIds works with both groupBy=SESSION and groupBy=END_USER. Other entity filters only work with groupBy=SESSION.

By Gap Type

When querying gaps, filter by type:
gapType=KNOWLEDGE  # or TOOL

By Language

When querying sessions, filter by detected language:
language=en  # or es, fr, de, etc.

Common Query Patterns

Top Topics This Month

GET /v1/query?
  groupBy=TOPIC&
  instanceId=...&
  dateRange.start=2024-01-01T00:00:00Z&
  dateRange.end=2024-01-31T23:59:59Z&
  timeGranularity=ALL&
  fields=sessions,users,messages&
  sort.field=sessions&
  sort.order=DESC&
  limit=10
GET /v1/query?
  groupBy=TOPIC&
  instanceId=...&
  dateRange.start=2024-01-01T00:00:00Z&
  dateRange.end=2024-01-31T23:59:59Z&
  timeGranularity=DAY&
  fields=sessions,messages

Worst Performing Sessions

GET /v1/query?
  groupBy=SESSION&
  instanceId=...&
  dateRange.start=2024-01-01T00:00:00Z&
  dateRange.end=2024-01-31T23:59:59Z&
  timeGranularity=ALL&
  fields=messages,sat,dsat,repeatedRequests&
  dimensionFields=title,summary&
  sort.field=dsat&
  sort.order=DESC&
  limit=20

Knowledge Gaps by Frequency

GET /v1/query?
  groupBy=GAP&
  instanceId=...&
  gapType=KNOWLEDGE&
  dateRange.start=2024-01-01T00:00:00Z&
  dateRange.end=2024-01-31T23:59:59Z&
  timeGranularity=ALL&
  fields=sessions,messages&
  sort.field=messages&
  sort.order=DESC

Sessions About a Specific Gap

GET /v1/query?
  groupBy=SESSION&
  instanceId=...&
  gapIds=gap-uuid&
  dateRange.start=2024-01-01T00:00:00Z&
  dateRange.end=2024-01-31T23:59:59Z&
  timeGranularity=ALL&
  fields=messages,sat,dsat&
  dimensionFields=title,summary,topics

Field Reference

Available by Group By

Group ByAvailable Fields
TOPICsessions, users, messages, avgMessagesPerSession, sat, dsat, netSat
SESSIONmessages, duration, lastActiveAt, sat, dsat, netSat, repeatedRequests
END_USERsessions, messages, sat, dsat, netSat, repeatedRequests
GAPsessions, users, messages
CSAT_DSATsessions, users, messages
REPEATED_REQUESTsessions, users, messages

Dimension Fields

Extra metadata available for some group by options:
Group ByDimension Fields
SESSIONtitle, summary, topics, language
END_USERexternalId, topTopics, createdAt, lastActiveAt