Documentation Index
Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
Use this file to discover all available pages before exploring further.
Using our API via a dedicated deployment? Just replace api.langdock.com with your deployment’s base URL: <deployment-url>/api/public
Deletes a file (attachment) from a knowledge folder. This removes the file and all associated embeddings, making the content no longer searchable.
Path Parameters
| Parameter | Type | Required | Description |
|---|
folderId | string | Yes | The ID of the knowledge folder |
attachmentId | string | Yes | The ID of the attachment to delete |
Examples
Delete with cURL
curl -X DELETE "https://api.langdock.com/knowledge/{folderId}/{attachmentId}" \
-H "Authorization: Bearer YOUR_API_KEY"
Delete with JavaScript
const axios = require("axios");
async function deleteAttachment(folderId, attachmentId) {
const response = await axios.delete(
`https://api.langdock.com/knowledge/${folderId}/${attachmentId}`,
{
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
}
);
return response.data;
}
// Example usage
try {
const result = await deleteAttachment("folder_abc123", "att_xyz789");
console.log("Attachment deleted:", result.message);
} catch (error) {
console.error("Failed to delete:", error.response?.data?.message);
}
Bulk Delete Example
async function deleteMultipleAttachments(folderId, attachmentIds) {
const results = await Promise.allSettled(
attachmentIds.map((id) => deleteAttachment(folderId, id))
);
const succeeded = results.filter((r) => r.status === "fulfilled").length;
const failed = results.filter((r) => r.status === "rejected").length;
console.log(`Deleted ${succeeded} files, ${failed} failed`);
return results;
}
Success Response (200 OK)
{
status: "success";
message: "Attachment deleted";
}
Example Response
{
"status": "success",
"message": "Attachment deleted"
}
Error Handling
try {
const response = await deleteAttachment(folderId, attachmentId);
} catch (error) {
if (error.response) {
switch (error.response.status) {
case 400:
console.error("Invalid request:", error.response.data.message);
break;
case 401:
console.error("Invalid or missing API key");
break;
case 403:
console.error("API key does not have access to this knowledge folder");
break;
case 404:
console.error("Knowledge folder or attachment not found");
break;
case 429:
console.error("Rate limit exceeded");
break;
case 500:
console.error("Server error");
break;
}
}
}
Important Notes
Deletion is permanent. The file and all associated embeddings will be removed and cannot be recovered.
- The attachment must belong to the specified knowledge folder
- The knowledge folder must be shared with your API key
- Deleting an attachment removes it from search results immediately
- Embeddings associated with the attachment are also deleted
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. API key as Bearer token. Format "Bearer YOUR_API_KEY"
The ID of the knowledge folder
The ID of the attachment to delete
Attachment deleted successfully