Access control
- Tenant admins: Can query metrics for the entire organization (tenant-wide).
- Users: Can query their own data and their teams’ data.
- Virtual accounts: Can query their own data and their teams’ data; with tenant-admin permissions, they can access tenant-wide data.
Contents
Authentication
You need to authenticate with your TrueFoundry API key. You can use either a Personal Access Token (PAT) or Virtual Account Token (VAT).Get your API key
Get your API key
To generate an API key:
- Personal Access Token (PAT): Go to Access → Personal Access Tokens in your TrueFoundry dashboard
- Virtual Account Token (VAT): Go to Access → Virtual Account Tokens (requires admin permissions)
Quick Start
The virtual-model column has two aliases. In
groupBy and aggregations[].column use virtualModel. In filters[].fieldName and in response keys, the name is virtualModelName. They refer to the same underlying database column.Distribution query
Aggregated model metrics including request counts, token totals, p99 latency, and cost grouped by model:Timeseries query
The same shape bucketed hourly:API reference
Endpoint
Authorization: Bearer <your_api_key> and Content-Type: application/json.
Request parameters
string
required
ISO 8601 timestamp marking the inclusive lower bound of the query window (e.g.
"2026-04-21T00:00:00.000Z").string
required
ISO 8601 timestamp marking the exclusive upper bound of the query window (e.g.
"2026-04-22T00:00:00.000Z").string
required
The data source to query. Use
"modelMetrics" for Gateway model metrics.string
required
The type of query to execute:
"distribution": returns aggregated rows (one row pergroupBycombination)."timeseries": returns time-bucketed rows (one row per bucket pergroupBycombination). Requiresinterval.
array
Array of Supported aggregation types
{ type, column } objects describing the aggregations to compute. When omitted, only the implicit total = COUNT(*) is returned.Supported aggregation columns
All scalar and percentile aggregation types apply to every column above.
array
Array of field names to group results by. Custom metadata keys are supported with a Available group-by fields
metadata. prefix (e.g. "metadata.environment").When
groupBy contains userEmail (without virtualaccount), the server auto-injects WHERE CreatedBySubjectType = 'user'. virtualaccount alone auto-injects 'virtualaccount'. When both appear, scope it yourself with createdBySubjectType if needed.array
Array of filter objects, AND-combined. See Filtering for the full operator reference and the per-field allow-list.
string
Required for timeseries queries. Bucket size as
<positive integer> <unit>, where <unit> is one of second, minute, hour, day, week, month, year (with or without a trailing s). Examples: "30 second", "5 minute", "1 hour", "1 day". Compound expressions like "1 hour 30 minute" are rejected.number
deprecated
Deprecated alias for
interval. Accepts a positive integer number of seconds (e.g. 3600 for hourly). Prefer interval in new code. If both are provided, interval wins.