mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 03:22:29 +08:00

* 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>
382 lines
9.2 KiB
Markdown
382 lines
9.2 KiB
Markdown
---
|
||
aliases:
|
||
- ../../http_api/folder/
|
||
canonical: /docs/grafana/latest/developers/http_api/folder/
|
||
description: Grafana Folder HTTP API
|
||
keywords:
|
||
- grafana
|
||
- http
|
||
- documentation
|
||
- api
|
||
- folder
|
||
labels:
|
||
products:
|
||
- enterprise
|
||
- oss
|
||
title: Folder HTTP API
|
||
---
|
||
|
||
# Folder API
|
||
|
||
> If you are running Grafana Enterprise, for some endpoints you'll need to have specific permissions. Refer to [Role-based access control permissions]({{< relref "/docs/grafana/latest/administration/roles-and-permissions/access-control/custom-role-actions-scopes" >}}) for more information.
|
||
|
||
## Identifier (id) vs unique identifier (uid)
|
||
|
||
The identifier (id) of a folder is an auto-incrementing numeric value and is only unique per Grafana install.
|
||
|
||
The unique identifier (uid) of a folder can be used for uniquely identify folders between multiple Grafana installs. It's automatically generated if not provided when creating a folder. The uid allows having consistent URLs for accessing folders and when syncing folders between multiple Grafana installs. This means that changing the title of a folder will not break any bookmarked links to that folder.
|
||
|
||
The uid can have a maximum length of 40 characters.
|
||
|
||
## A note about the General folder
|
||
|
||
The General folder (id=0) is special and is not part of the Folder API which means
|
||
that you cannot use this API for retrieving information about the General folder.
|
||
|
||
## Get all folders
|
||
|
||
`GET /api/folders`
|
||
|
||
Returns all folders that the authenticated user has permission to view. You can control the maximum number of folders returned through the `limit` query parameter, the default is 1000. You can also pass the `page` query parameter for fetching folders from a page other than the first one.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| -------------- | ----------- |
|
||
| `folders:read` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/folders?limit=10 HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
## Get folder by uid
|
||
|
||
`GET /api/folders/:uid`
|
||
|
||
Will return the folder given the folder uid.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| -------------- | ----------- |
|
||
| `folders:read` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/folders/nErXDvCkzzh HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – Found
|
||
- **401** – Unauthorized
|
||
- **403** – Access Denied
|
||
- **404** – Folder not found
|
||
|
||
## Create folder
|
||
|
||
`POST /api/folders`
|
||
|
||
Creates a new folder.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
`folders:create` allows creating folders in the root level. To create a subfolder, `folders:write` scoped to the parent folder is required in addition to `folders:create`.
|
||
|
||
| Action | Scope |
|
||
| ---------------- | ----------- |
|
||
| `folders:create` | n/a |
|
||
| `folders:write` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
POST /api/folders HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
JSON Body schema:
|
||
|
||
- **uid** – Optional [unique identifier](/http_api/folder/#identifier-id-vs-unique-identifier-uid).
|
||
- **title** – The title of the folder.
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – Created
|
||
- **400** – Errors (invalid json, missing or invalid fields, etc)
|
||
- **401** – Unauthorized
|
||
- **403** – Access Denied
|
||
- **409** - Folder already exists
|
||
|
||
## Update folder
|
||
|
||
`PUT /api/folders/:uid`
|
||
|
||
Updates an existing folder identified by uid.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| --------------- | ----------- |
|
||
| `folders:write` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
PUT /api/folders/nErXDvCkzz HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
JSON Body schema:
|
||
|
||
- **uid** – Provide another [unique identifier](/http_api/folder/#identifier-id-vs-unique-identifier-uid) than stored to change the unique identifier. Starting with 10.0, this is **deprecated**. It will be removed in a future release. Please avoid using it because it can result in folder losing its permissions.
|
||
- **title** – The title of the folder.
|
||
- **version** – Provide the current version to be able to update the folder. Not needed if `overwrite=true`.
|
||
- **overwrite** – Set to true if you want to overwrite existing folder with newer version.
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – Updated
|
||
- **400** – Errors (invalid json, missing or invalid fields, etc)
|
||
- **401** – Unauthorized
|
||
- **403** – Access Denied
|
||
- **404** – Folder not found
|
||
- **412** – Precondition failed
|
||
|
||
The **412** status code is used for explaining that you cannot update the folder and why.
|
||
There can be different reasons for this:
|
||
|
||
- The folder has been changed by someone else, `status=version-mismatch`
|
||
|
||
The response body will have the following properties:
|
||
|
||
```http
|
||
HTTP/1.1 412 Precondition Failed
|
||
Content-Type: application/json; charset=UTF-8
|
||
Content-Length: 97
|
||
|
||
```
|
||
|
||
## Delete folder
|
||
|
||
`DELETE /api/folders/:uid`
|
||
|
||
Deletes an existing folder identified by UID along with all dashboards (and their alerts) stored in the folder. This operation cannot be reverted.
|
||
|
||
If [Grafana Alerting]({{< relref "/docs/grafana/latest/alerting" >}}) is enabled, you can set an optional query parameter `forceDeleteRules=false` so that requests will fail with 400 (Bad Request) error if the folder contains any Grafana alerts. However, if this parameter is set to `true` then it will delete any Grafana alerts under this folder.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| ---------------- | ----------- |
|
||
| `folders:delete` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
DELETE /api/folders/nErXDvCkzz HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – Deleted
|
||
- **401** – Unauthorized
|
||
- **400** – Bad Request
|
||
- **403** – Access Denied
|
||
- **404** – Folder not found
|
||
|
||
## Get folder by id
|
||
|
||
`GET /api/folders/id/:id`
|
||
|
||
Will return the folder identified by id.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| -------------- | ----------- |
|
||
| `folders:read` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/folders/id/1 HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – Found
|
||
- **401** – Unauthorized
|
||
- **403** – Access Denied
|
||
- **404** – Folder not found
|