Upload Files
Learn how to upload and attach files to your API queries
The Arkangel AI API allows you to attach files to your queries for contextual analysis.
Supported File Types
| Type | Extensions | Max Size |
|---|---|---|
| Documents | .pdf, .doc, .docx |
10 MB |
| Images | .jpg, .png, .webp |
5 MB |
| Text | .txt, .md |
2 MB |
Uploading a File
Endpoint
POST https://api.arkangelai.com/v1/files
cURL Example
curl -X POST https://api.arkangelai.com/v1/files \
-H "Authorization: Bearer your_api_key" \
-F "file=@document.pdf" \
-F "purpose=analysis"
JavaScript Example
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('purpose', 'analysis');
const response = await fetch('https://api.arkangelai.com/v1/files', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key'
},
body: formData
});
const result = await response.json();
console.log('File uploaded:', result.file_id);
Upload Response
{
"file_id": "file_abc123",
"filename": "document.pdf",
"size": 1024000,
"mime_type": "application/pdf",
"purpose": "analysis",
"status": "processed",
"created_at": "2026-01-19T10:30:00Z"
}
Using Files in Queries
Once the file is uploaded, you can reference it in your messages:
const response = await fetch('https://api.arkangelai.com/v1/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'Analyze this medical document',
file_ids: ['file_abc123']
})
});
List Files
curl https://api.arkangelai.com/v1/files \
-H "Authorization: Bearer your_api_key"
Response
{
"files": [
{
"file_id": "file_abc123",
"filename": "document.pdf",
"size": 1024000,
"created_at": "2026-01-19T10:30:00Z"
}
],
"total": 1
}
Delete a File
curl -X DELETE https://api.arkangelai.com/v1/files/file_abc123 \
-H "Authorization: Bearer your_api_key"
Error Handling
| Code | Error | Description |
|---|---|---|
| 400 | invalid_file_type |
Unsupported file type |
| 400 | file_too_large |
File exceeds maximum size |
| 404 | file_not_found |
File does not exist |
| 422 | file_processing_failed |
Error processing file |
Best Practices
- Validate file type before uploading
- Compress large images before upload
- Delete files you no longer need
- Use descriptive names for your files
Next Steps
- Review Chats - Manage conversations with attached files
- Usage Examples - See complete examples