Delete a folder
curl --request DELETE \
--url https://api.dune.com/api/v1/folders/{folder_id} \
--header 'X-Dune-Api-Key: <x-dune-api-key>'import requests
url = "https://api.dune.com/api/v1/folders/{folder_id}"
headers = {"X-Dune-Api-Key": "<x-dune-api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {'X-Dune-Api-Key': '<x-dune-api-key>'}};
fetch('https://api.dune.com/api/v1/folders/{folder_id}', 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/{folder_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.dune.com/api/v1/folders/{folder_id}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("X-Dune-Api-Key", "<x-dune-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.dune.com/api/v1/folders/{folder_id}")
.header("X-Dune-Api-Key", "<x-dune-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dune.com/api/v1/folders/{folder_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["X-Dune-Api-Key"] = '<x-dune-api-key>'
response = http.request(request)
puts response.read_body{
"archived_dashboard_count": 1,
"archived_query_count": 4,
"deleted_folder_count": 3,
"folder_id": "dp180Cu3jW3L",
"path": "/Research/RWA"
}{
"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"
}{
"error": "Internal error"
}Folders
Delete Folder
Delete a folder. An empty folder is deleted right away. A folder that still holds subfolders, queries or dashboards is refused with 409 folder_not_empty and the counts, unless recursive=true. A recursive delete removes every subfolder and archives the queries and dashboards inside, as deleting a folder in the Dune app does; move content out first with POST /v1/content/move to keep it in the library.
DELETE
/
v1
/
folders
/
{folder_id}
Delete a folder
curl --request DELETE \
--url https://api.dune.com/api/v1/folders/{folder_id} \
--header 'X-Dune-Api-Key: <x-dune-api-key>'import requests
url = "https://api.dune.com/api/v1/folders/{folder_id}"
headers = {"X-Dune-Api-Key": "<x-dune-api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {'X-Dune-Api-Key': '<x-dune-api-key>'}};
fetch('https://api.dune.com/api/v1/folders/{folder_id}', 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/{folder_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.dune.com/api/v1/folders/{folder_id}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("X-Dune-Api-Key", "<x-dune-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.dune.com/api/v1/folders/{folder_id}")
.header("X-Dune-Api-Key", "<x-dune-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dune.com/api/v1/folders/{folder_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["X-Dune-Api-Key"] = '<x-dune-api-key>'
response = http.request(request)
puts response.read_body{
"archived_dashboard_count": 1,
"archived_query_count": 4,
"deleted_folder_count": 3,
"folder_id": "dp180Cu3jW3L",
"path": "/Research/RWA"
}{
"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"
}{
"error": "Internal error"
}Minimum required API key scope:
Read/WriteUse Cases
- Remove Empty Folders: An empty folder is deleted right away.
- Remove a Folder Tree: Pass
recursive=trueto delete all subfolders and archive the queries and dashboards inside. To keep the content, move it out first with Move Queries and Dashboards.
Headers
API Key for the service
Path Parameters
Folder id
Query Parameters
API Key, alternative to using the HTTP header X-Dune-Api-Key
Delete a folder that is not empty, archiving its queries and dashboards
Was this page helpful?