# Dashboards endpoints

Every path starts at your [API URL](https://docs.qualithm.com/api.md#find-your-api-url). Every response is JSON, and an error has the [error body](https://docs.qualithm.com/api.md#errors).

## Read the dashboard a share link shows

`GET /v1/shared/dashboard`

Its name and widgets. A widget's device is the one it resolves to, and an ID outside the team or the dashboard's scope is left out.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate).

**Response:** `200` with object in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `401`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/shared/dashboard" \
  -H "Authorization: Bearer <your-api-token>"
```

## Read the latest run of each of a shared dashboard's automations

`GET /v1/shared/dashboard/automations`

By `automationId`, ascending.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate).

**Response:** `200` with object in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `401`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/shared/dashboard/automations" \
  -H "Authorization: Bearer <your-api-token>"
```

## Stream a shared dashboard's live events

`GET /v1/shared/dashboard/events`

`device.state` for the dashboard's devices, with only the metrics its widgets read, and `automation.run` for its automations, with only the status and times. A link that stops resolving ends the stream with `sse:error`, and every stream ends within an hour: reconnect on `sse:close`.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate).

**Response:** `204` with no body.

**[Errors](https://docs.qualithm.com/api.md#errors):** `401`, `404`, `406`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/shared/dashboard/events" \
  -H "Authorization: Bearer <your-api-token>"
```

## Read a shared dashboard device's metric over a fixed window

`GET /v1/shared/dashboard/telemetry`

Bucketed averages by bucket start, ascending. Only a device and metric the dashboard's widgets read.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate).

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `deviceId` | query | string | Yes | A device the dashboard names |
| `metric` | query | string | Yes | A metric the dashboard reads from that device: 1 to 64 ASCII letters, digits, `_`, `.` or `-` |
| `window` | query | one of `"1h"`, `"24h"`, `"7d"`, `"30d"` | Yes | How far back to read; the server picks the bucket |

**Response:** `200` with object in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/shared/dashboard/telemetry?deviceId=<device-id>&metric=<metric>&window=<window>" \
  -H "Authorization: Bearer <your-api-token>"
```

## Read the latest values of a shared dashboard's devices

`GET /v1/shared/dashboard/values`

By `deviceId`, ascending. A device that has never reported has no row.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate).

**Response:** `200` with object in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `401`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/shared/dashboard/values" \
  -H "Authorization: Bearer <your-api-token>"
```

## List the team's dashboards

`GET /v1/teams/{teamId}/dashboards`

Newest first, by `createdAt` then `id`.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `dashboard.read` permission, which the owner, manager and viewer roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `limit` | query | integer | No | Items per page, 1 to 100. Default 50. |
| `cursor` | query | string | No | A previous page's `nextCursor`, to read the page after it |

**Response:** `200` with [DashboardPage](#dashboardpage) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/dashboards" \
  -H "Authorization: Bearer <your-api-token>"
```

## Create a dashboard

`POST /v1/teams/{teamId}/dashboards`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `dashboard.write` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `Idempotency-Key` | header | string | No | A unique key for this request. A retry with the same key and body returns the first response instead of acting again; keys last 24 hours. |

**Request body:** [CreateDashboardRequest](#createdashboardrequest)

**Response:** `201` with [Dashboard](#dashboard) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `409`, `413`, `415`, `429`, `500`, `503`

```bash
curl -X POST "<your-api-url>/v1/teams/<team-id>/dashboards" \
  -H "Authorization: Bearer <your-api-token>" \
  -H "Content-Type: application/json" \
  -d '{"name":"<name>"}'
```

## Get a dashboard

`GET /v1/teams/{teamId}/dashboards/{dashboardId}`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `dashboard.read` permission, which the owner, manager and viewer roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `dashboardId` | path | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |

**Response:** `200` with [Dashboard](#dashboard) in `data`.

**Response headers:**

- `ETag`: The resource's version; send it back as If-Match to edit only that version

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/dashboards/<dashboard-id>" \
  -H "Authorization: Bearer <your-api-token>"
```

## Update a dashboard

`PATCH /v1/teams/{teamId}/dashboards/{dashboardId}`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `dashboard.write` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `dashboardId` | path | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |
| `If-Match` | header | string | No | The ETag you last read. The request is refused with 412 when the resource has changed since; omit it to apply the change regardless. |

**Request body:** [UpdateDashboardRequest](#updatedashboardrequest)

**Response:** `200` with [Dashboard](#dashboard) in `data`.

**Response headers:**

- `ETag`: The resource's version; send it back as If-Match to edit only that version

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `409`, `412`, `413`, `415`, `429`, `500`, `503`

```bash
curl -X PATCH "<your-api-url>/v1/teams/<team-id>/dashboards/<dashboard-id>" \
  -H "Authorization: Bearer <your-api-token>" \
  -H "Content-Type: application/json" \
  -d '{"name":"<name>","scopeId":"<scope-id>","payload":[{"id":"<id>","type":"time-series","layout":{"x":1,"y":1,"w":1,"h":1},"source":{"deviceId":"<device-id>","capability":"<capability>","tag":"<tag>","metric":"<metric>","automationId":"<automation-id>"}}]}'
```

## Delete a dashboard

`DELETE /v1/teams/{teamId}/dashboards/{dashboardId}`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `dashboard.write` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `dashboardId` | path | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |
| `If-Match` | header | string | No | The ETag you last read. The request is refused with 412 when the resource has changed since; omit it to apply the change regardless. |

**Response:** `204` with no body.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `412`, `429`, `500`, `503`

```bash
curl -X DELETE "<your-api-url>/v1/teams/<team-id>/dashboards/<dashboard-id>" \
  -H "Authorization: Bearer <your-api-token>"
```

## Get a dashboard's live share link, without its token

`GET /v1/teams/{teamId}/dashboards/{dashboardId}/share`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `dashboard.read` permission, which the owner, manager and viewer roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `dashboardId` | path | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |

**Response:** `200` with [DashboardShare](#dashboardshare) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/dashboards/<dashboard-id>/share" \
  -H "Authorization: Bearer <your-api-token>"
```

## Create a dashboard's share link

`POST /v1/teams/{teamId}/dashboards/{dashboardId}/share`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `dashboard.write` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `dashboardId` | path | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |
| `Idempotency-Key` | header | string | No | A unique key for this request. A retry with the same key and body returns the first response instead of acting again; keys last 24 hours. |

**Response:** `201` with [CreatedDashboardShare](#createddashboardshare) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `409`, `429`, `500`, `503`

```bash
curl -X POST "<your-api-url>/v1/teams/<team-id>/dashboards/<dashboard-id>/share" \
  -H "Authorization: Bearer <your-api-token>"
```

## Revoke a dashboard's share link

`DELETE /v1/teams/{teamId}/dashboards/{dashboardId}/share`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `dashboard.write` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `dashboardId` | path | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |

**Response:** `204` with no body.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl -X DELETE "<your-api-url>/v1/teams/<team-id>/dashboards/<dashboard-id>/share" \
  -H "Authorization: Bearer <your-api-token>"
```

## Types

### DashboardWidget

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `id` | string | Yes | Unique within the dashboard |
| `type` | one of `"time-series"`, `"gauge"`, `"value"`, `"control"`, `"automation"` | Yes |  |
| `title` | string | No |  |
| `layout` | object | Yes | Placement in grid cells: x and y not negative, w and h positive |
| `layout.x` | number | Yes |  |
| `layout.y` | number | Yes |  |
| `layout.w` | number | Yes |  |
| `layout.h` | number | Yes |  |
| `source` | object | Yes | What the widget shows: an `automationId` for an automation widget, else a `deviceId` or a `capability` |
| `source.deviceId` | string | No |  |
| `source.capability` | string | No |  |
| `source.tag` | string | No |  |
| `source.metric` | string | No |  |
| `source.automationId` | string | No |  |
| `options` | object | No |  |

### TelemetryPoint

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `ts` | integer (int64) | Yes | The bucket start, epoch milliseconds |
| `value` | number or null | Yes | The bucket's aggregate. Null for a gap with no prior observation, and for the first bucket of a delta or rate series. |

### DashboardPage

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `items` | array of [Dashboard](#dashboard) | Yes |  |
| `nextCursor` | string or null | Yes | Pass as `cursor` to read the next page; `null` on the last page |

### Dashboard

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `id` | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |
| `teamId` | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `scopeId` | string or null | Yes | The scope it shows; null for team-wide |
| `scopeName` | string or null | Yes |  |
| `name` | string | Yes |  |
| `payload` | array of [DashboardWidget](#dashboardwidget) | Yes |  |
| `createdAt` | string (date-time) | Yes | UTC time, RFC 3339 |
| `updatedAt` | string (date-time) | Yes | UTC time, RFC 3339 |

### CreateDashboardRequest

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `name` | string | Yes |  |
| `scopeId` | string or null | No | The scope it shows; null or absent for team-wide |
| `payload` | array of [DashboardWidget](#dashboardwidget) or null | No | The widgets; null or absent for none. At most 64 KiB once serialised |

### UpdateDashboardRequest

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `name` | string | No |  |
| `scopeId` | string or null | No | The scope it shows; null or absent for team-wide |
| `payload` | array of [DashboardWidget](#dashboardwidget) or null | No | Replaces every widget; null for none. At most 64 KiB once serialised |

### DashboardShare

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `id` | string | Yes | A dashboard share link ID: `shr_<zone>_…` |
| `dashboardId` | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |
| `createdBy` | string or null | Yes | The account that created the link |
| `createdAt` | string (date-time) | Yes | UTC time, RFC 3339 |

### CreatedDashboardShare

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `id` | string | Yes | A dashboard share link ID: `shr_<zone>_…` |
| `dashboardId` | string | Yes | A dashboard ID: `dsh_<zone>_…`; also accepts the legacy `dash_…` |
| `createdAt` | string (date-time) | Yes | UTC time, RFC 3339 |
| `token` | string | Yes | The share token, sent as `Authorization: Share <token>`; shown once, never retrievable again |
