Analysis boards
Chart your calls — volume, handle time, outcomes, guardrail triggers — and click through to the calls behind any number.
A board is a named collection of insights: saved charts and tables over your calls and related activity. Use one to follow call volume, compare handle time, or group extracted outcomes. We compute each insight when you view it, so it reflects the selected time range.
These routes use the /analysis prefix; authorization uses the boards
permission family.
Discover the vocabulary first
GET /analysis/schema returns the complete query language — the sources,
each source's columns with data types, the aggregations (count, sum,
avg, min, max) and filter operators each column supports, grouping
and time-basis choices, and the hard result limits — plus your agent IDs.
Refresh it before generating or repairing a definition; never guess column
names.
The schema is version: "2.0". Every column is listed once, under
sources[]: the fixed call, guardrail, tool_call and contact
sources first, then one extraction source per active
extraction object, carrying its
extraction_object_id, extraction_object_name and description. Version
1.0's top-level *_columns arrays and extraction_objects are gone — read
sources[].columns instead.
Preview before you save
POST /analysis/preview computes any valid definition without persisting
anything — the insight body minus name and position;
Idempotency-Key is optional here. Successful previews are audit-logged
because they read workspace data.
curl -X POST https://api.kejue.co/v1/analysis/preview \
-H "Authorization: Bearer $KEJUE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: board-preview-20260906-01" \
-d '{
"chart_type": "line",
"time_range": "30d",
"bucket": "day",
"group_by": "time",
"config": {
"queries": [
{"name": "Calls", "source": "call", "column": "id", "operation": "count"}
]
}
}'There is no query-string preview — nested JSON never lands in a URL or access log.
Boards
GET /analysis/boards— summaries; cursor pagination,q,archived=exclude|include|only; insights not embedded.POST /analysis/boards— an active, empty board from a 1–120-charactername; active names are unique case-insensitively, duplicates return409 analysis_board_name_taken.GET /analysis/boards/{id}— insights ordered byposition, then ID; archived boards stay readable.PATCH /analysis/boards/{id}—nameand/orarchived.
There is no public board delete. archived: true is reversible and
definition-preserving — the board becomes read-only and hidden from the
default list; restoring returns 409 if an active board has since
claimed the name.
Board detail's ETag changes when the board or any nested insight
changes; send it as If-Match when patching
(Conditional requests).
Insights
POST /analysis/boards/{id}/insights creates one; name and config
are required. Presentation fields:
| Field | Accepted values | Default |
|---|---|---|
chart_type | bar, line, area, area_percent, pie, donut, scatter, heatmap, table, number, number_delta | bar |
time_range | 24h, 7d, 30d, 90d, all, custom | 7d |
bucket | hour, day, week, month | day |
group_by | none, time, agent, value | time |
position | 0–10,000 | append |
config.queries: 1–6 queries of source, column, operation; a
query's optional name becomes its formula identifier (defaults A,
B, …). Max 10 filters and 20 unique agent_ids per query.
Sources are call, extraction, guardrail, tool_call, contact:
- Any query that references analysis output in its metric, grouping, or
filters requires
extraction_object_id. All analysis references in one insight must use the same object. A query with no analysis references rejectsextraction_object_id. callandextractioncan combine: measure call duration while grouping or filtering by an analysis field, or combine their numeric aggregates in a formula.tool_callcannot mix with other sources.contactrejectsagent_idsand cannot mix with session-rooted sources.guardrailis a deliberately narrow, count-only projection (id,guardrail_name, namespacedguardrail_id,severity,guardrail_set_slug; one trigger row is the unit counted). Guardrail queries cannot mix with other sources — an indexedincompatiblefield error. Raw trigger evidence is never exposed here — see Guardrails.
config.formula is arithmetic over query names (+, -, *, /,
numbers, parentheses); config.group_by_2 adds a secondary time,
agent, or value grouping to a single-query insight; the two cannot
combine. Create and preview bodies cap at 65,536 bytes; invalid
combinations return 422 validation_failed with field-level details.
Then:
GET /analysis/insights/{id}— normalized definition andETag.PATCH /analysis/insights/{id}— true partial update; a semantic no-op preserves the ETag.DELETE /analysis/insights/{id}— deletes the definition only, never underlying data.GET /analysis/insights/{id}/data— computes against live workspace data.
Mutating an insight on an archived board returns 409; send If-Match
on update and delete.
Combine call metrics and analysis output
To see average call duration per topic, measure call.duration_sec
with avg and group by the declared topic field from an extraction
object. Get the object ID and exact field name from
GET /analysis/schema first; topic below is an example field name.
{
"chart_type": "bar",
"time_range": "30d",
"bucket": "day",
"group_by": "value",
"config": {
"queries": [
{
"name": "Duration",
"source": "call",
"column": "duration_sec",
"operation": "avg",
"extraction_object_id": "00000000-0000-0000-0000-000000000001",
"group_by": {"source": "extraction", "column": "topic"},
"filters": [
{"source": "extraction", "column": "topic", "op": "not_null"}
]
}
],
"display": {"value_format": "duration"}
}
}Replace the example object ID and topic with values from your schema.
Send this body to POST /analysis/preview; to save it, add a name and
send it to POST /analysis/boards/{id}/insights.
In the dashboard editor, choose Call, Talk duration, and avg, select the Analysis object, set grouping to Value, then choose its topic field under Group values by. Preview and save the chart.
The query's optional group_by object selects a value dimension
independently of the metric: its source and column can reference
call or extraction. It applies when the insight's group_by or
config.group_by_2 is value. Value grouping requires a single query;
without this object, it groups by the metric's own source and column.
Filters also accept an optional source. Omit it to use the metric's
source, or set it to extraction to filter call metrics by analysis
output. The reverse works too: an extraction metric can use call
filters or a call value dimension. Field types and supported operators
still come from the schema.
The not_null filter drops calls with no topic; remove it and they collect
in a — bucket. Grouping does not multiply a call's duration by its number of analysis fields.
For numeric calculations, define a call query and an extraction query
and set config.formula to an expression over their names. For example,
A / B can divide average call duration (A) by an average numeric
analysis score (B). Formulas operate on the query aggregates, not on a
calculation performed separately for each call. A formula combining
multiple queries cannot use value grouping; formulas cannot use a
secondary grouping.
Drill down to the calls
In the dashboard, clicking a point, bar, slice, cell or table row opens the calls list narrowed to the calls behind it. The link carries four things, because a slice is the intersection of all four:
- the clicked value — the time bucket, agent, or (for
group_by: "value") the column value; - the insight's time range — so a 30-day chart does not open an all-time list. A time drill uses the clicked bucket instead, which is narrower;
- the query filters every query in the insight shares;
- the agent scope, including multiple agents. Formula insights use the union of their query scopes; if any query is unscoped, the union is all agents.
Channel exclusions remain exclusions, including multiple excluded channels.
The calls API receives repeated channel_not values and repeated agent_ids
UUIDs for a multi-agent scope.
Each one arrives as an editable filter chip, so the list states exactly which predicates are applied and each can be removed independently.
Which dimensions are drillable depends on the value dimension’s source
(query.group_by.source when present, otherwise query.source). A call
duration chart grouped by an analysis topic drills into that topic, and
shared filters retain their own sources:
| Source | Drillable by value |
|---|---|
call | direction, lifecycle status, channel, handled-by, agent, campaign name, caller/platform number, failure code, human agent |
extraction | any declared field, using its type's operators |
guardrail | name, id, severity, set slug |
tool_call | slug, name, kind, ok, error kind |
contact | not drillable — rooted at contacts, not sessions |
A chart whose column has no equivalent in the call list simply doesn't respond to clicks, rather than linking you to the wrong set of calls.
A drilled list is a best-effort narrowing, not a guaranteed row-for-row reproduction of the number on the chart. Four things legitimately move the count:
- Deleted calls. The calls list hides purged calls by default, but the
analysis engine still counts the facts they left behind — so a slice can
drill to an empty list. Add
include_purged=1to see them. - Eval traffic.
GET /v1/callsexcludes eval-backed sessions that the engine counts. - Triggers are not calls. Guardrail and tool charts count triggers and invocations, so a call that fired the same guardrail twice is two counts and one row.
- Dropped predicates. A filter the calls list cannot express
(
is_null,ends_with) is dropped rather than faked, which widens the result.
The chips show what actually applied.
Board-wide time range
The Range bar under the board title sets a single time window for every insight on it: Today, Yesterday, Last 7 days, Last 30 days, This month, Last month, or a custom window. It's a viewing filter — your saved insights don't change, and alerts keep using each insight's own saved range.
- Open Boards in the sidebar and select a board.
- In the Range row, pick Today, Yesterday, Last 7 days, Last 30 days, This month or Last month. Every tile reloads.
- For an exact window, click Custom, pick or type a start and end date and time, and click Apply range.
- Click Insight default to give each insight its own saved range again.
Presets cover whole days in your browser's time zone, and "Last 7 days" and
"Last 30 days" include today. The bar prints the resolved window and time
zone, for example OCT 20, 09:00 → OCT 21, 17:30 // ASIA/DUBAI. Each tile
shows a Board range chip; hover it to see the insight's saved range.
While a range is active:
- Time-series charts pick their bucket from the window length: hourly up to 2 days, daily up to 92 days, weekly beyond. Hour and day buckets are cut in UTC.
- Number + delta tiles compare against the window of the same length just before the board range.
- Drilling into a chart opens the calls list for the board range, or for the clicked bucket.
- Both exports use the board range.
The range is in the page URL, so a shared link opens on the same window. A
preset link is relative: "Last 7 days" is recalculated when someone else
opens it. Custom windows span at most 400 days. Presets use ?range=last_7d; custom windows use RFC 3339 ?from=…&to=… values. Your browser remembers each board’s last range and ignores an invalid URL range.
Through the API
GET /analysis/insights/{id}/data and GET /analysis/boards/{id}/export
accept from (inclusive) and to (exclusive), both RFC 3339. They replace
each insight's saved range for that request and re-bucket time series as
above. The data endpoint combines them with campaign_id.
curl 'https://api.kejue.co/v1/analysis/insights/INSIGHT_ID/data?from=2026-10-01T00:00:00Z&to=2026-10-24T00:00:00Z' \
-H "Authorization: Bearer $KEJUE_API_KEY"Send both or neither. Problems return 400 invalid_query_parameter with
details.parameter and details.reason:
reason | Meaning |
|---|---|
required | Only one of from and to was sent |
empty | The value is blank |
invalid_format | Not an RFC 3339 timestamp |
must_be_before_to | from is not before to |
range_too_long | The window is longer than 400 days (details.maximum_days) |
Export
GET /analysis/boards/{id}/export?format=csv|pdf (default csv)
uses one consistent view of every insight; an invalid or
too-large insight fails the whole export — never a silently partial
file. Exports are audit-logged, including the window when you pass one.
- CSV is the data. Each insight section lists its bucket, window
bounds (
range_from_inclusive,range_to_exclusive), grouping, formula inputs, the previous-period value for delta insights, and every result row. - PDF is a branded visual report for sharing, not a data dump. The header names the board, team, time range, when it was generated and by whom (a person, or the API key's name). Each insight is drawn as its dashboard chart; number insights become headline figures with their previous-period change, and tables become a top-12 list that points to the CSV for the rest. Pages are A4 portrait, and every page carries a "Confidential" footer with the board name and page number.
Three optional parameters shape the export:
| Parameter | Meaning |
|---|---|
from, to | One window for every insight, as in Board-wide time range |
range_label | Up to 80 characters, such as Last 30 days, printed in the PDF header. Requires from and to |
tz | IANA time zone, such as Asia/Dubai, for dates printed in the PDF. Defaults to UTC; doesn't change the data |
curl -o board.pdf 'https://api.kejue.co/v1/analysis/boards/BOARD_ID/export?format=pdf&from=2026-09-24T00:00:00Z&to=2026-10-24T00:00:00Z&range_label=Last%2030%20days&tz=Asia/Dubai' \
-H "Authorization: Bearer $KEJUE_API_KEY"Without a window, the PDF header says each insight uses its own range, and each card names it. The PDF renders Latin, Greek, Cyrillic and Arabic script; other scripts, such as Hebrew, Devanagari or Chinese, show as empty boxes — use the CSV for those.
CSV cells whose user-controlled text could start with =, +, -, or
@ get an apostrophe prefix to neutralize spreadsheet formulas; preserve
it when re-emitting the file.
Limits and freshness
Results cap at 500 rows, 50 series, and 10,000 cells; exceeding a cap
returns 422 analysis_result_too_large, never a partial 200. Nothing
is cached, but post-call facts such as extraction results and guardrail
triggers may take a short time to appear. A call that ended moments ago
may not be included yet.
Permissions
| Operation | Permission |
|---|---|
| schema, list, get, compute, preview, export | boards:read |
| create board or insight | boards:create |
| rename/archive/restore board; update insight | boards:update |
| delete insight | boards:delete |
Idempotency-Key is required for API-key board and insight creation
(Idempotency); exact schemas in the
API reference.