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

# Analytics API

> Query executions, availability, incidents, anomalies and pre-computed metrics via the read API

## Overview

The Analytics endpoints expose the same monitoring data that powers your dashboard: pre-computed metric aggregations, raw executions, availability samples, incidents and anomalies. They all require an API key with `analytics: read` (see [Authentication](/api-reference/authentication)) and are automatically scoped to the connections your key can access.

Base URL:

```
https://api.opsmatic.com/v1
```

## Cursor Pagination

The read endpoints use **keyset (cursor) pagination** rather than offsets — stable even as new rows arrive.

| Parameter         | Description                                          |
| ----------------- | ---------------------------------------------------- |
| `limit`           | Page size, default **100**, max **1000**             |
| `cursor`          | Opaque cursor from the previous page's `next_cursor` |
| `since` / `until` | ISO timestamps bounding the time range               |

Every response carries a `pagination` object:

```json theme={null}
{
  "data": [ /* rows */ ],
  "pagination": { "next_cursor": "eyJ0Ijoi…", "has_more": true, "limit": 100 }
}
```

To fetch the next page, pass `next_cursor` back as `cursor`. When `has_more` is `false`, you've reached the end.

## Metric Aggregations

```
GET /v1/analytics
```

Returns pre-computed daily/weekly/monthly rollups.

### Parameters

| Parameter         | Description                     |
| ----------------- | ------------------------------- |
| `metric_type`     | One of the metric types below   |
| `connection_id`   | Restrict to a single connection |
| `since` / `until` | Bound the aggregation period    |
| `limit`, `cursor` | Pagination                      |

**Valid `metric_type` values:**

`daily_executions`, `daily_success_rate`, `daily_avg_duration`, `weekly_executions`, `weekly_success_rate`, `weekly_avg_duration`, `monthly_executions`, `monthly_success_rate`, `monthly_avg_duration`, `daily_availability`, `weekly_availability`, `monthly_availability`, `monthly_openclaw_cost`

```bash theme={null}
curl -H "Authorization: Bearer ops_your_api_key" \
  "https://api.opsmatic.com/v1/analytics?metric_type=daily_success_rate&connection_id=conn_abc123&since=2026-06-01T00:00:00Z"
```

## Executions

```
GET /v1/executions
```

Raw workflow execution records.

| Parameter               | Description                                                      |
| ----------------------- | ---------------------------------------------------------------- |
| `connection_id`         | Filter to one connection                                         |
| `workflow_id`           | Filter to one workflow                                           |
| `status`                | `running`, `success`, `error`, `waiting` or `cancelled`          |
| `since` / `until`       | Time range                                                       |
| `include_error_details` | `true` to include failure reasons                                |
| `group_by`              | `workflow` to return per-workflow aggregates instead of raw rows |
| `limit`, `cursor`       | Pagination                                                       |

```bash theme={null}
# Failed executions for one workflow, with error details
curl -H "Authorization: Bearer ops_your_api_key" \
  "https://api.opsmatic.com/v1/executions?workflow_id=wf_support_triage&status=error&include_error_details=true"
```

```bash theme={null}
# Per-workflow rollup across a connection
curl -H "Authorization: Bearer ops_your_api_key" \
  "https://api.opsmatic.com/v1/executions?connection_id=conn_abc123&group_by=workflow"
```

## Availability

```
GET /v1/availability
```

Raw availability check samples.

| Parameter           | Description                                                           |
| ------------------- | --------------------------------------------------------------------- |
| `connection_id`     | Filter to one connection                                              |
| `is_available`      | `true` / `false` to filter by outcome                                 |
| `include_synthetic` | Defaults to `true`; set `false` to exclude synthetic gap-fill samples |
| `since` / `until`   | Time range                                                            |
| `limit`, `cursor`   | Pagination                                                            |

### Availability Summary

```
GET /v1/availability/summary
```

Rolled-up uptime instead of raw samples.

| Parameter       | Description                              |
| --------------- | ---------------------------------------- |
| `window`        | `day`, `week` or `month` (default `day`) |
| `connection_id` | Restrict to one connection               |

```bash theme={null}
curl -H "Authorization: Bearer ops_your_api_key" \
  "https://api.opsmatic.com/v1/availability/summary?window=week&connection_id=conn_abc123"
```

## Incidents

```
GET /v1/incidents
```

First-class incidents opened by the monitoring pipeline (kinds: `availability`, `missed_heartbeat`, `anomaly`, `budget`; lifecycle `open → acknowledged → resolved`). Supports `connection_id`, `since` / `until` and cursor pagination.

```bash theme={null}
curl -H "Authorization: Bearer ops_your_api_key" \
  "https://api.opsmatic.com/v1/incidents?connection_id=conn_abc123"
```

## Anomalies

```
GET /v1/anomalies
```

Statistically-detected anomalies (response times, execution failure rates and OpenClaw token spend, against 7-day baselines). Supports `connection_id`, `since` / `until` and cursor pagination.

```bash theme={null}
curl -H "Authorization: Bearer ops_your_api_key" \
  "https://api.opsmatic.com/v1/anomalies?since=2026-07-01T00:00:00Z"
```

## Related

<CardGroup cols={2}>
  <Card title="Analytics in the app" icon="chart-line" href="/analytics/overview">
    How this data is visualized in the dashboard
  </Card>

  <Card title="Usage & Cost API" icon="code" href="/api-reference/usage">
    Push and query AI token usage and cost
  </Card>
</CardGroup>
