mirror of
https://github.com/grafana/grafana.git
synced 2026-02-03 20:49:50 -05:00
Some checks failed
Actionlint / Lint GitHub Actions files (push) Has been cancelled
Backend Unit Tests / Detect whether code changed (push) Has been cancelled
Lint Frontend / Detect whether code changed (push) Has been cancelled
Lint Frontend / Verify API clients (push) Has been cancelled
Lint Frontend / Verify API clients (enterprise) (push) Has been cancelled
Verify i18n / verify-i18n (push) Has been cancelled
Documentation / Build & Verify Docs (push) Has been cancelled
End-to-end tests / Detect whether code changed (push) Has been cancelled
Frontend tests / Detect whether code changed (push) Has been cancelled
Integration Tests / Detect whether code changed (push) Has been cancelled
publish-technical-documentation-next / sync (push) Has been cancelled
Reject GitHub secrets / reject-gh-secrets (push) Has been cancelled
Build Release Packages / setup (push) Has been cancelled
Run dashboard schema v2 e2e / dashboard-schema-v2-e2e (push) Has been cancelled
Shellcheck / Shellcheck scripts (push) Has been cancelled
Run Storybook a11y tests / Detect whether code changed (push) Has been cancelled
Swagger generated code / Detect whether code changed (push) Has been cancelled
Dispatch sync to mirror / dispatch-job (push) Has been cancelled
Backend Unit Tests / Grafana (1/8) (push) Has been cancelled
Backend Unit Tests / Grafana (2/8) (push) Has been cancelled
Backend Unit Tests / Grafana (3/8) (push) Has been cancelled
Backend Unit Tests / Grafana (4/8) (push) Has been cancelled
Backend Unit Tests / Grafana (5/8) (push) Has been cancelled
Backend Unit Tests / Grafana (6/8) (push) Has been cancelled
Backend Unit Tests / Grafana (7/8) (push) Has been cancelled
Backend Unit Tests / Grafana (8/8) (push) Has been cancelled
Backend Unit Tests / Grafana Enterprise (1/8) (push) Has been cancelled
Backend Unit Tests / Grafana Enterprise (2/8) (push) Has been cancelled
Backend Unit Tests / Grafana Enterprise (3/8) (push) Has been cancelled
Backend Unit Tests / Grafana Enterprise (4/8) (push) Has been cancelled
Backend Unit Tests / Grafana Enterprise (5/8) (push) Has been cancelled
Backend Unit Tests / Grafana Enterprise (6/8) (push) Has been cancelled
Backend Unit Tests / Grafana Enterprise (7/8) (push) Has been cancelled
Backend Unit Tests / Grafana Enterprise (8/8) (push) Has been cancelled
Backend Unit Tests / All backend unit tests complete (push) Has been cancelled
Lint Frontend / Lint (push) Has been cancelled
Lint Frontend / Typecheck (push) Has been cancelled
End-to-end tests / Build & Package Grafana (push) Has been cancelled
End-to-end tests / Build E2E test runner (push) Has been cancelled
End-to-end tests / push-docker-image (push) Has been cancelled
End-to-end tests / dashboards-suite (old arch) (push) Has been cancelled
End-to-end tests / panels-suite (old arch) (push) Has been cancelled
End-to-end tests / smoke-tests-suite (old arch) (push) Has been cancelled
End-to-end tests / various-suite (old arch) (push) Has been cancelled
End-to-end tests / Verify Storybook (Playwright) (push) Has been cancelled
End-to-end tests / Playwright E2E tests (1/8) (push) Has been cancelled
End-to-end tests / Playwright E2E tests (2/8) (push) Has been cancelled
End-to-end tests / Playwright E2E tests (3/8) (push) Has been cancelled
End-to-end tests / Playwright E2E tests (4/8) (push) Has been cancelled
End-to-end tests / Playwright E2E tests (5/8) (push) Has been cancelled
End-to-end tests / Playwright E2E tests (6/8) (push) Has been cancelled
End-to-end tests / Playwright E2E tests (7/8) (push) Has been cancelled
End-to-end tests / Playwright E2E tests (8/8) (push) Has been cancelled
End-to-end tests / run-azure-monitor-e2e (push) Has been cancelled
End-to-end tests / All Playwright tests complete (push) Has been cancelled
End-to-end tests / A11y test (push) Has been cancelled
End-to-end tests / Publish metrics (push) Has been cancelled
End-to-end tests / All E2E tests complete (push) Has been cancelled
Frontend tests / Unit tests (1 / 16) (push) Has been cancelled
Frontend tests / Unit tests (10 / 16) (push) Has been cancelled
Frontend tests / Unit tests (11 / 16) (push) Has been cancelled
Frontend tests / Unit tests (12 / 16) (push) Has been cancelled
Frontend tests / Unit tests (13 / 16) (push) Has been cancelled
Frontend tests / Unit tests (14 / 16) (push) Has been cancelled
Frontend tests / Unit tests (15 / 16) (push) Has been cancelled
Frontend tests / Unit tests (16 / 16) (push) Has been cancelled
Frontend tests / Unit tests (2 / 16) (push) Has been cancelled
Frontend tests / Unit tests (3 / 16) (push) Has been cancelled
Frontend tests / Unit tests (4 / 16) (push) Has been cancelled
Frontend tests / Unit tests (5 / 16) (push) Has been cancelled
Frontend tests / Unit tests (6 / 16) (push) Has been cancelled
Frontend tests / Unit tests (7 / 16) (push) Has been cancelled
Frontend tests / Unit tests (8 / 16) (push) Has been cancelled
Frontend tests / Unit tests (9 / 16) (push) Has been cancelled
Frontend tests / Decoupled plugin tests (push) Has been cancelled
Frontend tests / Packages unit tests (push) Has been cancelled
Frontend tests / All frontend unit tests complete (push) Has been cancelled
Frontend tests / Devenv frontend-service build (push) Has been cancelled
Integration Tests / Sqlite (1/4) (push) Has been cancelled
Integration Tests / Sqlite (2/4) (push) Has been cancelled
Integration Tests / Sqlite (3/4) (push) Has been cancelled
Integration Tests / Sqlite (4/4) (push) Has been cancelled
Integration Tests / Sqlite Without CGo (1/4) (push) Has been cancelled
Integration Tests / Sqlite Without CGo (2/4) (push) Has been cancelled
Integration Tests / Sqlite Without CGo (3/4) (push) Has been cancelled
Integration Tests / Sqlite Without CGo (4/4) (push) Has been cancelled
Integration Tests / Sqlite Without CGo (profiled) (push) Has been cancelled
Integration Tests / MySQL (1/16) (push) Has been cancelled
Integration Tests / MySQL (10/16) (push) Has been cancelled
Integration Tests / MySQL (11/16) (push) Has been cancelled
Integration Tests / MySQL (12/16) (push) Has been cancelled
Integration Tests / MySQL (13/16) (push) Has been cancelled
Integration Tests / MySQL (14/16) (push) Has been cancelled
Integration Tests / MySQL (15/16) (push) Has been cancelled
Integration Tests / MySQL (16/16) (push) Has been cancelled
Integration Tests / MySQL (2/16) (push) Has been cancelled
Integration Tests / MySQL (3/16) (push) Has been cancelled
Integration Tests / MySQL (4/16) (push) Has been cancelled
Integration Tests / MySQL (5/16) (push) Has been cancelled
Integration Tests / MySQL (6/16) (push) Has been cancelled
Integration Tests / MySQL (7/16) (push) Has been cancelled
Integration Tests / MySQL (8/16) (push) Has been cancelled
Integration Tests / MySQL (9/16) (push) Has been cancelled
Integration Tests / Postgres (1/16) (push) Has been cancelled
Integration Tests / Postgres (10/16) (push) Has been cancelled
Integration Tests / Postgres (11/16) (push) Has been cancelled
Integration Tests / Postgres (12/16) (push) Has been cancelled
Integration Tests / Postgres (13/16) (push) Has been cancelled
Integration Tests / Postgres (14/16) (push) Has been cancelled
Integration Tests / Postgres (15/16) (push) Has been cancelled
Integration Tests / Postgres (16/16) (push) Has been cancelled
Integration Tests / Postgres (2/16) (push) Has been cancelled
Integration Tests / Postgres (3/16) (push) Has been cancelled
Integration Tests / Postgres (4/16) (push) Has been cancelled
Integration Tests / Postgres (5/16) (push) Has been cancelled
Integration Tests / Postgres (6/16) (push) Has been cancelled
Integration Tests / Postgres (7/16) (push) Has been cancelled
Integration Tests / Postgres (8/16) (push) Has been cancelled
Integration Tests / Postgres (9/16) (push) Has been cancelled
Integration Tests / All backend integration tests complete (push) Has been cancelled
Build Release Packages / Dispatch grafana-enterprise build (push) Has been cancelled
Build Release Packages / / darwin-amd64 (push) Has been cancelled
Build Release Packages / / darwin-arm64 (push) Has been cancelled
Build Release Packages / / linux-amd64 (push) Has been cancelled
Build Release Packages / / linux-armv6 (push) Has been cancelled
Build Release Packages / / linux-armv7 (push) Has been cancelled
Build Release Packages / / linux-arm64 (push) Has been cancelled
Build Release Packages / / linux-s390x (push) Has been cancelled
Build Release Packages / / windows-amd64 (push) Has been cancelled
Build Release Packages / / windows-arm64 (push) Has been cancelled
Build Release Packages / Upload artifacts (push) Has been cancelled
Build Release Packages / publish-dockerhub (push) Has been cancelled
Build Release Packages / Dispatch publish NPM canaries (push) Has been cancelled
Build Release Packages / notify-pr (push) Has been cancelled
Run Storybook a11y tests / Run Storybook a11y tests (light theme) (push) Has been cancelled
Run Storybook a11y tests / Run Storybook a11y tests (dark theme) (push) Has been cancelled
Swagger generated code / Verify committed API specs match (push) Has been cancelled
872 lines
24 KiB
Markdown
872 lines
24 KiB
Markdown
---
|
||
aliases:
|
||
- ../../../http_api/folder/ # /docs/grafana/next/http_api/folder/
|
||
- ../../../developers/http_api/folder/ # /docs/grafana/next/developers/http_api/folder/
|
||
canonical: https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/folder/
|
||
description: Grafana Folder HTTP API
|
||
keywords:
|
||
- grafana
|
||
- http
|
||
- documentation
|
||
- api
|
||
- folder
|
||
labels:
|
||
products:
|
||
- enterprise
|
||
- oss
|
||
- cloud
|
||
title: Folder HTTP API
|
||
refs:
|
||
apis:
|
||
- pattern: /docs/grafana/
|
||
destination: /docs/grafana/<GRAFANA_VERSION>/developer-resources/api-reference/http-api/apis/
|
||
- pattern: /docs/grafana-cloud/
|
||
destination: ./apis/
|
||
alerting:
|
||
- pattern: /docs/grafana/
|
||
destination: /docs/grafana/<GRAFANA_VERSION>/alerting
|
||
- pattern: /docs/grafana-cloud/
|
||
destination: /docs/grafana-cloud/alerting-and-irm/alerting/
|
||
---
|
||
|
||
# New Folders APIs
|
||
|
||
> If you are running Grafana Enterprise, for some endpoints you'll need to have specific permissions. Refer to [Role-based access control permissions](/docs/grafana/latest/administration/roles-and-permissions/access-control/custom-role-actions-scopes/) for more information.
|
||
|
||
> To view more about the new api structure, refer to [API overview](ref:apis).
|
||
|
||
### Get all folders
|
||
|
||
`GET /apis/folder.grafana.app/v1beta1/namespaces/:namespace/folders`
|
||
|
||
Returns all folders that the authenticated user has permission to view within the given organization. Use the `limit` query parameter to control the maximum number of dashboards returned. To retrieve additional dashboards, utilize the `continue` token provided in the response to fetch the next page.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](ref:apis).
|
||
|
||
**Query parameters**:
|
||
|
||
- **`limit`** (optional): Maximum number of folders to return
|
||
- **`continue`** (optional): Continue token from a previous response to fetch the next page
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| -------------- | ----------- |
|
||
| `folders:read` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /apis/folder.grafana.app/v1beta1/namespaces/default/folders?limit=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
|
||
{
|
||
```
|
||
|
||
The `metadata.continue` field contains a token to fetch the next page.
|
||
|
||
**Example subsequent request using continue token**:
|
||
|
||
```http
|
||
GET /apis/folder.grafana.app/v1beta1/namespaces/default/folders?limit=1&continue=eyJvIjoxNTIsInYiOjE3NjE3MDQyMjQyMDcxODksInMiOmZhbHNlfQ== HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example subsequent response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
{
|
||
```
|
||
|
||
Continue making requests with the updated `continue` token until you receive a response without a `continue` field in the metadata, indicating you've reached the last page.
|
||
|
||
Status Codes:
|
||
|
||
- **200** – OK
|
||
- **401** – Unauthorized
|
||
- **403** – Access Denied
|
||
|
||
### Get folder by uid
|
||
|
||
`GET /apis/folder.grafana.app/v1beta1/namespaces/:namespace/folders/:uid`
|
||
|
||
Will return the folder given the folder uid.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](ref:apis).
|
||
- uid: the unique identifier of the folder to update. this will be the _name_ in the folder response
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| -------------- | ----------- |
|
||
| `folders:read` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /apis/folder.grafana.app/v1beta1/namespaces/default/folders/aef30vrzxs3y8d HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
{
|
||
```
|
||
|
||
Note the annotation `grafana.app/folder` which contains the uid of the parent folder.
|
||
|
||
Status Codes:
|
||
|
||
- **200** – Found
|
||
- **401** – Unauthorized
|
||
- **403** – Access Denied
|
||
- **404** – Folder not found
|
||
|
||
### Create folder
|
||
|
||
`POST /apis/folder.grafana.app/v1beta1/namespaces/:namespace/folders`
|
||
|
||
Creates a new folder.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](ref:apis).
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
`folders:create` allows creating folders and subfolders. If granted with scope `folders:uid:general`, allows creating root level folders. Otherwise, allows creating subfolders under the specified folders.
|
||
|
||
| Action | Scope |
|
||
| ---------------- | ----------- |
|
||
| `folders:create` | `folders:*` |
|
||
| `folders:write` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
POST /apis/folder.grafana.app/v1beta1/namespaces/default/folders HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
JSON Body schema:
|
||
|
||
- **metadata.name** – The Grafana [unique identifier]({{< ref "#identifier-id-vs-unique-identifier-uid" >}}). If you do not want to provide this, set metadata.generateName to the prefix you would like for the uid.
|
||
- **metadata.annotations.grafana.app/folder** - Optional field, the unique identifier of the parent folder under which the folder should be created. Requires nested folders to be enabled.
|
||
- **spec.title** – The title of the folder.
|
||
|
||
{{< admonition type="note" >}}
|
||
Custom labels and annotations in the metadata field are supported on some instances, with full support planned for all instances when these APIs reach general availability. If they are not yet supported on your instance, they will be ignored.
|
||
{{< /admonition >}}
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
{
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **201** – Created
|
||
- **400** – Errors (invalid json, missing or invalid fields, etc)
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
- **409** – Conflict (folder with the same uid already exists)
|
||
|
||
### Update folder
|
||
|
||
`PUT /apis/folder.grafana.app/v1beta1/namespaces/:namespace/folders/:uid`
|
||
|
||
Updates an existing folder identified by uid.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](ref:apis).
|
||
- uid: the unique identifier of the folder to update. this will be the _name_ in the folder response
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| --------------- | ----------- |
|
||
| `folders:write` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
PUT /apis/folder.grafana.app/v1beta1/namespaces/default/folders/fef30w4jaxla8b HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
JSON Body schema:
|
||
|
||
- **metadata.name** – The [unique identifier]({{< ref "#identifier-id-vs-unique-identifier-uid" >}}) of the folder.
|
||
- **metadata.annotations.grafana.app/folder** - Optional field, the unique identifier of the parent folder under which the folder should be - update this to move the folder under a different parent folder. Requires nested folders to be enabled.
|
||
- **spec.title** – The title of the folder.
|
||
|
||
{{< admonition type="note" >}}
|
||
Custom labels and annotations in the metadata field are supported on some instances, with full support planned for all instances when these APIs reach general availability. If they are not yet supported on your instance, they will be ignored.
|
||
{{< /admonition >}}
|
||
|
||
**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 folder has been changed by someone else). With this status code, 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 /apis/folder.grafana.app/v1beta1/namespaces/:namespace/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](ref: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.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](ref:apis).
|
||
- uid: the unique identifier of the folder to delete. this will be the _name_ in the folder response
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#folder-api" >}}) for an explanation.
|
||
|
||
| Action | Scope |
|
||
| ---------------- | ----------- |
|
||
| `folders:delete` | `folders:*` |
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
DELETE /apis/folder.grafana.app/v1beta1/namespaces/default/folders/fef30w4jaxla8b 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
|
||
|
||
## APIs
|
||
|
||
## Identifier (id) vs unique identifier (uid)
|
||
|
||
The unique identifier (uid) of a folder can be used for uniquely identify folders within an org. 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.
|
||
|
||
The identifier (id) of a folder is deprecated in favor of the unique identifier (uid).
|
||
|
||
### 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.
|
||
|
||
If nested folders are enabled, the operation expects an additional optional query parameter `parentUid` with the parent folder UID, and returns the immediate subfolders that the authenticated user has permission to view.
|
||
If the parameter is not supplied, then the operation returns immediate subfolders under the root
|
||
that the authenticated user has permission to view.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction](#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](#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
|
||
|
||
```
|
||
|
||
If nested folders are enabled, and the folder is nested (lives under another folder), then the response additionally contains:
|
||
|
||
- **parentUid** - The parent folder UID.
|
||
- **parents** - An array with the whole tree hierarchy, starting from the root going down up to the parent folder.
|
||
|
||
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](#folder-api) for an explanation.
|
||
|
||
`folders:create` allows creating folders and subfolders. If granted with scope `folders:uid:general`, allows creating root level folders. Otherwise, allows creating subfolders under the specified folders.
|
||
|
||
| Action | Scope |
|
||
| ---------------- | ----------- |
|
||
| `folders:create` | `folders:*` |
|
||
| `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](#identifier-id-vs-unique-identifier-uid).
|
||
- **title** – The title of the folder.
|
||
- **parentUid** - Optional field, the unique identifier of the parent folder under which the folder should be created. Requires nested folders to be enabled.
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
If nested folders are enabled, and the folder is nested (lives under another folder) then the response additionally contains:
|
||
|
||
- **parentUid** - the parent folder UID.
|
||
- **parents** - an array with the whole tree hierarchy starting from the root going down up to the parent folder.
|
||
|
||
Status Codes:
|
||
|
||
- **200** – Created
|
||
- **400** – Errors (invalid json, missing or invalid fields, etc)
|
||
- **401** – Unauthorized
|
||
- **403** – Access Denied
|
||
- **412** - Folder already exists
|
||
|
||
### Update folder
|
||
|
||
`PUT /api/folders/:uid`
|
||
|
||
Updates an existing folder identified by uid.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction](#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:
|
||
|
||
- **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
|
||
|
||
```
|
||
|
||
If nested folders are enabled, and the folder is nested (lives under another folder) then the response additionally contains:
|
||
|
||
- **parentUid** - the parent folder UID.
|
||
- **parents** - an array with the whole tree hierarchy starting from the root going down up to the parent folder.
|
||
|
||
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](/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](#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
|
||
|
||
### Move folder
|
||
|
||
`POST /api/folders/:uid/move`
|
||
|
||
Moves the folder.
|
||
|
||
This is relevant only if nested folders are enabled.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction](#folder-api) for an explanation.
|
||
|
||
If moving the folder under another folder:
|
||
|
||
| Action | Scope |
|
||
| ---------------- | ----------------------------------------------------- |
|
||
| `folders:create` | `folders:uid:<destination folder UID>`<br>`folders:*` |
|
||
|
||
If moving the folder under root:
|
||
| Action | Scope |
|
||
| -------------- | ------------- |
|
||
| `folders:create` | `folders:uid:general`<br>`folders:*` |
|
||
|
||
JSON body schema:
|
||
|
||
- **parentUid** – Optional [unique identifier](#identifier-id-vs-unique-identifier-uid) of the new parent folder. If this is empty, then the folder is moved under the root.
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
POST /api/folders/a5393ec3-5568-4e88-8809-b866968ae8a6/move 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** – Moved
|
||
- **400** – Errors (invalid JSON, missing or invalid fields, and so on)
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
- **404** – Not found
|