2018-02-21 13:09:01 +01:00
+++
title = "Folder HTTP API "
description = "Grafana Folder HTTP API"
keywords = ["grafana", "http", "documentation", "api", "folder"]
2021-04-15 14:08:58 -07:00
aliases = ["/docs/grafana/latest/http_api/folder/"]
2018-02-21 13:09:01 +01:00
+++
# Folder API
## 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.
2020-02-14 21:41:08 +05:30
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.
2018-02-21 13:09:01 +01:00
The uid can have a maximum length of 40 characters.
2018-06-29 20:24:02 +02:00
## 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.
2018-02-21 13:09:01 +01:00
## Get all folders
`GET /api/folders`
2021-07-22 09:53:14 +03:00
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.
2018-02-21 13:09:01 +01:00
**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
[
{
"id" : 1 ,
"uid" : "nErXDvCkzz" ,
2021-03-29 13:21:20 +02:00
"title" : "Department ABC"
},
{
"id" : 2 ,
"uid" : "k3S1cklGk" ,
"title" : "Department RND"
2018-02-21 13:09:01 +01:00
}
]
```
## Get folder by uid
`GET /api/folders/:uid`
Will return the folder given the folder uid.
**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
{
"id" : 1 ,
"uid" : "nErXDvCkzz" ,
2019-10-08 05:21:47 -03:00
"title" : "Department ABC" ,
2018-02-21 13:09:01 +01:00
"url" : "/dashboards/f/nErXDvCkzz/department-abc" ,
"hasAcl" : false ,
"canSave" : true ,
"canEdit" : true ,
"canAdmin" : true ,
"createdBy" : "admin" ,
"created" : "2018-01-31T17:43:12+01:00" ,
"updatedBy" : "admin" ,
"updated" : "2018-01-31T17:43:12+01:00" ,
"version" : 1
}
```
Status Codes:
- **200** – Found
- **401** – Unauthorized
- **403** – Access Denied
- **404** – Folder not found
## Create folder
`POST /api/folders`
Creates a new folder.
**Example Request** :
```http
POST /api/folders HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"uid" : "nErXDvCkzz" ,
"title" : "Department ABC"
}
```
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
{
"id" : 1 ,
"uid" : "nErXDvCkzz" ,
2019-10-08 05:21:47 -03:00
"title" : "Department ABC" ,
2018-02-21 13:09:01 +01:00
"url" : "/dashboards/f/nErXDvCkzz/department-abc" ,
"hasAcl" : false ,
"canSave" : true ,
"canEdit" : true ,
"canAdmin" : true ,
"createdBy" : "admin" ,
"created" : "2018-01-31T17:43:12+01:00" ,
"updatedBy" : "admin" ,
"updated" : "2018-01-31T17:43:12+01:00" ,
"version" : 1
}
```
Status Codes:
- **200** – Created
- **400** – Errors (invalid json, missing or invalid fields, etc)
- **401** – Unauthorized
- **403** – Access Denied
2021-07-06 12:11:29 +03:00
- **409** - Folder already exists
2018-02-21 13:09:01 +01:00
## Update folder
`PUT /api/folders/:uid`
Updates an existing folder identified by uid.
**Example Request** :
```http
PUT /api/folders/nErXDvCkzz HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"title" : "Department DEF" ,
"version" : 1
}
```
JSON Body schema:
2018-02-22 16:07:55 +01:00
- **uid** – Provide another [unique identifier ](/http_api/folder/#identifier-id-vs-unique-identifier-uid ) than stored to change the unique identifier.
2018-02-21 13:09:01 +01:00
- **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
{
"id" : 1 ,
"uid" : "nErXDvCkzz" ,
2019-10-08 05:21:47 -03:00
"title" : "Department DEF" ,
2018-02-21 13:09:01 +01:00
"url" : "/dashboards/f/nErXDvCkzz/department-def" ,
"hasAcl" : false ,
"canSave" : true ,
"canEdit" : true ,
"canAdmin" : true ,
"createdBy" : "admin" ,
"created" : "2018-01-31T17:43:12+01:00" ,
"updatedBy" : "admin" ,
"updated" : "2018-01-31T17:43:12+01:00" ,
"version" : 1
}
```
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
2018-08-11 23:42:31 -07:00
The **412** status code is used for explaining that you cannot update the folder and why.
2018-02-21 13:09:01 +01:00
There can be different reasons for this:
- The folder has been changed by someone else, `status=version-mismatch`
2021-08-06 07:52:36 -06:00
The response body will have the following properties:
2018-02-21 13:09:01 +01:00
```http
HTTP / 1.1 412 Precondition Failed
Content-Type : application/json; charset=UTF-8
Content-Length : 97
{
"message" : "The folder has been changed by someone else" ,
"status" : "version-mismatch"
}
```
## Delete folder
`DELETE /api/folders/:uid`
2021-07-22 12:27:13 +03:00
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 8 Alerts ]({{< relref "../alerting/unified-alerting/_index.md" >}} ) are 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 8 Alerts. However, if this parameter is set to `true` then it will delete any Grafana 8 Alerts under this folder.
2018-02-21 13:09:01 +01:00
**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
{
2020-07-31 08:22:09 +02:00
"message" : "Folder deleted" ,
"id" : 2
2018-02-21 13:09:01 +01:00
}
```
Status Codes:
- **200** – Deleted
- **401** – Unauthorized
2021-07-22 12:27:13 +03:00
- **400** – Bad Request
2018-02-21 13:09:01 +01:00
- **403** – Access Denied
- **404** – Folder not found
## Get folder by id
2018-06-29 20:24:02 +02:00
`GET /api/folders/id/:id`
2018-02-21 13:09:01 +01:00
Will return the folder identified by id.
**Example Request** :
```http
2018-06-29 20:24:02 +02:00
GET /api/folders/id/1 HTTP / 1.1
2018-02-21 13:09:01 +01:00
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
{
"id" : 1 ,
"uid" : "nErXDvCkzz" ,
2019-10-08 05:21:47 -03:00
"title" : "Department ABC" ,
2018-02-21 13:09:01 +01:00
"url" : "/dashboards/f/nErXDvCkzz/department-abc" ,
"hasAcl" : false ,
"canSave" : true ,
"canEdit" : true ,
"canAdmin" : true ,
"createdBy" : "admin" ,
"created" : "2018-01-31T17:43:12+01:00" ,
"updatedBy" : "admin" ,
"updated" : "2018-01-31T17:43:12+01:00" ,
"version" : 1
}
```
Status Codes:
- **200** – Found
- **401** – Unauthorized
- **403** – Access Denied
- **404** – Folder not found