Overview
Analytics and usage endpointsAvailable Operations
- getUserActivity - Get user activity grouped by endpoint
- getAnalyticsMeta - Get available analytics metrics and dimensions
- queryAnalytics - Query analytics data
getUserActivity
Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. Passworkspace_id to scope the response to a single workspace. Pass group_by=workspace to split each row per workspace and include workspace_id on every item; by default rows are aggregated across workspaces and workspace_id is not returned. Activity recorded before workspace resolution existed is permanently attributed to the account default workspace (no backfill is possible). A workspace-scoped management key needs activity:view_all on its own workspace and reads only that workspace: an omitted workspace_id defaults to it, a workspace_id naming any other workspace returns 403, api_key_hash and user_id resolve only keys and members of that workspace, and legacy activity with no workspace is excluded (including for the default workspace). For Custom keys, api_key_hash also requires api_keys:view_all and does not resolve deleted keys. user_id also requires workspace_members:view on an explicit non-default workspace; organization and default-workspace member filtering requires org_members:view, which is not available as a Custom grant. Management key required.
Example Usage
Standalone function
The standalone function version of this method:Parameters
Response
Promise<models.ActivityResponse>Errors
getAnalyticsMeta
Returns the available metrics, dimensions, filter operators, and granularities for the analytics query endpoint. Custom access requires an organization-scoped key withanalytics:view. Workspace-scoped keys with base Read Only or Read Write access are also accepted. Management key required.
Example Usage
Standalone function
The standalone function version of this method:Parameters
Response
Promise<operations.GetAnalyticsMetaResponse>Errors
queryAnalytics
Execute an analytics query with specified metrics, dimensions, filters, and time range. Custom access requires an organization-scoped key withanalytics:view; grouping or filtering by api_key_id or api_key_tag also requires api_keys:view_all, and by user requires org_members:view. Key hash filters resolve only non-deleted ordinary keys. Workspace-scoped keys with base Read Only or Read Write access can query only their own workspace: a workspace filter naming another workspace is refused, legacy rows with no workspace are excluded (including for the default workspace), and possible-cache metrics such as possible_cached_tokens return 400. Management key required.