Skip to main content
POST
Upload an attachment
⚠️ Using our API via a dedicated deployment? Just replace api.langdock.com with your deployment’s base URL: <deployment-url>/api/public
This is the new Agents API with native Vercel AI SDK compatibility. The upload attachment endpoint is shared across both APIs. If you’re using the legacy Assistants API, see the migration guide.
Upload files that can be referenced in Agent conversations using their attachment IDs.
Requires an API key with the KNOWLEDGE_FOLDER_API scope. You can create API Keys in your Workspace settings.

Request Format

This endpoint accepts multipart/form-data requests with a single file upload.

Response Format

The API returns the uploaded file information:

Example

Error Handling

The uploaded attachment ID can be used in the Agent API in two ways:
  1. Per-message (recommended): Include the attachment UUID in the message’s metadata.attachments array when calling the Completions API
  2. Agent-level: Include the attachment UUID in the attachments array when creating or updating an agent
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

multipart/form-data
file
file
required

The file to upload

Response

Successfully uploaded file

attachmentId
string<uuid>
required

Unique identifier for the uploaded attachment

file
object
required