2022-05-26 23:06:25 +08:00
---
aliases:
2022-12-10 00:36:04 +08:00
- ../http_api/
- ../overview/
2023-02-07 01:14:36 +08:00
canonical: /docs/grafana/latest/developers/http_api/
2022-05-26 23:06:25 +08:00
description: Grafana HTTP API
keywords:
- grafana
- http
- documentation
- api
- overview
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
labels:
products:
- enterprise
- oss
2022-05-26 23:06:25 +08:00
title: HTTP API
weight: 100
---
2016-11-28 00:09:47 +08:00
2021-10-29 01:26:23 +08:00
# HTTP API reference
2016-11-28 00:09:47 +08:00
2021-10-29 01:26:23 +08:00
The Grafana backend exposes an HTTP API, which is the same API that is used by the frontend to do everything from saving
dashboards, creating users, and updating data sources.
2016-11-28 00:09:47 +08:00
2023-03-01 22:36:37 +08:00
Since version 8.4, HTTP API details are [specified ](https://editor.swagger.io/?url=https://raw.githubusercontent.com/grafana/grafana/main/public/api-merged.json ) using OpenAPI v2.
Starting from version 9.1, there is also a [OpenAPI v3 specification ](https://editor.swagger.io/?url=https://raw.githubusercontent.com/grafana/grafana/main/public/openapi3.json ) (generated by the v2 one).
2024-01-10 04:07:40 +08:00
Users can browser and try out both via the Swagger UI editor (served by the grafana server) by navigating to `/swagger-ui` .
2023-03-01 22:36:37 +08:00
2023-10-31 21:29:08 +08:00
## Authenticating API requests
You can authenticate requests using basic auth, a service account token or a session cookie (acquired using regular login or OAuth).
### Basic Auth
If basic auth is enabled (it is enabled by default), then you can authenticate your HTTP request via
standard basic auth. Basic auth will also authenticate LDAP users.
curl example:
```bash
curl http://admin:admin@localhost:3000/api/org
{"id":1,"name":"Main Org."}
```
### Service Account Token
2023-11-30 22:19:07 +08:00
To create a service account token, click on **Administration** in the left-side menu, click **Users and access** , then **Service Accounts** .
2023-10-31 21:29:08 +08:00
For more information on how to use service account tokens, refer to the [Service Accounts ]({{< relref "../../administration/service-accounts/" >}} ) documentation.
You use the token in all requests in the `Authorization` header, like this:
**Example**:
```http
GET http://your.grafana.com/api/dashboards/db/mydash HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
The `Authorization` header value should be `Bearer <your service account token>` .
## X-Grafana-Org-Id Header
**X-Grafana-Org-Id** is an optional property that specifies the organization to which the action is applied. If it is not set, the created key belongs to the current context org. Use this header in all requests except those regarding admin.
**Example Request**:
```http
GET /api/org/ HTTP/1.1
Accept: application/json
Content-Type: application/json
X-Grafana-Org-Id: 2
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2021-05-20 18:38:05 +08:00
## HTTP APIs
2020-10-03 02:02:11 +08:00
2022-06-03 00:57:22 +08:00
- [Admin API ]({{< relref "admin/" >}} )
2022-10-13 21:09:49 +08:00
- [Alerting API (unstable) ](https://editor.swagger.io/?url=https://raw.githubusercontent.com/grafana/grafana/main/pkg/services/ngalert/api/tooling/post.json )
2022-06-10 22:25:15 +08:00
- [Alerting Provisioning API ]({{< relref "alerting_provisioning/" >}} )
2022-06-03 00:57:22 +08:00
- [Annotations API ]({{< relref "annotations/" >}} )
2022-07-27 14:01:46 +08:00
- [Correlations API ]({{< relref "correlations/" >}} )
2022-06-03 00:57:22 +08:00
- [Dashboard API ]({{< relref "dashboard/" >}} )
- [Dashboard Permissions API ]({{< relref "dashboard_permissions/" >}} )
- [Dashboard Versions API ]({{< relref "dashboard_versions/" >}} )
- [Data source API ]({{< relref "data_source/" >}} )
- [Folder API ]({{< relref "folder/" >}} )
- [Folder Permissions API ]({{< relref "folder_permissions/" >}} )
- [Folder/Dashboard Search API ]({{< relref "folder_dashboard_search/" >}} )
- [Library Element API ]({{< relref "library_element/" >}} )
- [Organization API ]({{< relref "org/" >}} )
- [Other API ]({{< relref "other/" >}} )
- [Playlists API ]({{< relref "playlist/" >}} )
- [Preferences API ]({{< relref "preferences/" >}} )
- [Short URL API ]({{< relref "short_url/" >}} )
2022-06-13 15:47:40 +08:00
- [Query history API ]({{< relref "query_history/" >}} )
2022-06-03 00:57:22 +08:00
- [Snapshot API ]({{< relref "snapshot/" >}} )
- [Team API ]({{< relref "team/" >}} )
- [User API ]({{< relref "user/" >}} )
2020-01-27 20:41:15 +08:00
2022-06-10 22:25:15 +08:00
## Deprecated HTTP APIs
- [Alerting Notification Channels API ]({{< relref "alerting_notification_channels/" >}} )
- [Alerting API ]({{< relref "alerting/" >}} )
2023-10-31 21:29:08 +08:00
- [Authentication API ]({{< relref "auth/" >}} )
2022-06-10 22:25:15 +08:00
2021-05-20 18:38:05 +08:00
## Grafana Enterprise HTTP APIs
Grafana Enterprise includes all of the Grafana OSS APIs as well as those that follow:
2020-01-27 20:41:15 +08:00
2022-06-03 00:57:22 +08:00
- [Role-based access control API ]({{< relref "access_control/" >}} )
- [Data source permissions API ]({{< relref "datasource_permissions/" >}} )
2023-06-01 23:48:32 +08:00
- [Team sync API ]({{< relref "team_sync/" >}} )
2022-06-03 00:57:22 +08:00
- [License API ]({{< relref "licensing/" >}} )
- [Reporting API ]({{< relref "reporting/" >}} )
2023-04-27 22:28:26 +08:00
- [Query and resource caching API ]({{< relref "query_and_resource_caching/" >}} )