> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrubbe.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dashboard Endpoints: Metrics and Analytics Data

> Retrieve aggregated performance metrics and detailed analytics for your Scrubbe workspace — incident trends, MTTR, SLA compliance, and signal volumes.

The dashboard API provides the data that powers the Scrubbe analytics interface. Use the metrics endpoint to fetch high-level KPIs for a summary view, or the analytics endpoint for time-series and breakdown data suitable for custom dashboards and reporting. Both endpoints require `Authorization: Bearer <accessToken>` and live under `/api/v1/dashboard`.

***

## GET /dashboard/metrics

Retrieve key performance metrics for the authenticated user's workspace. Returns aggregate values for the current period — useful for summary cards and health indicators.

**Request**

```http theme={null}
GET /api/v1/dashboard/metrics
Authorization: Bearer <accessToken>
```

Query parameters are optional and can be used to filter the time range.

<ParamField query="from" type="string">
  ISO 8601 start date for the metrics window. Example: `"2025-05-01T00:00:00Z"`. Defaults to 30 days ago.
</ParamField>

<ParamField query="to" type="string">
  ISO 8601 end date for the metrics window. Example: `"2025-05-31T23:59:59Z"`. Defaults to the current time.
</ParamField>

**Response**

```json theme={null}
{
  "success": true,
  "message": "Metrics retrieved.",
  "data": {
    "totalIncidents": 47,
    "openIncidents": 5,
    "resolvedIncidents": 42,
    "mttr": 3420,
    "mttd": 840,
    "slaBreaches": 3,
    "slaComplianceRate": 93.6,
    "criticalIncidents": 8,
    "highIncidents": 14,
    "signalsIngested": 1283,
    "period": {
      "from": "2025-05-01T00:00:00Z",
      "to": "2025-05-31T23:59:59Z"
    }
  }
}
```

<ResponseField name="data.totalIncidents" type="number">
  Total number of incidents created during the period.
</ResponseField>

<ResponseField name="data.openIncidents" type="number">
  Number of incidents currently open.
</ResponseField>

<ResponseField name="data.resolvedIncidents" type="number">
  Number of incidents resolved during the period.
</ResponseField>

<ResponseField name="data.mttr" type="number">
  Mean time to resolution in seconds.
</ResponseField>

<ResponseField name="data.mttd" type="number">
  Mean time to detect in seconds (from signal ingestion to incident creation).
</ResponseField>

<ResponseField name="data.slaBreaches" type="number">
  Number of incidents that exceeded their SLA threshold.
</ResponseField>

<ResponseField name="data.slaComplianceRate" type="number">
  Percentage of incidents resolved within SLA. Range: 0–100.
</ResponseField>

<ResponseField name="data.criticalIncidents" type="number">
  Count of incidents with `CRITICAL` severity.
</ResponseField>

<ResponseField name="data.highIncidents" type="number">
  Count of incidents with `HIGH` severity.
</ResponseField>

<ResponseField name="data.signalsIngested" type="number">
  Total number of signals ingested from all sources during the period.
</ResponseField>

<ResponseField name="data.period" type="object">
  The effective time range used to compute the metrics.
</ResponseField>

***

## GET /dashboard/analytics

Retrieve detailed analytics data including time-series breakdowns, source distributions, and team performance statistics. Suitable for charting incident trends or building custom reporting pipelines.

**Request**

```http theme={null}
GET /api/v1/dashboard/analytics
Authorization: Bearer <accessToken>
```

<ParamField query="from" type="string">
  ISO 8601 start date. Defaults to 30 days ago.
</ParamField>

<ParamField query="to" type="string">
  ISO 8601 end date. Defaults to the current time.
</ParamField>

<ParamField query="granularity" type="string" default="day">
  Time bucket size for time-series data. One of: `"hour"`, `"day"`, `"week"`.
</ParamField>

**Response**

```json theme={null}
{
  "success": true,
  "message": "Analytics retrieved.",
  "data": {
    "incidentTrend": [
      { "date": "2025-05-01", "created": 4, "resolved": 3 },
      { "date": "2025-05-02", "created": 2, "resolved": 5 },
      { "date": "2025-05-03", "created": 1, "resolved": 2 }
    ],
    "severityBreakdown": {
      "CRITICAL": 8,
      "HIGH": 14,
      "MEDIUM": 19,
      "LOW": 6
    },
    "sourceBreakdown": {
      "prometheus": 22,
      "datadog": 11,
      "github": 7,
      "webhook": 7
    },
    "mttrByTeamMember": [
      {
        "userId": "usr_01HX...",
        "name": "Ada Lovelace",
        "mttr": 2700,
        "incidentsResolved": 12
      }
    ],
    "topIncidentSources": [
      { "source": "prometheus", "count": 22, "percentage": 46.8 }
    ],
    "period": {
      "from": "2025-05-01T00:00:00Z",
      "to": "2025-05-31T23:59:59Z",
      "granularity": "day"
    }
  }
}
```

<ResponseField name="data.incidentTrend" type="object[]">
  Time-series array of incident creation and resolution counts, bucketed by `granularity`.
</ResponseField>

<ResponseField name="data.severityBreakdown" type="object">
  Count of incidents per severity level during the period.
</ResponseField>

<ResponseField name="data.sourceBreakdown" type="object">
  Count of ingested signals per source during the period.
</ResponseField>

<ResponseField name="data.mttrByTeamMember" type="object[]">
  Per-user MTTR and resolved incident count, useful for understanding team performance distribution.
</ResponseField>

<ResponseField name="data.topIncidentSources" type="object[]">
  Ranked list of the sources generating the most signals, with counts and percentage share.
</ResponseField>

<Tip>
  Use `granularity=hour` for real-time dashboards and `granularity=week` for executive summaries. The default (`day`) works well for weekly review charts.
</Tip>

<Note>
  Both endpoints return data scoped to the authenticated user's workspace. Users with the `VIEWER` role can read analytics data but cannot modify incidents or configuration.
</Note>
