curl --request POST \
--url https://api.dune.com/api/v1/folders \
--header 'Content-Type: application/json' \
--header 'X-Dune-Api-Key: <x-dune-api-key>' \
--data '
{
"name": "RWA",
"color": "blue",
"description": "<string>",
"icon": "rocket",
"parent_folder_id": "aZ3kP0qLm9Xc"
}
'import requests
url = "https://api.dune.com/api/v1/folders"
payload = {
"name": "RWA",
"color": "blue",
"description": "<string>",
"icon": "rocket",
"parent_folder_id": "aZ3kP0qLm9Xc"
}
headers = {
"X-Dune-Api-Key": "<x-dune-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Dune-Api-Key': '<x-dune-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'RWA',
color: 'blue',
description: '<string>',
icon: 'rocket',
parent_folder_id: 'aZ3kP0qLm9Xc'
})
};
fetch('https://api.dune.com/api/v1/folders', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dune.com/api/v1/folders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'RWA',
'color' => 'blue',
'description' => '<string>',
'icon' => 'rocket',
'parent_folder_id' => 'aZ3kP0qLm9Xc'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Dune-Api-Key: <x-dune-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.dune.com/api/v1/folders"
payload := strings.NewReader("{\n \"name\": \"RWA\",\n \"color\": \"blue\",\n \"description\": \"<string>\",\n \"icon\": \"rocket\",\n \"parent_folder_id\": \"aZ3kP0qLm9Xc\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Dune-Api-Key", "<x-dune-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dune.com/api/v1/folders")
.header("X-Dune-Api-Key", "<x-dune-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"RWA\",\n \"color\": \"blue\",\n \"description\": \"<string>\",\n \"icon\": \"rocket\",\n \"parent_folder_id\": \"aZ3kP0qLm9Xc\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dune.com/api/v1/folders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Dune-Api-Key"] = '<x-dune-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"RWA\",\n \"color\": \"blue\",\n \"description\": \"<string>\",\n \"icon\": \"rocket\",\n \"parent_folder_id\": \"aZ3kP0qLm9Xc\"\n}"
response = http.request(request)
puts response.read_body{
"color": "blue",
"created_at": "<string>",
"description": "<string>",
"folder_id": "dp180Cu3jW3L",
"icon": "folder",
"name": "RWA",
"parent_folder_id": "aZ3kP0qLm9Xc",
"path": "/Research/RWA",
"updated_at": "<string>"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"error": "Invalid API Key"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"error": "Internal error"
}Create Folder
Create a folder at the root of the library or inside parent_folder_id. Team folders need an editor or admin behind the API key. When a folder already exists at the same path the response is 409 with code folder_already_exists and details.existing_folder_id, so a retry can use that folder.
curl --request POST \
--url https://api.dune.com/api/v1/folders \
--header 'Content-Type: application/json' \
--header 'X-Dune-Api-Key: <x-dune-api-key>' \
--data '
{
"name": "RWA",
"color": "blue",
"description": "<string>",
"icon": "rocket",
"parent_folder_id": "aZ3kP0qLm9Xc"
}
'import requests
url = "https://api.dune.com/api/v1/folders"
payload = {
"name": "RWA",
"color": "blue",
"description": "<string>",
"icon": "rocket",
"parent_folder_id": "aZ3kP0qLm9Xc"
}
headers = {
"X-Dune-Api-Key": "<x-dune-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Dune-Api-Key': '<x-dune-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'RWA',
color: 'blue',
description: '<string>',
icon: 'rocket',
parent_folder_id: 'aZ3kP0qLm9Xc'
})
};
fetch('https://api.dune.com/api/v1/folders', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dune.com/api/v1/folders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'RWA',
'color' => 'blue',
'description' => '<string>',
'icon' => 'rocket',
'parent_folder_id' => 'aZ3kP0qLm9Xc'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Dune-Api-Key: <x-dune-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.dune.com/api/v1/folders"
payload := strings.NewReader("{\n \"name\": \"RWA\",\n \"color\": \"blue\",\n \"description\": \"<string>\",\n \"icon\": \"rocket\",\n \"parent_folder_id\": \"aZ3kP0qLm9Xc\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Dune-Api-Key", "<x-dune-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dune.com/api/v1/folders")
.header("X-Dune-Api-Key", "<x-dune-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"RWA\",\n \"color\": \"blue\",\n \"description\": \"<string>\",\n \"icon\": \"rocket\",\n \"parent_folder_id\": \"aZ3kP0qLm9Xc\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dune.com/api/v1/folders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Dune-Api-Key"] = '<x-dune-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"RWA\",\n \"color\": \"blue\",\n \"description\": \"<string>\",\n \"icon\": \"rocket\",\n \"parent_folder_id\": \"aZ3kP0qLm9Xc\"\n}"
response = http.request(request)
puts response.read_body{
"color": "blue",
"created_at": "<string>",
"description": "<string>",
"folder_id": "dp180Cu3jW3L",
"icon": "folder",
"name": "RWA",
"parent_folder_id": "aZ3kP0qLm9Xc",
"path": "/Research/RWA",
"updated_at": "<string>"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"error": "Invalid API Key"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"code": "folder_not_found",
"details": {
"dashboard_count": 123,
"existing_folder_id": "<string>",
"query_count": 123,
"subfolder_count": 123
},
"error": "Folder not found"
}{
"error": "Internal error"
}Read/WriteUse Cases
- Set Up a Project: Create a folder tree for a new project or client.
- Safe Retries: When the folder already exists, the
409response includesexisting_folder_id, so a script or agent can use that folder and continue.
Headers
API Key for the service
Query Parameters
API Key, alternative to using the HTTP header X-Dune-Api-Key
Body
Folder to create
"RWA"
Color is a preset (green, yellow, red, blue-light, gray, orange, blue, pink, mauve, amber) or a hex value such as #E5477D. Defaults to "gray".
"blue"
Icon defaults to "folder".
"rocket"
ParentFolderID creates the folder inside another folder; omit it for the library root.
"aZ3kP0qLm9Xc"
Response
OK
Color is a preset name or a hex value.
"blue"
"dp180Cu3jW3L"
"folder"
"RWA"
ParentFolderID is null for a folder at the library root.
"aZ3kP0qLm9Xc"
Path is the full path from the library root.
"/Research/RWA"
Was this page helpful?