Skip to content
Anlyon
Esc
↑↓navigate↵open⌘Jpreview
On this page

Analytics API

Query how many actions your agents ran, how many waited for approval or were refused, agent run outcomes and your usage, for one environment over a date range.

The analytics endpoints summarise what your agents did in one environment: action invocations and their outcomes, approval decisions, agent runs, errors and usage against your plan.

Why use it. You need to know whether an agent is behaving before a customer tells you: a rise in refused calls means a limit is doing its job or set too low, a growing approval backlog means users are not answering, and failures point at a broken connection. These endpoints give you those numbers in one call each, to put in your own dashboard or alerting, instead of paging through invocation lists.

Call an analytics endpoint

Every endpoint needs an API key with analytics:read. The Read only and Standard presets include it.

import { Client } from '@anlyonhq/sdk';

const anlyon = new Client({ apiKey: process.env.ANLYON_API_KEY! });

const { data } = await anlyon.analytics.getTrustControlAnalytics({
  startDate: '2026-10-01T00:00:00Z',
  endDate: '2026-10-27T00:00:00Z',
  granularity: 'day',
  limit: 10,
});

console.log(data);
import os
from anlyon import Client

anlyon = Client(api_key=os.environ["ANLYON_API_KEY"])

data = anlyon.analytics.trust_control_analytics(
    start_date="2026-10-01T00:00:00Z",
    end_date="2026-10-27T00:00:00Z",
    granularity="day",
    limit=10,
).data

print(data)
anlyon.close()
curl "https://api.anlyon.com/api/v2/analytics/trust-control?startDate=2026-10-01T00:00:00Z&endDate=2026-10-27T00:00:00Z&granularity=day&limit=10" \
  -H "Authorization: Bearer $ANLYON_API_KEY"

Pick the endpoint

Endpoint TypeScript Python Returns
GET /api/v2/analytics/overview analytics.getOverview() analytics.overview() Summary figures, usage and attention signals
GET /api/v2/analytics/trust-control analytics.getTrustControlAnalytics() analytics.trust_control_analytics() Action invocations and approval decisions: outcomes, latency, top actions
GET /api/v2/analytics/agents analytics.getAgentAnalytics() analytics.agent_analytics() Agent run volume, outcomes, duration, tokens and cost
GET /api/v2/analytics/usage/current analytics.getCurrentUsage() analytics.current_usage() Usage in the current billing period
GET /api/v2/analytics/usage/history analytics.getUsageHistory() analytics.usage_history() Usage over a date range
GET /api/v2/analytics/errors analytics.getErrorDistribution() analytics.error_distribution() The most frequent errors (limit)
GET /api/v2/analytics/onboarding analytics.getOnboardingStatus() analytics.onboarding_status() Which setup steps the workspace has done

Set the range and grouping

Parameter Type Default Meaning
startDate, endDate ISO 8601 date-time The API’s default window The range to report. Both are optional.
granularity hour, day, week or month day How the series is bucketed
limit Integer, 1 to 100 10 How many top entries a breakdown returns
environmentId UUID The key’s environment Only for a console session. An API key or an OAuth token always reads its own environment.

overview, trust-control and agents take all four. errors takes the range and limit.

Read the response

Each response has success and data. The product endpoints (overview, trust-control, agents) also carry:

  • range: the range actually reported. range.truncated is true when startDate is older than your plan’s analytics history.
  • scope: what the figures cover. Metered usage is counted for the whole workspace and labelled that way. Everything else is for the key’s environment.
  • charts on many endpoints: series shaped for a dashboard.

Take exact field names from the API reference.

Handle errors

Status Cause What to do
401 The key is invalid, expired or revoked Use a valid key. See API keys and scopes.
403, API key is missing required scope: analytics:read The key has no analytics:read Create a key with it, for example from the Read only preset.
403, This credential cannot access analytics for that environment An API key or OAuth token sent another environment’s environmentId Leave environmentId out, or use a key from that environment.
400 A malformed date, an unknown granularity or limit outside 1 to 100 Fix the query.
429 Rate limited Back off and retry. See Errors and rate limits.

Was this page helpful?