# Get an environment's analytics dashboard

> Source: https://truto.one/docs/api-reference/admin/analytics/dashboard/

`GET /analytics/dashboard`

Resource: **Analytics**

**Everything the Dashboard shows, for one environment, in one call.** This is the endpoint the Truto Dashboard, the CLI (`truto analytics dashboard`) and the platform MCP server use. Numbers are read live from the logs and Truto's database and cached for 6 hours. A range that includes today runs up to now.
The response has: - **Headline numbers** (`kpis`): each figure for the range and for the days it is compared with (when those are inside the 90-day window), with a daily series: the same days of last month for a month-to-date range (Nov 1–11 against Oct 1–11, clamped to the end of a shorter month), the whole month before for a whole calendar month, and otherwise the span of the same length just before it. The top-level `previous` names those days. Also calls by category, account events, every integration's calls and accounts, and the environment's integrated accounts as they are now. These ignore the page filters. - **`api_calls`**: API calls per day as a total, by category and by integration. - **`latency_p95`**: total and provider latency p95 per day. - **`hourly_api_calls`**: API calls per hour over the last 7 days of the range. - **`status_codes`**: billable API calls by HTTP status class. Background work (workflows, sync jobs, webhook deliveries) has no status and is not included. - **`errors_by_integration`**: the integrations with the most errors, counted over billable API calls like `kpis.errors`. - **`accounts`**: a page of the integrated accounts with the most API calls. Page it with `accounts_cursor` and search it with `accounts_search`; each page's tenant, status, label and existence are read live, and deleted accounts are left out.
Each part takes the page filters its metric accepts (`filter[category]`, `filter[integration]`): latency has no category, and the accounts table takes the integration filter only. A part that cannot be loaded right now is `null` and is named in `unavailable`; the rest of the response is still returned.
Callable with a dashboard session or an API token. An API token reaches its own environment only.
API calls and billable API calls are the same count, made with the billing filter: only requests that reach a provider's API. Latency figures in `kpis` are the p95 over the whole range.

## Query parameters

- **`environment_id`** _(string)_
  The environment to report on; the caller must be able to reach it. Required with a session. With an API token it defaults to the token's environment.
- **`range`** _(string)_
  A named range ending today, inside the 90-day window. `mtd` is this month, `last_month` the whole of last month, `7d` / `30d` / `90d` the last 7, 30 or 90 days. Send this or `from` / `to`, not both. Defaults to `mtd`.
  Allowed: `mtd`, `last_month`, `7d`, `30d`, `90d`
- **`from`** _(string)_
  A custom range's first UTC day (inclusive). Defaults to 30 days before `to`. Clamped to the 90-day window.
- **`to`** _(string)_
  A custom range's last UTC day (inclusive). Defaults to today; a range that includes today runs up to now.
- **`filter`** _(object)_
  Page filters, `filter[category]=<id>` and `filter[integration]=<name>`. Each part takes the ones its metric accepts; the headline numbers take none.
- **`accounts_cursor`** _(string)_
  The `accounts.next_cursor` of the previous response, for the next page of accounts. The rest of the response is the same (served from the cache).
- **`accounts_search`** _(string)_
  Only accounts whose id starts with this.

## Response body

- **`environment_id`** _(string)_
- **`range`** _(string)_
  The named range shown, or `custom` for `from` / `to`.
  Allowed: `mtd`, `last_month`, `7d`, `30d`, `90d`, `custom`
- **`window`** _(object)_
  The days analytics can show (the last 90 days, up to today).
  - **`from`** _(string)_
  - **`to`** _(string)_
- **`cache_seconds`** _(integer)_
  How long the parts of this response are cached.
- **`filters`** _(object)_
  The page filters applied, as sent.
- **`from`** _(string)_
- **`to`** _(string)_
- **`previous`** _(object)_
  The days every `previous` value covers. `range=mtd` (this month so far) is compared with the same days of last month, `range=last_month` with the whole month before, and any other range with the span of the same length just before it. A range that ends today is compared up to the same time of day. Null when those days are older than the 90 days analytics keeps.
  - **`from`** _(string)_
  - **`to`** _(string)_
- **`buckets`** _(array<string>)_
- **`generated_at`** _(string)_
  When the numbers were read. Responses are cached for 6 hours, so a range that includes today shows today as of this time.
- **`kpis`** _(object)_
  Each headline number for the range, for the `previous` days it is compared with, and a daily series. `accounts`, `active_accounts` and `active_integrations` describe the accounts as they are now, so they have no previous value or series.
  - **`api_calls`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`billable_api_calls`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`errors`** _(object)_
    Billable API calls that returned an HTTP status of 400 or above.
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`error_rate`** _(object)_
    `errors` divided by `billable_api_calls`: the same calls the API calls count shows. Null when there were no billable calls.
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`rate_limited`** _(object)_
    Billable API calls that returned HTTP 429, so never more than `errors`.
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`latency_p95`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`provider_latency_p95`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`records_synced`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`sync_failures`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`webhook_events`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`webhook_failure_rate`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`mcp_calls`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`new_accounts`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`accounts`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`active_accounts`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
  - **`active_integrations`** _(object)_
    - **`value`** _(number)_
      Null when there is nothing to measure, e.g. a rate with no requests behind it.
    - **`previous`** _(number)_
      The same figure for the span of equal length just before the range (ending at the same time of day); null when that span is not inside the 90-day window, and for numbers that describe the accounts as they are now.
    - **`series`** _(array<number>)_
      One value per day of the range (null for a rate or latency with no requests that day); empty for numbers that describe the accounts as they are now.
- **`by_category`** _(array<object>)_
  - **`category`** _(string)_
  - **`calls`** _(integer)_
- **`inventory`** _(object)_
  The environment's integrations and integrated accounts as they are now.
  - **`as_of`** _(string)_
  - **`accounts`** _(integer)_
  - **`by_status`** _(object)_
  - **`active_connections`** _(integer)_
  - **`superquery_accounts`** _(integer)_
  - **`installed_connectors`** _(integer)_
  - **`active_connectors`** _(integer)_
- **`account_events`** _(array<object>)_
  Integrated account lifecycle events in the range, from the logs (for example `created`, `updated`, `deleted`).
  - **`event`** _(string)_
  - **`count`** _(integer)_
- **`integrations`** _(array<object>)_
  Every integration with API calls in the range or integrated accounts now, by API calls.
  - **`integration`** _(string)_
  - **`calls`** _(integer)_
    API calls as billing counts them (the `billable_api_calls` filter).
  - **`requests`** _(integer)_
    The denominator of the error rate, the same billable calls as `calls`.
  - **`errors`** _(integer)_
    Billable calls that returned an HTTP status of 400 or above.
  - **`accounts`** _(integer)_
  - **`active_accounts`** _(integer)_
  - **`attention_accounts`** _(integer)_
    Accounts with status `needs_reauth`, `validation_error` or `post_install_error` now.
- **`api_calls`** _(object)_
  API calls per day (as billing counts them), aligned with `buckets`. `null` when it could not be loaded.
  - **`buckets`** _(array<string>)_
  - **`total`** _(array<object>)_
    - **`key`** _(string)_
    - **`values`** _(array<number>)_
    - **`total`** _(number)_
  - **`by_category`** _(array<object>)_
    - **`key`** _(string)_
    - **`values`** _(array<number>)_
    - **`total`** _(number)_
  - **`by_integration`** _(array<object>)_
    - **`key`** _(string)_
    - **`values`** _(array<number>)_
    - **`total`** _(number)_
- **`latency_p95`** _(object)_
  p95 latency per day in ms, total and waiting on the provider; `null` on a day without requests.
  - **`buckets`** _(array<string>)_
  - **`total`** _(array<number>)_
  - **`provider`** _(array<number>)_
- **`hourly_api_calls`** _(object)_
  API calls per hour (UTC) over the last 7 days of the range; an hour later today is `null`.
  - **`from`** _(string)_
  - **`to`** _(string)_
  - **`buckets`** _(array<string>)_
  - **`values`** _(array<number>)_
- **`status_codes`** _(array<object>)_
  Billable API calls by HTTP status class (`2`, `4`, `5`, ...), largest first.
  - **`key`** _(string)_
  - **`value`** _(number)_
- **`errors_by_integration`** _(array<object>)_
  The integrations with the most requests that returned HTTP 400 or above. An empty `key` is calls with no integration (Admin API calls, and requests that failed before an integration was known).
  - **`key`** _(string)_
  - **`value`** _(number)_
- **`accounts`** _(object)_
  One page of the integrated accounts with the most API calls in the range. Only accounts that still exist are listed.
  - **`rows`** _(array<object>)_
    - **`key`** _(string)_
      The integrated account id.
    - **`value`** _(number)_
      API calls.
    - **`integration`** _(string)_
    - **`calls`** _(integer)_
    - **`errors`** _(integer)_
    - **`last_active_day`** _(string)_
    - **`last_active_at`** _(string)_
    - **`tenant_id`** _(string)_
    - **`status`** _(string)_
    - **`label`** _(string)_
      The account's `context.label`, when it is text.
  - **`next_cursor`** _(string)_
    Pass as `accounts_cursor` for the next page.
  - **`search`** _(string)_
- **`unavailable`** _(array<string>)_
  Parts that could not be loaded right now and are `null` (`api_calls`, `latency`, `hourly_api_calls`, `status_codes`, `errors_by_integration`, `accounts`).

## Errors

| Status | Description |
| :----- | :---------- |
| `400` | Missing `environment_id`; a malformed date, an unknown `range`, `range` sent with `from`/`to`, or a range outside the window; a filter other than `category` / `integration`; an invalid `accounts_cursor` or `accounts_search`; or a query parameter the route does not take |
| `403` | Forbidden if the caller cannot reach the environment (an API token reaches its own environment only), or uses an integrated-account or tenant token |
| `429` | More uncached analytics reads for this environment than the per-minute limit allows. Retry after the `Retry-After` header (60 seconds). Cached responses are not limited. |
| `502` | The logs could not be read. The response carries a generic message; retry in a minute. |

## Code examples

### curl

```bash
curl -X GET 'https://api.truto.one/analytics/dashboard' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json'
```

### JavaScript

```javascript
const response = await fetch('https://api.truto.one/analytics/dashboard', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/analytics/dashboard"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}

response = requests.get(url, headers=headers, params=params)
print(response.json())
```
