featurebase-node 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/client.d.mts +12 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +12 -0
  5. package/client.d.ts.map +1 -1
  6. package/client.js +21 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs +21 -1
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/audit-logs.d.mts +233 -0
  12. package/resources/audit-logs.d.mts.map +1 -0
  13. package/resources/audit-logs.d.ts +233 -0
  14. package/resources/audit-logs.d.ts.map +1 -0
  15. package/resources/audit-logs.js +122 -0
  16. package/resources/audit-logs.js.map +1 -0
  17. package/resources/audit-logs.mjs +118 -0
  18. package/resources/audit-logs.mjs.map +1 -0
  19. package/resources/help-center/articles.d.mts +248 -11
  20. package/resources/help-center/articles.d.mts.map +1 -1
  21. package/resources/help-center/articles.d.ts +248 -11
  22. package/resources/help-center/articles.d.ts.map +1 -1
  23. package/resources/help-center/articles.js +78 -0
  24. package/resources/help-center/articles.js.map +1 -1
  25. package/resources/help-center/articles.mjs +78 -0
  26. package/resources/help-center/articles.mjs.map +1 -1
  27. package/resources/help-center/help-center.d.mts +2 -2
  28. package/resources/help-center/help-center.d.mts.map +1 -1
  29. package/resources/help-center/help-center.d.ts +2 -2
  30. package/resources/help-center/help-center.d.ts.map +1 -1
  31. package/resources/help-center/help-center.js.map +1 -1
  32. package/resources/help-center/help-center.mjs.map +1 -1
  33. package/resources/help-center/index.d.mts +1 -1
  34. package/resources/help-center/index.d.mts.map +1 -1
  35. package/resources/help-center/index.d.ts +1 -1
  36. package/resources/help-center/index.d.ts.map +1 -1
  37. package/resources/help-center/index.js.map +1 -1
  38. package/resources/help-center/index.mjs.map +1 -1
  39. package/resources/index.d.mts +2 -0
  40. package/resources/index.d.mts.map +1 -1
  41. package/resources/index.d.ts +2 -0
  42. package/resources/index.d.ts.map +1 -1
  43. package/resources/index.js +5 -1
  44. package/resources/index.js.map +1 -1
  45. package/resources/index.mjs +2 -0
  46. package/resources/index.mjs.map +1 -1
  47. package/resources/organization/admins.d.mts +10 -0
  48. package/resources/organization/admins.d.mts.map +1 -1
  49. package/resources/organization/admins.d.ts +10 -0
  50. package/resources/organization/admins.d.ts.map +1 -1
  51. package/resources/organization/admins.js +2 -0
  52. package/resources/organization/admins.js.map +1 -1
  53. package/resources/organization/admins.mjs +2 -0
  54. package/resources/organization/admins.mjs.map +1 -1
  55. package/resources/reports.d.mts +720 -0
  56. package/resources/reports.d.mts.map +1 -0
  57. package/resources/reports.d.ts +720 -0
  58. package/resources/reports.d.ts.map +1 -0
  59. package/resources/reports.js +241 -0
  60. package/resources/reports.js.map +1 -0
  61. package/resources/reports.mjs +237 -0
  62. package/resources/reports.mjs.map +1 -0
  63. package/resources/users/contacts/contacts.d.mts +2 -2
  64. package/resources/users/contacts/contacts.d.ts +2 -2
  65. package/resources/users/contacts/contacts.js +1 -1
  66. package/resources/users/contacts/contacts.mjs +1 -1
  67. package/resources/webhooks.d.mts +5 -3
  68. package/resources/webhooks.d.mts.map +1 -1
  69. package/resources/webhooks.d.ts +5 -3
  70. package/resources/webhooks.d.ts.map +1 -1
  71. package/resources/webhooks.js +2 -0
  72. package/resources/webhooks.js.map +1 -1
  73. package/resources/webhooks.mjs +2 -0
  74. package/resources/webhooks.mjs.map +1 -1
  75. package/src/client.ts +73 -1
  76. package/src/resources/audit-logs.ts +609 -0
  77. package/src/resources/help-center/articles.ts +380 -10
  78. package/src/resources/help-center/help-center.ts +8 -0
  79. package/src/resources/help-center/index.ts +4 -0
  80. package/src/resources/index.ts +26 -0
  81. package/src/resources/organization/admins.ts +12 -0
  82. package/src/resources/reports.ts +1025 -0
  83. package/src/resources/users/contacts/contacts.ts +2 -2
  84. package/src/resources/webhooks.ts +5 -0
  85. package/src/version.ts +1 -1
  86. package/version.d.mts +1 -1
  87. package/version.d.ts +1 -1
  88. package/version.js +1 -1
  89. package/version.mjs +1 -1
@@ -0,0 +1,1025 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as ReportsAPI from './reports';
5
+ import { APIPromise } from '../core/api-promise';
6
+ import { buildHeaders } from '../internal/headers';
7
+ import { RequestOptions } from '../internal/request-options';
8
+
9
+ /**
10
+ * Query your workspace analytics: conversation volume, response times, CSAT, SLA compliance, teammate performance, AI agent resolutions and more. Start with the datasets catalog to discover metrics and attributes, then run queries with filters, grouping and period comparison.
11
+ */
12
+ export class Reports extends APIResource {
13
+ /**
14
+ * Returns the reporting catalog: every dataset available to your workspace with
15
+ * its metrics and attributes.
16
+ *
17
+ * This is the discovery endpoint for the reporting API — read it before building
18
+ * query payloads:
19
+ *
20
+ * - **Metrics** carry the `metric` IDs accepted by `POST /v2/reports/query`, plus
21
+ * each metric's `allowedAggregations`, unit, and whether it supports
22
+ * office-hours restriction and period comparison.
23
+ * - **Attributes** carry the `fieldId`s accepted in filter rules and the attribute
24
+ * IDs accepted as `groupBy` / `segmentBy`, plus each attribute's
25
+ * `allowedOperators` and value type. Attributes with `staticOptions` list their
26
+ * full value set inline; other filterable attributes resolve values via
27
+ * `POST /v2/reports/filter-values`.
28
+ *
29
+ * The catalog includes your workspace's custom conversation/ticket attributes
30
+ * where applicable, so it can differ between workspaces.
31
+ *
32
+ * ### Version Availability
33
+ *
34
+ * This endpoint is only available in API version 2026-01-01.nova and newer, and
35
+ * only for workspaces with the Reports product enabled (404 otherwise).
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const response = await client.reports.listDatasets();
40
+ * ```
41
+ */
42
+ listDatasets(
43
+ params: ReportListDatasetsParams | null | undefined = {},
44
+ options?: RequestOptions,
45
+ ): APIPromise<ReportListDatasetsResponse> {
46
+ const { 'Featurebase-Version': featurebaseVersion } = params ?? {};
47
+ return this._client.get('/v2/reports/datasets', {
48
+ ...options,
49
+ headers: buildHeaders([
50
+ {
51
+ ...(featurebaseVersion?.toString() != null ?
52
+ { 'Featurebase-Version': featurebaseVersion?.toString() }
53
+ : undefined),
54
+ },
55
+ options?.headers,
56
+ ]),
57
+ });
58
+ }
59
+
60
+ /**
61
+ * Executes an ad-hoc reporting query: one metric + aggregation over a date range,
62
+ * with optional filters, grouping, segmentation and period-over-period comparison.
63
+ *
64
+ * ### Building a query
65
+ *
66
+ * 1. Pick a `metric` and `aggregation` from the datasets catalog
67
+ * (`GET /v2/reports/datasets`). Counts use `count`; duration metrics support
68
+ * `sum`, `avg`, `median`, `min`, `max`, `range` and `percentile` (pass
69
+ * `percentile: 95` for p95); rate metrics use `value`.
70
+ * 2. Set the reporting window with `startDate` / `endDate` (ISO 8601) and a
71
+ * `granularity` (`hour`, `day`, `week`, `month`) for the returned time series.
72
+ * Reporting data is available from **July 12, 2026**. Windows ending earlier
73
+ * are rejected; crossing windows are clamped to that boundary in the requested
74
+ * timezone.
75
+ * 3. Optionally narrow with `filters` — a rule
76
+ * (`{ "kind": "rule", "fieldId": "...", "operator": "in", "value": [...] }`) or
77
+ * an `and`/`or` group of rules. Attribute IDs and allowed operators come from
78
+ * the catalog.
79
+ * 4. Optionally break results down with `groupBy` (primary dimension) and
80
+ * `segmentBy` (secondary dimension).
81
+ * 5. Optionally pass `compareStartDate` / `compareEndDate` to get `previousValue`
82
+ * / `deltaPercent` alongside every data point.
83
+ *
84
+ * ### Example
85
+ *
86
+ * ```json
87
+ * {
88
+ * "metric": "new_conversations",
89
+ * "aggregation": "count",
90
+ * "startDate": "2026-07-12",
91
+ * "endDate": "2026-07-15",
92
+ * "granularity": "day",
93
+ * "groupBy": "conversation.channel",
94
+ * "filters": {
95
+ * "kind": "rule",
96
+ * "fieldId": "conversation.state",
97
+ * "operator": "is",
98
+ * "value": "closed"
99
+ * }
100
+ * }
101
+ * ```
102
+ *
103
+ * ### Response shape
104
+ *
105
+ * - `value` — the aggregate across the whole window
106
+ * - `timeSeries` — one datum per granularity bucket
107
+ * - `groupedData` / `segmentData` — present when `groupBy` / `segmentBy` were
108
+ * requested
109
+ * - `flowData` — present for `view: "sankey"` (Overview conversation-flow metrics)
110
+ * - `meta` — echo of the resolved metric, dataset, unit and aggregation
111
+ *
112
+ * ### Special views
113
+ *
114
+ * - `view: "hourly_heatmap"` buckets by day-of-week × hour-of-day (use with volume
115
+ * metrics)
116
+ * - `view: "sankey"` returns conversation flow edges (Overview metrics only)
117
+ *
118
+ * ### Version Availability
119
+ *
120
+ * This endpoint is only available in API version 2026-01-01.nova and newer, and
121
+ * only for workspaces with the Reports product enabled (404 otherwise).
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const response = await client.reports.query({
126
+ * aggregation: 'count',
127
+ * endDate: '2026-07-15',
128
+ * granularity: 'day',
129
+ * metric: 'new_conversations',
130
+ * startDate: '2026-07-12',
131
+ * });
132
+ * ```
133
+ */
134
+ query(params: ReportQueryParams, options?: RequestOptions): APIPromise<ReportQueryResponse> {
135
+ const { 'Featurebase-Version': featurebaseVersion, ...body } = params;
136
+ return this._client.post('/v2/reports/query', {
137
+ body,
138
+ ...options,
139
+ headers: buildHeaders([
140
+ {
141
+ ...(featurebaseVersion?.toString() != null ?
142
+ { 'Featurebase-Version': featurebaseVersion?.toString() }
143
+ : undefined),
144
+ },
145
+ options?.headers,
146
+ ]),
147
+ });
148
+ }
149
+
150
+ /**
151
+ * Returns the available values for a filterable attribute — use it to build valid
152
+ * `filters` rules for `POST /v2/reports/query`.
153
+ *
154
+ * Works for attributes whose values live in your workspace data (tags, teammates,
155
+ * teams, companies, plans, countries, ...). Attributes with `staticOptions` in the
156
+ * catalog don't need this endpoint — their value set is already inline.
157
+ *
158
+ * - `query` narrows results by search string
159
+ * - `selectedValues` resolves labels for values you already hold (returned
160
+ * alongside search results)
161
+ *
162
+ * ### Example
163
+ *
164
+ * ```json
165
+ * { "fieldId": "conversation.tags", "query": "bill", "limit": 20 }
166
+ * ```
167
+ *
168
+ * ### Version Availability
169
+ *
170
+ * This endpoint is only available in API version 2026-01-01.nova and newer, and
171
+ * only for workspaces with the Reports product enabled (404 otherwise).
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * const response = await client.reports.lookupFilterValues({
176
+ * fieldId: 'conversation.tags',
177
+ * });
178
+ * ```
179
+ */
180
+ lookupFilterValues(
181
+ params: ReportLookupFilterValuesParams,
182
+ options?: RequestOptions,
183
+ ): APIPromise<ReportLookupFilterValuesResponse> {
184
+ const { 'Featurebase-Version': featurebaseVersion, ...body } = params;
185
+ return this._client.post('/v2/reports/filter-values', {
186
+ body,
187
+ ...options,
188
+ headers: buildHeaders([
189
+ {
190
+ ...(featurebaseVersion?.toString() != null ?
191
+ { 'Featurebase-Version': featurebaseVersion?.toString() }
192
+ : undefined),
193
+ },
194
+ options?.headers,
195
+ ]),
196
+ });
197
+ }
198
+
199
+ /**
200
+ * Returns the paginated row-level records behind a metric — either the whole
201
+ * reporting window, or one specific data point from a previous
202
+ * `POST /v2/reports/query` response.
203
+ *
204
+ * Send the **same** `metric`, date range, `granularity`, `filters`, `groupBy` /
205
+ * `segmentBy` and `view` as the query you're drilling into, plus
206
+ * `dataPointFilters` selecting the data point:
207
+ *
208
+ * - `timeBucket` — a `date` from the time series
209
+ * - `groupValue` / `segmentValue` — a `group` / `segment` value from grouped data
210
+ * - `dayOfWeek` + `hourOfDay` — a heatmap cell (`hourly_heatmap` view)
211
+ * - `flowPathId` or `sourceNodeId` + `targetNodeId` — a flow edge (`sankey` view)
212
+ *
213
+ * Pass `dataPointFilters: {}` to list all rows behind the metric for the window.
214
+ *
215
+ * Results are paginated with `page` / `pageSize` (max 200 per page);
216
+ * `availableColumns` describes every column the dataset can return and
217
+ * `defaultColumnIds` the recommended subset. Rows are keyed by column ID; identity
218
+ * cells (teammates, contacts) are objects with `id` + `label`.
219
+ *
220
+ * ### Version Availability
221
+ *
222
+ * This endpoint is only available in API version 2026-01-01.nova and newer, and
223
+ * only for workspaces with the Reports product enabled (404 otherwise).
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * const response = await client.reports.drillIn({
228
+ * endDate: 'xxxxxxxxxx',
229
+ * granularity: 'day',
230
+ * metric: 'new_conversations',
231
+ * startDate: 'xxxxxxxxxx',
232
+ * });
233
+ * ```
234
+ */
235
+ drillIn(params: ReportDrillInParams, options?: RequestOptions): APIPromise<ReportDrillInResponse> {
236
+ const { 'Featurebase-Version': featurebaseVersion, ...body } = params;
237
+ return this._client.post('/v2/reports/drill-in', {
238
+ body,
239
+ ...options,
240
+ headers: buildHeaders([
241
+ {
242
+ ...(featurebaseVersion?.toString() != null ?
243
+ { 'Featurebase-Version': featurebaseVersion?.toString() }
244
+ : undefined),
245
+ },
246
+ options?.headers,
247
+ ]),
248
+ });
249
+ }
250
+ }
251
+
252
+ export interface ReportAttribute {
253
+ /**
254
+ * Attribute ID — use as `fieldId` in filter rules and as `groupBy` / `segmentBy`
255
+ * in query requests.
256
+ */
257
+ id: string;
258
+
259
+ allowedOperators: Array<
260
+ | 'is'
261
+ | 'is_not'
262
+ | 'in'
263
+ | 'not_in'
264
+ | 'contains'
265
+ | 'not_contains'
266
+ | 'gte'
267
+ | 'lte'
268
+ | 'between'
269
+ | 'exists'
270
+ | 'not_exists'
271
+ | 'is_member_of'
272
+ | 'is_not_member_of'
273
+ >;
274
+
275
+ category: string;
276
+
277
+ description: string;
278
+
279
+ name: string;
280
+
281
+ /**
282
+ * Whether the filter uses the latest mutable state, an immutable historical
283
+ * action/snapshot, or a metric-dependent mapping.
284
+ */
285
+ semantics: 'current_state' | 'historical_action' | 'historical_snapshot' | 'dynamic_metric_mapped';
286
+
287
+ /**
288
+ * Whether the attribute can be used in `filters` rules.
289
+ */
290
+ supportsFilter: boolean;
291
+
292
+ /**
293
+ * Whether the attribute can be used as `groupBy` / `segmentBy`.
294
+ */
295
+ supportsGroupBy: boolean;
296
+
297
+ /**
298
+ * Whether `POST /v2/reports/filter-values` can list this attribute's values.
299
+ */
300
+ supportsValueLookup: boolean;
301
+
302
+ valueType: 'string' | 'number' | 'boolean' | 'date' | 'enum' | 'id';
303
+
304
+ multiValue?: boolean;
305
+
306
+ /**
307
+ * Fixed value set for enum-like attributes. Attributes without static options
308
+ * resolve values via `POST /v2/reports/filter-values`.
309
+ */
310
+ staticOptions?: Array<ReportAttributeOption>;
311
+ }
312
+
313
+ export interface ReportAttributeOption {
314
+ label: string;
315
+
316
+ value: string;
317
+ }
318
+
319
+ export interface ReportDataset {
320
+ id: string;
321
+
322
+ attributes: Array<ReportAttribute>;
323
+
324
+ description: string;
325
+
326
+ metrics: Array<ReportMetric>;
327
+
328
+ name: string;
329
+ }
330
+
331
+ export interface ReportFilterExpression {
332
+ /**
333
+ * Rules and/or nested groups of rules. Groups may nest up to 6 levels at runtime;
334
+ * 100 rules max per expression.
335
+ */
336
+ children: Array<ReportFilterRule | ReportFilterExpression.ReportFilterGroup>;
337
+
338
+ kind: 'group';
339
+
340
+ /**
341
+ * Group operator: `and` (all match) or `or` (any match).
342
+ */
343
+ op: 'and' | 'or';
344
+ }
345
+
346
+ export namespace ReportFilterExpression {
347
+ export interface ReportFilterGroup {
348
+ children: Array<ReportsAPI.ReportFilterRule>;
349
+
350
+ kind: 'group';
351
+
352
+ /**
353
+ * Group operator: `and` (all match) or `or` (any match).
354
+ */
355
+ op: 'and' | 'or';
356
+ }
357
+ }
358
+
359
+ export interface ReportFilterRule {
360
+ /**
361
+ * Attribute ID to filter on (e.g. `conversation.channel`). Discover attribute IDs
362
+ * via `GET /v2/reports/datasets`.
363
+ */
364
+ fieldId: string;
365
+
366
+ kind: 'rule';
367
+
368
+ /**
369
+ * Comparison operator. Each attribute supports a subset of operators — see the
370
+ * `allowedOperators` field in the `GET /v2/reports/datasets` catalog.
371
+ */
372
+ operator:
373
+ | 'is'
374
+ | 'is_not'
375
+ | 'in'
376
+ | 'not_in'
377
+ | 'contains'
378
+ | 'not_contains'
379
+ | 'gte'
380
+ | 'lte'
381
+ | 'between'
382
+ | 'exists'
383
+ | 'not_exists'
384
+ | 'is_member_of'
385
+ | 'is_not_member_of';
386
+
387
+ /**
388
+ * Value to compare against. Scalar for `is`, `is_not`, `contains`, `not_contains`,
389
+ * `gte`, `lte` (ISO date strings for date attributes); non-empty array for `in`,
390
+ * `not_in`, `is_member_of`, `is_not_member_of`; 2-element array for `between`;
391
+ * omit for `exists` / `not_exists`.
392
+ */
393
+ value?: string | number | boolean | Array<string | number | boolean>;
394
+ }
395
+
396
+ export interface ReportGroupedDatum {
397
+ /**
398
+ * Raw group value (e.g. an ID). Use `groupLabel` for display.
399
+ */
400
+ group: string;
401
+
402
+ value: number;
403
+
404
+ groupLabel?: string;
405
+
406
+ previousValue?: number;
407
+
408
+ segments?: Array<ReportSegmentDatum>;
409
+ }
410
+
411
+ export interface ReportMetric {
412
+ /**
413
+ * Metric ID — use as `metric` in query requests.
414
+ */
415
+ id: string;
416
+
417
+ allowedAggregations: Array<
418
+ 'count' | 'sum' | 'avg' | 'median' | 'min' | 'max' | 'range' | 'percentile' | 'value'
419
+ >;
420
+
421
+ description: string;
422
+
423
+ name: string;
424
+
425
+ /**
426
+ * Attribute IDs this specific metric accepts in filter expressions.
427
+ */
428
+ supportedFilterAttributeIds: Array<string>;
429
+
430
+ /**
431
+ * Attribute IDs this specific metric accepts as `groupBy` or `segmentBy`.
432
+ */
433
+ supportedGroupByDimensions: Array<string>;
434
+
435
+ /**
436
+ * Which `view` values `POST /v2/reports/query` accepts for this metric. Most
437
+ * metrics support `standard` and `hourly_heatmap`; conversation-flow metrics are
438
+ * `sankey`-only.
439
+ */
440
+ supportedViews: Array<'standard' | 'hourly_heatmap' | 'sankey'>;
441
+
442
+ supportsOfficeHours: boolean;
443
+
444
+ supportsPeriodComparison: boolean;
445
+
446
+ type: 'count' | 'percentage' | 'duration' | 'number';
447
+
448
+ unit: 'count' | 'percentage' | 'duration_ms' | 'number';
449
+ }
450
+
451
+ export interface ReportSegmentDatum {
452
+ segment: string;
453
+
454
+ value: number;
455
+
456
+ previousValue?: number;
457
+
458
+ segmentLabel?: string;
459
+ }
460
+
461
+ export interface ReportTimeSeriesDatum {
462
+ /**
463
+ * Time bucket start (ISO 8601).
464
+ */
465
+ date: string;
466
+
467
+ value: number;
468
+
469
+ /**
470
+ * Value for the same bucket in the comparison window, when requested.
471
+ */
472
+ previousValue?: number;
473
+
474
+ segments?: Array<ReportSegmentDatum>;
475
+ }
476
+
477
+ export interface ReportDrillInResponse {
478
+ availableColumns: Array<ReportDrillInResponse.AvailableColumn>;
479
+
480
+ defaultColumnIds: Array<string>;
481
+
482
+ meta: ReportDrillInResponse.Meta;
483
+
484
+ object: 'report_drill_in_result';
485
+
486
+ page: number;
487
+
488
+ pageSize: number;
489
+
490
+ /**
491
+ * One record per underlying row, keyed by column ID.
492
+ */
493
+ rows: Array<{
494
+ [key: string]:
495
+ | string
496
+ | number
497
+ | boolean
498
+ | Array<string>
499
+ | ReportDrillInResponse.ReportDrillInIdentityCell
500
+ | null;
501
+ }>;
502
+
503
+ timezone: string;
504
+
505
+ total: number;
506
+ }
507
+
508
+ export namespace ReportDrillInResponse {
509
+ export interface AvailableColumn {
510
+ /**
511
+ * Column ID (an attribute ID or `metric.value`).
512
+ */
513
+ id: string;
514
+
515
+ name: string;
516
+
517
+ valueType: string;
518
+
519
+ category?: string;
520
+ }
521
+
522
+ export interface Meta {
523
+ datasetId: string;
524
+
525
+ metricId: string;
526
+ }
527
+
528
+ export interface ReportDrillInIdentityCell {
529
+ id: string;
530
+
531
+ kind: 'identity';
532
+
533
+ label: string;
534
+
535
+ avatarUrl?: string;
536
+
537
+ color?: string;
538
+ }
539
+ }
540
+
541
+ export interface ReportListDatasetsResponse {
542
+ data: Array<ReportDataset>;
543
+
544
+ object: 'list';
545
+ }
546
+
547
+ export interface ReportLookupFilterValuesResponse {
548
+ data: Array<ReportAttributeOption>;
549
+
550
+ object: 'list';
551
+ }
552
+
553
+ export interface ReportQueryResponse {
554
+ meta: ReportQueryResponse.Meta;
555
+
556
+ object: 'report_query_result';
557
+
558
+ /**
559
+ * Aggregated value across the whole reporting window.
560
+ */
561
+ value: number;
562
+
563
+ /**
564
+ * Percentage change vs the comparison window.
565
+ */
566
+ deltaPercent?: number;
567
+
568
+ flowData?: Array<ReportQueryResponse.FlowData>;
569
+
570
+ groupedData?: Array<ReportGroupedDatum>;
571
+
572
+ /**
573
+ * Aggregated value for the comparison window, when requested.
574
+ */
575
+ previousValue?: number;
576
+
577
+ segmentData?: Array<ReportSegmentDatum>;
578
+
579
+ table?: ReportQueryResponse.Table;
580
+
581
+ timeSeries?: Array<ReportTimeSeriesDatum>;
582
+ }
583
+
584
+ export namespace ReportQueryResponse {
585
+ export interface Meta {
586
+ /**
587
+ * Aggregation function applied to the metric. Each metric supports a subset of
588
+ * aggregations — see the `allowedAggregations` field in the
589
+ * `GET /v2/reports/datasets` catalog.
590
+ */
591
+ aggregation: 'count' | 'sum' | 'avg' | 'median' | 'min' | 'max' | 'range' | 'percentile' | 'value';
592
+
593
+ datasetId: string;
594
+
595
+ granularity: string;
596
+
597
+ metric: string;
598
+
599
+ officeHoursOnly: boolean;
600
+
601
+ unit: 'count' | 'percentage' | 'duration_ms' | 'number';
602
+
603
+ groupBy?: string;
604
+
605
+ segmentBy?: string;
606
+ }
607
+
608
+ export interface FlowData {
609
+ metricId: string;
610
+
611
+ pathId: string;
612
+
613
+ source: string;
614
+
615
+ sourceLabel: string;
616
+
617
+ target: string;
618
+
619
+ targetLabel: string;
620
+
621
+ value: number;
622
+
623
+ colorKey?: string;
624
+
625
+ percentage?: number;
626
+
627
+ sortOrder?: number;
628
+ }
629
+
630
+ export interface Table {
631
+ columns: Array<Table.Column>;
632
+
633
+ key: string;
634
+
635
+ mode: 'aggregate' | 'records';
636
+
637
+ page: number;
638
+
639
+ pageSize: number;
640
+
641
+ rows: Array<Table.Row>;
642
+
643
+ totalRows: number;
644
+
645
+ sort?: Table.Sort;
646
+
647
+ summaryRows?: Array<Table.SummaryRow>;
648
+ }
649
+
650
+ export namespace Table {
651
+ export interface Column {
652
+ id: string;
653
+
654
+ kind: 'dimension' | 'metric' | 'record_attribute';
655
+
656
+ label: string;
657
+
658
+ sortable: boolean;
659
+
660
+ unit: 'count' | 'percentage' | 'duration_ms' | 'number' | 'text' | 'datetime';
661
+
662
+ align?: 'left' | 'right';
663
+
664
+ sticky?: boolean;
665
+
666
+ summary?: 'sum' | 'weighted_rate' | 'none';
667
+
668
+ valueType?: string;
669
+ }
670
+
671
+ export interface Row {
672
+ id: string;
673
+
674
+ cells: { [key: string]: Row.Cells };
675
+ }
676
+
677
+ export namespace Row {
678
+ export interface Cells {
679
+ display: string;
680
+
681
+ denominator?: number;
682
+
683
+ numerator?: number;
684
+
685
+ raw?: unknown;
686
+
687
+ sortValue?: string | number | null;
688
+
689
+ value?: unknown;
690
+ }
691
+ }
692
+
693
+ export interface Sort {
694
+ columnId: string;
695
+
696
+ direction: 'asc' | 'desc';
697
+ }
698
+
699
+ export interface SummaryRow {
700
+ id: string;
701
+
702
+ cells: { [key: string]: SummaryRow.Cells };
703
+ }
704
+
705
+ export namespace SummaryRow {
706
+ export interface Cells {
707
+ display: string;
708
+
709
+ denominator?: number;
710
+
711
+ numerator?: number;
712
+
713
+ raw?: unknown;
714
+
715
+ sortValue?: string | number | null;
716
+
717
+ value?: unknown;
718
+ }
719
+ }
720
+ }
721
+ }
722
+
723
+ export interface ReportListDatasetsParams {
724
+ /**
725
+ * API version for this request. Defaults to your organization's configured API
726
+ * version if not specified.
727
+ */
728
+ 'Featurebase-Version'?: '2026-01-01.nova' | '2025-12-12.clover';
729
+ }
730
+
731
+ export interface ReportQueryParams {
732
+ /**
733
+ * Body param: Aggregation function applied to the metric. Each metric supports a
734
+ * subset of aggregations — see the `allowedAggregations` field in the
735
+ * `GET /v2/reports/datasets` catalog.
736
+ */
737
+ aggregation: 'count' | 'sum' | 'avg' | 'median' | 'min' | 'max' | 'range' | 'percentile' | 'value';
738
+
739
+ /**
740
+ * Body param: End of the reporting window (ISO 8601 date or datetime, inclusive).
741
+ * Windows ending before 2026-07-12 are rejected.
742
+ */
743
+ endDate: string;
744
+
745
+ /**
746
+ * Body param: Time bucket size for the returned time series.
747
+ */
748
+ granularity: 'hour' | 'day' | 'week' | 'month';
749
+
750
+ /**
751
+ * Body param: Metric ID to query (e.g. `new_conversations`). Discover metric IDs
752
+ * via `GET /v2/reports/datasets`.
753
+ */
754
+ metric: string;
755
+
756
+ /**
757
+ * Body param: Start of the reporting window (ISO 8601 date or datetime,
758
+ * inclusive). Reporting data is available from 2026-07-12; crossing windows are
759
+ * clamped to that boundary.
760
+ */
761
+ startDate: string;
762
+
763
+ /**
764
+ * Body param: End of the comparison window. Must be paired with
765
+ * `compareStartDate`.
766
+ */
767
+ compareEndDate?: string;
768
+
769
+ /**
770
+ * Body param: Start of the comparison window for period-over-period deltas. Must
771
+ * be paired with `compareEndDate`.
772
+ */
773
+ compareStartDate?: string;
774
+
775
+ /**
776
+ * Body param: Filter expression: a single rule, or an `and`/`or` group combining
777
+ * rules and nested groups. Attribute IDs and their allowed operators come from
778
+ * `GET /v2/reports/datasets`.
779
+ */
780
+ filters?: ReportFilterRule | ReportFilterExpression;
781
+
782
+ /**
783
+ * Body param: Attribute ID to group results by (e.g. `conversation.channel`). See
784
+ * `supportsGroupBy` in the catalog.
785
+ */
786
+ groupBy?: string;
787
+
788
+ /**
789
+ * Body param: Restrict time-based metrics to configured office hours. Only
790
+ * supported by some metrics (see `supportsOfficeHours` in the catalog).
791
+ */
792
+ officeHoursOnly?: boolean;
793
+
794
+ /**
795
+ * Body param: Percentile (1-100) — required when `aggregation` is `percentile`.
796
+ */
797
+ percentile?: number;
798
+
799
+ /**
800
+ * Body param: Attribute ID for secondary segmentation within each group or time
801
+ * bucket.
802
+ */
803
+ segmentBy?: string;
804
+
805
+ /**
806
+ * Body param: IANA timezone for date bucketing (e.g. `America/New_York`). Defaults
807
+ * to UTC.
808
+ */
809
+ timezone?: string;
810
+
811
+ /**
812
+ * Body param: Result shape. `standard` returns a time series (plus grouped/segment
813
+ * data when requested), `hourly_heatmap` buckets by day-of-week × hour-of-day,
814
+ * `sankey` returns conversation flow data. Each metric lists its `supportedViews`
815
+ * in the `GET /v2/reports/datasets` catalog.
816
+ */
817
+ view?: 'standard' | 'hourly_heatmap' | 'sankey';
818
+
819
+ /**
820
+ * Header param: API version for this request. Defaults to your organization's
821
+ * configured API version if not specified.
822
+ */
823
+ 'Featurebase-Version'?: '2026-01-01.nova' | '2025-12-12.clover';
824
+ }
825
+
826
+ export interface ReportLookupFilterValuesParams {
827
+ /**
828
+ * Body param: Attribute ID to look up values for (must have
829
+ * `valueSource: "remote_search"` or static options in the catalog).
830
+ */
831
+ fieldId: string;
832
+
833
+ /**
834
+ * Body param: Maximum number of options to return (1-50, default 20).
835
+ */
836
+ limit?: number;
837
+
838
+ /**
839
+ * Body param: Optional search string to narrow the returned options.
840
+ */
841
+ query?: string;
842
+
843
+ /**
844
+ * Body param: Already-selected values to resolve labels for (returned alongside
845
+ * search results).
846
+ */
847
+ selectedValues?: Array<string>;
848
+
849
+ /**
850
+ * Header param: API version for this request. Defaults to your organization's
851
+ * configured API version if not specified.
852
+ */
853
+ 'Featurebase-Version'?: '2026-01-01.nova' | '2025-12-12.clover';
854
+ }
855
+
856
+ export interface ReportDrillInParams {
857
+ /**
858
+ * Body param
859
+ */
860
+ endDate: string;
861
+
862
+ /**
863
+ * Body param: Time bucket size for the returned time series.
864
+ */
865
+ granularity: 'hour' | 'day' | 'week' | 'month';
866
+
867
+ /**
868
+ * Body param: Metric ID the drill-in belongs to.
869
+ */
870
+ metric: string;
871
+
872
+ /**
873
+ * Body param
874
+ */
875
+ startDate: string;
876
+
877
+ /**
878
+ * Body param: Narrows the drill-in to one data point from a previous query (time
879
+ * bucket, group value, heatmap cell, or flow edge). Pass `{}` to list all
880
+ * underlying rows.
881
+ */
882
+ dataPointFilters?: ReportDrillInParams.DataPointFilters;
883
+
884
+ /**
885
+ * Body param: Filter expression: a single rule, or an `and`/`or` group combining
886
+ * rules and nested groups. Attribute IDs and their allowed operators come from
887
+ * `GET /v2/reports/datasets`.
888
+ */
889
+ filters?: ReportFilterRule | ReportFilterExpression;
890
+
891
+ /**
892
+ * Body param
893
+ */
894
+ groupBy?: string;
895
+
896
+ /**
897
+ * Body param
898
+ */
899
+ officeHoursOnly?: boolean;
900
+
901
+ /**
902
+ * Body param: Page number (1-based).
903
+ */
904
+ page?: number;
905
+
906
+ /**
907
+ * Body param: Rows per page (1-200, default 25).
908
+ */
909
+ pageSize?: number;
910
+
911
+ /**
912
+ * Body param
913
+ */
914
+ segmentBy?: string;
915
+
916
+ /**
917
+ * Body param: A metric ID from the datasets catalog. Use when the originating
918
+ * chart aggregates several metrics to pick which one the drill-in follows.
919
+ * Defaults to `metric`.
920
+ */
921
+ selectedMetricId?: string;
922
+
923
+ /**
924
+ * Body param
925
+ */
926
+ sort?: Array<ReportDrillInParams.Sort>;
927
+
928
+ /**
929
+ * Body param
930
+ */
931
+ timezone?: string;
932
+
933
+ /**
934
+ * Body param: Result shape. `standard` returns a time series (plus grouped/segment
935
+ * data when requested), `hourly_heatmap` buckets by day-of-week × hour-of-day,
936
+ * `sankey` returns conversation flow data. Each metric lists its `supportedViews`
937
+ * in the `GET /v2/reports/datasets` catalog.
938
+ */
939
+ view?: 'standard' | 'hourly_heatmap' | 'sankey';
940
+
941
+ /**
942
+ * Header param: API version for this request. Defaults to your organization's
943
+ * configured API version if not specified.
944
+ */
945
+ 'Featurebase-Version'?: '2026-01-01.nova' | '2025-12-12.clover';
946
+ }
947
+
948
+ export namespace ReportDrillInParams {
949
+ /**
950
+ * Narrows the drill-in to one data point from a previous query (time bucket, group
951
+ * value, heatmap cell, or flow edge). Pass `{}` to list all underlying rows.
952
+ */
953
+ export interface DataPointFilters {
954
+ /**
955
+ * Day of week (1 = Monday … 7 = Sunday) — for `hourly_heatmap` views.
956
+ */
957
+ dayOfWeek?: number;
958
+
959
+ /**
960
+ * Flow path ID — for `sankey` views.
961
+ */
962
+ flowPathId?: string;
963
+
964
+ /**
965
+ * Group value to drill into (a `group` value from `groupedData`).
966
+ */
967
+ groupValue?: string;
968
+
969
+ /**
970
+ * Hour of day (0-23) — for `hourly_heatmap` views.
971
+ */
972
+ hourOfDay?: number;
973
+
974
+ /**
975
+ * Segment value to drill into (a `segment` value from segment data).
976
+ */
977
+ segmentValue?: string;
978
+
979
+ /**
980
+ * Flow source node ID — for `sankey` views.
981
+ */
982
+ sourceNodeId?: string;
983
+
984
+ /**
985
+ * Flow target node ID — for `sankey` views.
986
+ */
987
+ targetNodeId?: string;
988
+
989
+ /**
990
+ * Time bucket to drill into (a `date` value from the query time series).
991
+ */
992
+ timeBucket?: string;
993
+ }
994
+
995
+ export interface Sort {
996
+ direction: 'asc' | 'desc';
997
+
998
+ /**
999
+ * Column ID to sort by (an attribute ID or `metric.value`).
1000
+ */
1001
+ fieldId: string;
1002
+ }
1003
+ }
1004
+
1005
+ export declare namespace Reports {
1006
+ export {
1007
+ type ReportAttribute as ReportAttribute,
1008
+ type ReportAttributeOption as ReportAttributeOption,
1009
+ type ReportDataset as ReportDataset,
1010
+ type ReportFilterExpression as ReportFilterExpression,
1011
+ type ReportFilterRule as ReportFilterRule,
1012
+ type ReportGroupedDatum as ReportGroupedDatum,
1013
+ type ReportMetric as ReportMetric,
1014
+ type ReportSegmentDatum as ReportSegmentDatum,
1015
+ type ReportTimeSeriesDatum as ReportTimeSeriesDatum,
1016
+ type ReportDrillInResponse as ReportDrillInResponse,
1017
+ type ReportListDatasetsResponse as ReportListDatasetsResponse,
1018
+ type ReportLookupFilterValuesResponse as ReportLookupFilterValuesResponse,
1019
+ type ReportQueryResponse as ReportQueryResponse,
1020
+ type ReportListDatasetsParams as ReportListDatasetsParams,
1021
+ type ReportQueryParams as ReportQueryParams,
1022
+ type ReportLookupFilterValuesParams as ReportLookupFilterValuesParams,
1023
+ type ReportDrillInParams as ReportDrillInParams,
1024
+ };
1025
+ }