Get Org Metrics By Date Range
GET/api/v2/org/:org_id/metrics
Get organization metrics by date range using cursor pagination in descending order.
Retrieves organization-level metrics (where workspace_id is NULL) based on their created_at timestamp. Results are ordered by created_at DESC, id DESC for consistent cursor pagination.
Args:
org_id (str): Path parameter - Organization ID to query metrics from from_date (datetime): Query parameter - Start date for filtering (inclusive) to_date (datetime): Query parameter - End date for filtering (inclusive) metric_type (str, optional): Query parameter - Filter by specific metric type Examples: "auth.user.login", "chat.message.create" If None, returns all metric types size (int): Query parameter - Maximum records to return (default: 100, max: 1000) cursor (str, optional): Query parameter - Cursor for pagination Base64 encoded datetime string from the 'next_page' field of previous response When not provided, starts from the end (to_date) and goes backwards include_total (bool): Query parameter - Include total count of entries (default: False) When true, calculates and returns the total number of entries in the database
Returns
MetricsPaginatedResponse: Paginated response containing:
- items: List of organization metrics matching the criteria (newest first)
- total: Total count of metrics in the date range (only when include_total=True)
- current_page: Current cursor (if provided)
- next_page: Cursor for next page (if more results available)
Details
- Filtering is done on created_at timestamp, NOT the event time field
- Date range is inclusive on both ends
- Results are ordered by (created_at DESC, id DESC) for descending cursor pagination
- When cursor is provided, it replaces the to_date for that query (going backwards)
- Only returns organization-level metrics (workspace_id = NULL)
- Large date ranges may impact performance for total count calculation
- Timezone information in dates is preserved but comparison is done in UTC
- Cursors are base64-encoded datetime strings for security and consistency
- Returns newest metrics first (descending order by creation time)
Permissions:
- Scope: organization_metrics:read
- Allowed Roles:
- superadmin: ✓
- admin: ✓
- controller: ✓
- curator: ✓
- basic: ✗ (read permission denied)
Request
Responses
- 200
- 422
Successful Response
Validation Error