Upload bijlage-API
Upload bestanden die in Assistant-gesprekken kunnen worden verwijzen met hun attachment-ID's.
Om de API te gebruiken heb je een API-sleutel nodig. Je kunt API-sleutels aanmaken in je Workspace-instellingen: https://app.langdock.com/settings/workspace/products/api
curl --request POST \
--url https://api.langdock.com/attachment/v1/upload \
--header 'Authorization: <authorization>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file'const axios = require("axios");
const FormData = require("form-data");
const fs = require("fs");
async function uploadAttachment() {
const form = new FormData();
form.append("file", fs.createReadStream("example.pdf"));
const response = await axios.post(
"https://api.langdock.com/attachment/v1/upload",
form,
{
headers: {
...form.getHeaders(),
Authorization: "Bearer YOUR_API_KEY",
},
}
);
console.log(response.data);
// {
// attachmentId: "550e8400-e29b-41d4-a716-446655440000",
// file: {
// name: "example.pdf",
// mimeType: "application/pdf",
// sizeInBytes: 1234567
// }
// }
}Verzoek
Dit endpoint accepteert multipart/form-data-aanvragen met een enkele bestandsupload.
Methode: POST
Pad: /attachment/v1/upload
Content-Type: multipart/form-data
Header
Authorization (string, vereist) — API-sleutel als Bearer-token. Formaat: "Bearer YOUR_API_KEY"
Body
file (file, vereist) — Het bestand om te uploaden
Respons
200 application/json — Bestand succesvol geüpload
Response JSON:
{
"attachmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file": {
"name": "<string>",
"mimeType": "<string>",
"sizeInBytes": 123
}
}Veldgegevens:
Voorbeeldgebruik
Gebruik de geretourneerde attachmentId in de Assistant-API door deze op te nemen in de
attachmentIdsarray op assistant-niveau of berichtniveau.

