---
title: "Grafana"
description: "The grafana endpoints of the HTTP API."
---

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

# Grafana

## GET /grafana

List the stored Grafana connections.

Only Admins can call this endpoint. Connections are sorted by creation time; a response never carries the token.

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The connections. | [`GrafanaConnectionList`](/docs/reference/api/schemas/#grafanaconnectionlist) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The caller is not allowed to perform the request; a role that is too low is code `forbidden_role`. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## POST /grafana

Store a Grafana URL and service-account token.

Only Admins can call this endpoint. The URL may be http or https on any port, and its host may resolve to a private or loopback address, because Grafana usually runs inside the network. The host must be a domain name, and it is added to the outbound allowlist when it is not allowed yet. The token is encrypted with a key derived from `SLASHOBSERVE_SECRET_KEY` and is never returned.

### Request body

`application/json`, required.

A [`CreateGrafanaConnectionRequest`](/docs/reference/api/schemas/#creategrafanaconnectionrequest) object.

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `201` | The connection is stored. | [`GrafanaConnection`](/docs/reference/api/schemas/#grafanaconnection) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The role is too low (`forbidden_role`), or `SLASHOBSERVE_OUTBOUND_DOMAINS` is set and does not allow the host (`outbound_domain_not_allowed`). | [`Error`](/docs/reference/api/schemas/#error) |
| `409` | `SLASHOBSERVE_SECRET_KEY` is not set (`secret_key_missing`). | [`Error`](/docs/reference/api/schemas/#error) |
| `413` | The request body exceeds the size limit. | [`Error`](/docs/reference/api/schemas/#error) |
| `422` | The host is not allowed and 100 outbound domains are already allowed (`too_many_domains`). | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## GET /grafana/{id}

Read one Grafana connection.

Only Admins can call this endpoint.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The connection. | [`GrafanaConnection`](/docs/reference/api/schemas/#grafanaconnection) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The caller is not allowed to perform the request; a role that is too low is code `forbidden_role`. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## PATCH /grafana/{id}

Change a connection's name, URL or token.

Only Admins can call this endpoint. A new URL needs the token again, so a stored token never reaches another host. Changing the URL or the token clears the last test.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |

### Request body

`application/json`, required.

A [`UpdateGrafanaConnectionRequest`](/docs/reference/api/schemas/#updategrafanaconnectionrequest) object.

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The changed connection. | [`GrafanaConnection`](/docs/reference/api/schemas/#grafanaconnection) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The role is too low (`forbidden_role`), or `SLASHOBSERVE_OUTBOUND_DOMAINS` is set and does not allow the new host (`outbound_domain_not_allowed`). | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `409` | `SLASHOBSERVE_SECRET_KEY` is not set and a new token was sent (`secret_key_missing`). | [`Error`](/docs/reference/api/schemas/#error) |
| `413` | The request body exceeds the size limit. | [`Error`](/docs/reference/api/schemas/#error) |
| `422` | The new host is not allowed and 100 outbound domains are already allowed (`too_many_domains`). | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## DELETE /grafana/{id}

Delete a connection and its stored token.

Only Admins can call this endpoint. Imported dashboards stay. The host's outbound allowlist entry, when the connection added it, is removed unless a webhook, a datasource or another connection still uses the host.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `204` | The connection is deleted. |   |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The caller is not allowed to perform the request; a role that is too low is code `forbidden_role`. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## POST /grafana/{id}/test

Check that Grafana answers with the stored token.

Only Admins can call this endpoint. The server reads `/api/health`, `/api/folders` and the first page of `/api/search`, and stores the outcome in `last_test`. A Grafana that cannot be reached or refuses the token still answers 200, with `last_test.ok` false and a fixed message. Every test is recorded as `grafana_connection.test` with the host and the outcome.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The connection with its new `last_test`. | [`GrafanaConnection`](/docs/reference/api/schemas/#grafanaconnection) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The caller is not allowed to perform the request; a role that is too low is code `forbidden_role`. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `409` | `SLASHOBSERVE_SECRET_KEY` is not set (`secret_key_missing`), or the stored token cannot be read with it (`token_unreadable`). | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## GET /grafana/{id}/folders

List the Grafana folders and how many dashboards each holds.

Only Admins can call this endpoint. Nested folders are titled `Parent / Child`, and dashboards outside any folder are counted under the uid `general`. Counts cover the folder itself, not its subfolders.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The folders, sorted by title. | array of [`GrafanaFolder`](/docs/reference/api/schemas/#grafanafolder) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The role is too low (`forbidden_role`), or the host is no longer on the outbound allowlist (`outbound_domain_not_allowed`). | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `409` | `SLASHOBSERVE_SECRET_KEY` is not set (`secret_key_missing`), or the stored token cannot be read with it (`token_unreadable`). | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |
| `502` | Grafana could not be reached, refused the token or gave an answer the server cannot read (`grafana_unavailable`); the message is fixed by the kind of failure. | [`Error`](/docs/reference/api/schemas/#error) |

## GET /grafana/{id}/datasources

List the Grafana datasources and the datasource each one matches here.

Only Admins can call this endpoint. `matched_uid` applies the importer's automatic match rules; null means the datasource needs a mapping or has no supported type.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The datasources, sorted by name. | array of [`GrafanaDatasource`](/docs/reference/api/schemas/#grafanadatasource) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The role is too low (`forbidden_role`), or the host is no longer on the outbound allowlist (`outbound_domain_not_allowed`). | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `409` | `SLASHOBSERVE_SECRET_KEY` is not set (`secret_key_missing`), or the stored token cannot be read with it (`token_unreadable`). | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |
| `502` | Grafana could not be reached, refused the token or gave an answer the server cannot read (`grafana_unavailable`); the message is fixed by the kind of failure. | [`Error`](/docs/reference/api/schemas/#error) |

## POST /grafana/{id}/imports

Import every dashboard of the chosen folders.

Only Admins can call this endpoint. The import runs in the background; read its progress from the `Location` header. Each dashboard becomes one import record holding its Grafana uid, in a folder named after its Grafana folder (`Parent / Child` for nested ones), or General for dashboards outside any folder. A dashboard imported before is saved as a new version only when its Grafana `version` is newer, otherwise it is skipped. One dashboard failing never stops the run. A connection runs one import at a time. A server that stops hands the running import to another server, or picks it up again after its restart, skipping the dashboards it already handled. An import whose server crashes twice ends `failed`.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |

### Request body

`application/json`, required.

A [`StartGrafanaImportRequest`](/docs/reference/api/schemas/#startgrafanaimportrequest) object.

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `202` | The import started. | [`GrafanaImport`](/docs/reference/api/schemas/#grafanaimport) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The caller is not allowed to perform the request; a role that is too low is code `forbidden_role`. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `409` | An import from this connection is already running (`import_running`), `SLASHOBSERVE_SECRET_KEY` is not set (`secret_key_missing`), or the stored token cannot be read with it (`token_unreadable`). | [`Error`](/docs/reference/api/schemas/#error) |
| `413` | The request body exceeds the size limit. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## GET /grafana/{id}/imports/{sync_id}

Read the progress of an import.

Only Admins can call this endpoint. Any server answers it, during the import and after it. Each connection keeps its last 20 imports; the connection's `last_sync` is the newest finished one.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |
| `sync_id` (required) | path | `string` |   |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The import and every dashboard handled so far. | [`GrafanaImport`](/docs/reference/api/schemas/#grafanaimport) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The caller is not allowed to perform the request; a role that is too low is code `forbidden_role`. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## POST /grafana/{id}/imports/{sync_id}/cancel

Stop a running import.

Only Admins can call this endpoint. The import ends `canceled` at once; the dashboards it already imported stay, and one being saved at that moment may still be saved. Starting the import again skips what it already imported.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (required) | path | `string` (uuid) |   |
| `sync_id` (required) | path | `string` |   |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The canceled import and every dashboard handled before it stopped. | [`GrafanaImport`](/docs/reference/api/schemas/#grafanaimport) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The caller is not allowed to perform the request; a role that is too low is code `forbidden_role`. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `409` | The import is not running (`invalid_transition`). | [`InvalidTransition`](/docs/reference/api/schemas/#invalidtransition) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## GET /grafana/resolve/{uid}

Find the dashboard imported from a Grafana uid.

Any signed-in caller can resolve a uid, so links to the old Grafana dashboard keep working. A uid whose dashboard sits in a folder the caller cannot see answers 404, like a uid nobody imported.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `uid` (required) | path | `string` |   |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The imported dashboard. | [`GrafanaResolved`](/docs/reference/api/schemas/#grafanaresolved) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The caller is not allowed to perform the request; a role that is too low is code `forbidden_role`. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |

## POST /grafana/link

Fetch a Grafana dashboard from its link through a stored connection.

Only Admins can call this endpoint, because the stored connection's token is an Admin's credential. The link must be a dashboard link (`/d/<uid>` or `/d-solo/<uid>`) on the address of a stored connection, under that address's path; the server only fetches from hosts an Admin already stored. `json` is the dashboard as Grafana returns it, in a string that `POST /imports` takes as its `json`. Redirects are not followed. Every fetch is recorded as `grafana_connection.fetch_dashboard`, naming the connection and its host and never the link.

### Request body

`application/json`, required.

A [`FetchGrafanaLinkRequest`](/docs/reference/api/schemas/#fetchgrafanalinkrequest) object.

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The dashboard. | [`GrafanaLinkedDashboard`](/docs/reference/api/schemas/#grafanalinkeddashboard) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `403` | The role is too low (`forbidden_role`), or `SLASHOBSERVE_OUTBOUND_DOMAINS` is set and does not allow the host (`outbound_domain_not_allowed`). | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | No stored connection matches the link (`no_connection`), or Grafana has no dashboard with that uid that the connection's token can read (`dashboard_not_found`). | [`Error`](/docs/reference/api/schemas/#error) |
| `409` | `SLASHOBSERVE_SECRET_KEY` is not set (`secret_key_missing`), or cannot read the stored token (`token_unreadable`). | [`Error`](/docs/reference/api/schemas/#error) |
| `413` | The request body exceeds the size limit. | [`Error`](/docs/reference/api/schemas/#error) |
| `422` | The link is not a Grafana dashboard link (`not_a_dashboard_link`). | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |
| `502` | Grafana could not be reached, refused the token or gave an answer the server cannot read (`grafana_unavailable`); the message is fixed by the kind of failure. | [`Error`](/docs/reference/api/schemas/#error) |

Generated from [`api/openapi.yaml`](https://github.com/slashobserve/slashobserve/blob/c770e5e0/api/openapi.yaml) at `c770e5e0`. [Report a problem](https://github.com/slashobserve/slashobserve/issues/new).
