Skip to main content
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"
}
'
{
  "success": true,
  "message": "Attachment deleted successfully",
  "attachmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
⚠️ Using our API via a dedicated deployment? Just replace api.langdock.com with your deployment’s base URL: <deployment-url>/api/public
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.
Requires an API key with the KNOWLEDGE_FOLDER_API scope. You can create API Keys in your Workspace settings.

Request Format

Send the attachment ID in the request body as JSON.
ParameterTypeRequiredDescription
attachmentIdstringYesThe 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

Authorization
string
header
required

API key as Bearer token. Format "Bearer YOUR_API_KEY"

Body

application/json
attachmentId
string<uuid>
required

The ID of the attachment to delete

Response

Attachment deleted successfully

success
boolean
required
Example:

true

message
string
required
Example:

"Attachment deleted successfully"

attachmentId
string<uuid>
required

The ID of the deleted attachment