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
Einen hochgeladenen Anhang anhand der ID löschen
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>"
}Lösche einen Anhang anhand seiner ID. Der Anhang muss zum gleichen Workspace wie der API-Schlüssel gehören und entweder vom Ersteller des API-Schlüssels erstellt worden sein oder zu einer Wissensdatenbank gehören, die mit dem API-Schlüssel geteilt ist.
Bevor du startest
- API-Key-Scope: Erfordert einen API-Schlüssel mit dem
KNOWLEDGE_FOLDER_APIScope. Du kannst API-Schlüssel in deinen Workspace Einstellungen erstellen.
Basis-URL
https://api.langdock.com/attachment/v1/delete
Dedicated DeploymentsErsetze
api.langdock.com durch <your-deployment-url>/api/public in allen Anfragen.Anforderungsformat
Sende die Anhangs-ID im Request-Body als JSON.| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
attachmentId | string | Ja | Die UUID des zu löschenden Anhangs |
Antwortformat
{
success: true;
message: string;
attachmentId: string;
}
Beispiel
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"
// }
}
Fehlerbehandlung
try {
await deleteAttachment("550e8400-e29b-41d4-a716-446655440000");
} catch (error) {
if (error.response) {
switch (error.response.status) {
case 400:
console.error("Ungültiger Request-Body:", error.response.data.message);
break;
case 401:
console.error("Ungültiger API-Schlüssel");
break;
case 403:
console.error("API-Schlüssel hat keinen Zugriff auf diesen Anhang");
break;
case 404:
console.error("Anhang nicht gefunden");
break;
case 500:
console.error("Server-Fehler");
break;
}
}
}
Ein gelöschter Anhang kann nicht mehr in Agent-Konversationen referenziert oder über die API wiederhergestellt werden.
Langdock blockiert bewusst Browser-basierte Anfragen, um deinen API-Schlüssel zu schützen und die Sicherheit deiner Anwendungen zu gewährleisten. Weitere Informationen findest du in unserem Guide zu Best Practices für API-Schlüssel.
Autorisierungen
API key as Bearer token. Format "Bearer YOUR_API_KEY"
Body
application/json
The ID of the attachment to delete
War diese Seite hilfreich?