try { const response = await axios.post('https://api.langdock.com/attachment/v1/upload', ...);} catch (error) { if (error.response) { switch (error.response.status) { case 400: console.error('No file provided'); break; case 401: console.error('Invalid API key'); break; case 500: console.error('Server error'); break; } }}
The uploaded attachment ID can be used in the Agent API by including it in the attachmentIds array either at the agent level or message level.
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.