curl --request DELETE \
--url http://localhost:8787/v1/files \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"keys": [
"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png",
"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg"
]
}
'import requests
url = "http://localhost:8787/v1/files"
payload = { "keys": ["9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png", "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg"] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
keys: [
'9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png',
'9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg'
]
})
};
fetch('http://localhost:8787/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8787",
CURLOPT_URL => "http://localhost:8787/v1/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'keys' => [
'9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png',
'9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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 := "http://localhost:8787/v1/files"
payload := strings.NewReader("{\n \"keys\": [\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png\",\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg\"\n ]\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("x-api-key", "<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.delete("http://localhost:8787/v1/files")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"keys\": [\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png\",\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8787/v1/files")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Delete.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"keys\": [\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png\",\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"results": [
{
"key": "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png",
"deleted": {
"id": "223e4567-e89b-12d3-a456-426614174001",
"key": "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png",
"file_name": "example.png"
}
},
{
"key": "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg",
"error": "File not found"
}
],
"summary": {
"total": 2,
"deleted": 1,
"errors": 1
}
}{
"error": "Validation failed",
"fields": {},
"invalid_keys": [
"<string>"
],
"expected_org_id": "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4"
}{
"error": "API key required"
}{
"error": "File not found"
}{
"error": "Internal server error"
}Delete file(s) by key(s)
Deletes one or more files by key from the authenticated organization. Validates API key using WorkOS, extracts organization ID, verifies each file key starts with the organization UUID and belongs to the organization, then deletes from S3 storage and database. Each file key must start with a valid UUID that matches the organization ID. The file key can contain slashes (e.g., ‘org-id/path/to/file.png’).
curl --request DELETE \
--url http://localhost:8787/v1/files \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"keys": [
"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png",
"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg"
]
}
'import requests
url = "http://localhost:8787/v1/files"
payload = { "keys": ["9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png", "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg"] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
keys: [
'9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png',
'9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg'
]
})
};
fetch('http://localhost:8787/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8787",
CURLOPT_URL => "http://localhost:8787/v1/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'keys' => [
'9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png',
'9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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 := "http://localhost:8787/v1/files"
payload := strings.NewReader("{\n \"keys\": [\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png\",\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg\"\n ]\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("x-api-key", "<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.delete("http://localhost:8787/v1/files")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"keys\": [\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png\",\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8787/v1/files")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Delete.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"keys\": [\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png\",\n \"9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"results": [
{
"key": "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png",
"deleted": {
"id": "223e4567-e89b-12d3-a456-426614174001",
"key": "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png",
"file_name": "example.png"
}
},
{
"key": "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg",
"error": "File not found"
}
],
"summary": {
"total": 2,
"deleted": 1,
"errors": 1
}
}{
"error": "Validation failed",
"fields": {},
"invalid_keys": [
"<string>"
],
"expected_org_id": "9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4"
}{
"error": "API key required"
}{
"error": "File not found"
}{
"error": "Internal server error"
}Authorizations
WorkOS API key for authentication
Body
Array of file keys/paths in storage. Each key must start with a UUID that matches the organization ID.
1File key/path in storage (must start with organization UUID)
Response
Delete operation completed (may include partial success)
Indicates if the request was processed
true
Array of results for each key. Each item may be a success object or an error object.
Successful deletion
- Option 1
- Option 2
Show child attributes
Show child attributes
Summary of the deletion operation
Show child attributes
Show child attributes
Was this page helpful?