Delete an attachment
curl --request DELETE \
--url https://api.langdock.com/attachment/v1/delete \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"attachmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api.langdock.com/attachment/v1/delete"
payload = { "attachmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({attachmentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://api.langdock.com/attachment/v1/delete', 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.langdock.com/attachment/v1/delete",
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([
'attachmentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.langdock.com/attachment/v1/delete"
payload := strings.NewReader("{\n \"attachmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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("https://api.langdock.com/attachment/v1/delete")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attachmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/attachment/v1/delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attachmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Attachment deleted successfully",
"attachmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"message": "<string>",
"errors": [
"<unknown>"
]
}{
"error": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Agents API
Delete Attachment API
Delete an uploaded attachment by ID
DELETE
/
attachment
/
v1
/
delete
Delete an attachment
curl --request DELETE \
--url https://api.langdock.com/attachment/v1/delete \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"attachmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api.langdock.com/attachment/v1/delete"
payload = { "attachmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({attachmentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://api.langdock.com/attachment/v1/delete', 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.langdock.com/attachment/v1/delete",
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([
'attachmentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.langdock.com/attachment/v1/delete"
payload := strings.NewReader("{\n \"attachmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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("https://api.langdock.com/attachment/v1/delete")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attachmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/attachment/v1/delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attachmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Attachment deleted successfully",
"attachmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"message": "<string>",
"errors": [
"<unknown>"
]
}{
"error": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Delete an attachment by its ID. The attachment must belong to the same workspace as the API key and must either be created by the API key’s creator or belong to a Knowledge base shared with the API key.
Before You Start
- API key scope: Requires an API key with the
KNOWLEDGE_FOLDER_APIscope. You can create API Keys in your Workspace settings.
Base URL
https://api.langdock.com/attachment/v1/delete
Dedicated deploymentsReplace
api.langdock.com with <your-deployment-url>/api/public in all requests.Request Format
Send the attachment ID in the request body as JSON.| Parameter | Type | Required | Description |
|---|---|---|---|
attachmentId | string | Yes | The UUID of the attachment to delete |
Response Format
{
success: true;
message: string;
attachmentId: string;
}
Example
const axios = require("axios");
async function deleteAttachment(attachmentId) {
const response = await axios.delete(
"https://api.langdock.com/attachment/v1/delete",
{
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
data: { attachmentId },
}
);
console.log(response.data);
// {
// success: true,
// message: "Attachment deleted successfully",
// attachmentId: "550e8400-e29b-41d4-a716-446655440000"
// }
}
Error Handling
try {
await deleteAttachment("550e8400-e29b-41d4-a716-446655440000");
} catch (error) {
if (error.response) {
switch (error.response.status) {
case 400:
console.error("Invalid request body:", error.response.data.message);
break;
case 401:
console.error("Invalid API key");
break;
case 403:
console.error("API key does not have access to this attachment");
break;
case 404:
console.error("Attachment not found");
break;
case 500:
console.error("Server error");
break;
}
}
}
A deleted attachment can no longer be referenced in Agent conversations or restored via the API.
Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on API Key Best Practices.
Authorizations
API key as Bearer token. Format "Bearer YOUR_API_KEY"
Body
application/json
The ID of the attachment to delete
Was this page helpful?
⌘I