Insights API

Get insights summary

Returns period-over-period totals, population distributions, top movers with z-scores, margin outliers, and cross-metric correlations. Call it with a GET request to /insights/summary, authenticated with a restricted API key and the "costs:read", "revenue:read" scopes.

Returns period-over-period totals, population distributions, top movers with z-scores, margin outliers, and cross-metric correlations. Designed for AI agent consumption: pure statistical data, no narrative. Use this endpoint when you need distributions, z-scored top movers, margin outliers, and correlations; use /cost-data/summary for a simple cost rollup with period comparison. All monetary values are USD. Totals (cost, revenue), top-mover costs, and distribution statistics are expressed in dollars; unmappedSpend fields are integer cents. Requests count toward your per-API-key rate limit; sustained overruns return 429 with the standard error envelope.

Authentication and scopes

Authenticate with a restricted API key in the Authorization: Bearer <key> header. This endpoint requires the costs:read, revenue:read scopes.

Parameters

NameInTypeRequiredDescription
startquerystringYesStart of date range (ISO 8601, inclusive). Filters on event invocation time, evaluated in UTC. The requested range must not exceed 365 days; longer ranges return 400.
endquerystringYesEnd of date range (ISO 8601, exclusive). Filters on event invocation time, evaluated in UTC. The requested range must not exceed 365 days; longer ranges return 400.
includequerystringNoOptional sections to compute. Supported value: distributions. Unrecognized values are ignored. When omitted, the distributions field is null.
limitquerynumber (double)NoMaximum number of top movers per category. Default 5. Values outside 1-50 are clamped to the nearest bound, not rejected; non-integer values are accepted.
prior_startquerystringNoExplicit prior period start (ISO 8601). Must be provided together with prior_end; if either is omitted, the prior period defaults to the window of equal length immediately preceding start.
prior_endquerystringNoExplicit prior period end (ISO 8601, exclusive). Must be provided together with prior_start; if either is omitted, the prior period defaults to the window of equal length immediately preceding start.

Response fields

Fields returned in the 200 response body. Nested objects are listed under their parent. A field marked optional may be absent from the body; one marked nullable is always present but its value may be null.

FieldTypeDescription
periodobjectAnalysis period metadata.
currentobjectCurrent analysis period.
startstringISO 8601 date string.
endstringISO 8601 date string.
priorobjectPrior comparison period. Auto-derived as the window of equal length immediately preceding start, or taken from prior_start and prior_end when both are provided.
startstringISO 8601 date string.
endstringISO 8601 date string.
totalsobjectPeriod-over-period totals with change metrics.
costobjectTotal cost comparison. Values are USD dollars.
currentnumber (double)Current period value.
priornumber (double)Prior period value.
change_percentnumber (double) nullablePercent change from prior to current. Null when prior is 0 and current > 0 (new entry).
revenueobjectTotal revenue comparison. Values are USD dollars.
currentnumber (double)Current period value.
priornumber (double)Prior period value.
change_percentnumber (double) nullablePercent change from prior to current. Null when prior is 0 and current > 0 (new entry).
marginobjectOverall margin comparison (percentage points).
currentnumber (double)Current period margin percentage.
priornumber (double)Prior period margin percentage.
change_pointsnumber (double)Percentage point change (current - prior).
request_countobjectTotal request count comparison.
currentnumber (double)Current period value.
priornumber (double)Prior period value.
change_percentnumber (double) nullablePercent change from prior to current. Null when prior is 0 and current > 0 (new entry).
active_end_usersobjectActive end user count comparison.
currentnumber (double)Current period value.
priornumber (double)Prior period value.
change_percentnumber (double) nullablePercent change from prior to current. Null when prior is 0 and current > 0 (new entry).
distributionsobject nullablePopulation distributions. Null when not requested via include parameter.
cost_per_end_userobject nullableCost distribution across end users, in USD dollars. Null when the period contains no qualifying data.
meannumber (double)Arithmetic mean.
mediannumber (double)Median (50th percentile).
std_devnumber (double)Population standard deviation.
p25number (double)25th percentile.
p75number (double)75th percentile.
p90number (double)90th percentile.
p99number (double)99th percentile.
skewnessnumber (double) nullableFisher-Pearson skewness. Null if fewer than 3 users or zero variance.
gininumber (double) nullableGini coefficient (0 = perfect equality, 1 = maximum inequality). Null if fewer than 2 users.
top_decile_sharenumber (double) nullablePercentage of total cost from the top 10% of users. Null if insufficient data.
cost_per_requestobject nullableCost-per-request distribution across end users, in USD dollars. Null when the period contains no qualifying data.
meannumber (double)Arithmetic mean.
mediannumber (double)Median (50th percentile).
std_devnumber (double)Population standard deviation.
p25number (double)25th percentile.
p75number (double)75th percentile.
p90number (double)90th percentile.
p99number (double)99th percentile.
margin_per_end_userobject nullableMargin percentage distribution across end users. Null when the period contains no qualifying data.
meannumber (double)Arithmetic mean.
mediannumber (double)Median (50th percentile).
std_devnumber (double)Population standard deviation.
p25number (double)25th percentile.
p75number (double)75th percentile.
p90number (double)90th percentile.
p99number (double)99th percentile.
skewnessnumber (double) nullableFisher-Pearson skewness. Null if fewer than 3 users or zero variance.
below_zero_countnumber (double)Number of end users with negative margin.
daily_costobject nullableDaily cost distribution with trend, in USD dollars. Null when the period contains no qualifying data.
meannumber (double)Arithmetic mean of daily costs.
mediannumber (double)Median daily cost.
std_devnumber (double)Population standard deviation.
minnumber (double)Minimum daily cost.
maxnumber (double)Maximum daily cost.
cvnumber (double)Coefficient of variation (std_dev / mean).
trendobject nullableLinear regression trend. Null if fewer than 2 data points.
r2number (double)
directionincreasing | decreasing | stable
slopenumber (double)
requests_per_end_userobject nullableRequest count distribution across end users. Null when the period contains no qualifying data.
meannumber (double)Arithmetic mean.
mediannumber (double)Median (50th percentile).
std_devnumber (double)Population standard deviation.
p25number (double)25th percentile.
p75number (double)75th percentile.
p90number (double)90th percentile.
p99number (double)99th percentile.
top_moversobjectTop movers by model, provider, end user, and custom dimensions.
by_modelobject[]Top movers by model.
valuestringModel slug.
costnumber (double)Current period cost (USD dollars).
priornumber (double)Prior period cost (USD dollars).
change_percentnumber (double) nullablePercent change. Null when prior is 0 and current > 0 (new entry).
share_percentnumber (double)Current period cost share (%).
prior_share_percentnumber (double)Prior period cost share (%).
z_scorenumber (double) nullableZ-score of change relative to population. Null if all changes identical.
request_countnumber (double)Request count in current period.
avg_cost_per_requestnumber (double)Average cost per request (USD dollars).
by_providerobject[]Top movers by provider.
valuestringProvider slug.
costnumber (double)Current period cost (USD dollars).
priornumber (double)Prior period cost (USD dollars).
change_percentnumber (double) nullablePercent change. Null when prior is 0 and current > 0 (new entry).
share_percentnumber (double)Current period cost share (%).
prior_share_percentnumber (double)Prior period cost share (%).
z_scorenumber (double) nullableZ-score of change relative to population. Null if all changes identical.
by_end_userobject[]Top movers by end user.
valuestringEnd user external ID (the ID supplied on your usage events).
costnumber (double)Current period cost (USD dollars).
priornumber (double)Prior period cost (USD dollars).
change_percentnumber (double) nullablePercent change. Null when prior is 0 and current > 0 (new entry).
share_percentnumber (double)Current period cost share (%).
z_scorenumber (double) nullableZ-score of change relative to population. Null if all changes identical.
percentilenumber (double) nullablePercentile rank by cost. Null if no data.
marginnumber (double) nullableCurrent period margin percentage. Null if no revenue data.
margin_percentilenumber (double) nullablePercentile rank by margin. Null if no margin data.
model_mixmap of string to number (double)Model mix: model slug to cost share percentage.
by_custom_dimensionmap of string to object[]Top movers by custom dimension, keyed by dimension key.
valuestringDimension value.
costnumber (double)Current period cost (USD dollars).
priornumber (double)Prior period cost (USD dollars).
change_percentnumber (double) nullablePercent change. Null when prior is 0 and current > 0 (new entry).
share_percentnumber (double)Current period cost share (%).
z_scorenumber (double) nullableZ-score of change relative to population. Null if all changes identical.
end_user_countnumber (double)Number of distinct end users.
request_countnumber (double)Total request count.
margin_outliersobject[]End users whose margin z-score is below -1.5. Empty when no outliers are found, when fewer than 2 end users have margin data, or when all margins are identical (zero variance).
end_userstringEnd user external ID (the ID supplied on your usage events).
marginnumber (double)Margin percentage.
deviation_from_meannumber (double)Deviation from population mean (percentage points).
z_scorenumber (double) nullableZ-score (how many std devs below mean). Null if zero variance.
costnumber (double)Total cost for this end user (USD dollars).
model_mixmap of string to number (double)Model mix: model slug to cost share percentage.
correlationsobjectCross-metric Pearson correlations.
cost_vs_request_volumenumber (double) nullablePearson correlation between cost and request volume per end user. Null if insufficient data.
margin_vs_model_mixnumber (double) nullablePearson correlation between margin and model mix concentration (HHI). Null if insufficient data.
unmapped_spendobjectAggregated unmapped-spend breakdown.
instrumentation_gap_centsnumber (double)Spend recorded without an end user ID, in integer USD cents. Close this gap by passing an end user ID in your usage events.
instrumentation_gap_percentnumber (double)instrumentation_gap_cents as a percent of total spend. A real 0, not null, when there is no spend.
connect_billing_gap_centsnumber (double)Spend for end users with no connected Stripe revenue data, in integer USD cents. Close this gap by connecting Stripe.
connect_billing_gap_percentnumber (double)connect_billing_gap_cents as a percent of total spend. A real 0, not null, when there is no spend.

Error codes

Errors return the standard error envelope with a code, message, and a correlationId you can quote to support.

StatusWhen it happens
400Invalid request parameters. Check that start and end are valid ISO 8601 dates and that the requested range does not exceed 365 days.
401Missing or invalid API key. Send your key as Authorization: Bearer YOUR_API_KEY.
403Forbidden. The API key is missing the costs:read or revenue:read scope; OR the current plan does not include the summary-ai capability.
429Rate limit or plan quota exceeded. Slow down and retry after the current window resets.
503Service unavailable. The summary could not be computed due to a temporary database issue; retry the request.

Rate limits and retries

Rate limit or plan quota exceeded. Slow down and retry after the current window resets.