Upload File
POST /backend/uploads
Content-Type: multipart/form-data
Form Parameters
| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | File to upload (max 10 MB) |
type | string | No | File type: media or audio (default: media) |
folder | string | No | Folder to organize the file in storage |
Example
curl -X POST "https://api.leavo.ai/backend/uploads" \
-H "Authorization: Bearer your_api_key_here" \
-F "file=@product_photo.jpg" \
-F "type=media"
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('type', 'media');
const response = await fetch('https://api.leavo.ai/backend/uploads', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key_here'
},
body: formData
});
const upload = await response.json();
console.log('File URL:', upload.file_url);
import requests
with open('product_photo.jpg', 'rb') as f:
response = requests.post(
'https://api.leavo.ai/backend/uploads',
headers={'Authorization': 'Bearer your_api_key_here'},
files={'file': f},
data={'type': 'media'}
)
print('File URL:', response.json()['file_url'])
Response (200)
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"tenant_id": "d6b10acc-2307-413f-a4de-4c2edf3f9a70",
"filename": "product_photo",
"file_type": "media",
"file_url": "https://api.leavo.ai/media/proxy/d6b10acc/550e8400.jpg",
"mime_type": "image/jpeg",
"size": 1048576,
"status": "PENDING",
"created_at": "2024-01-15T10:30:00Z"
}
Send Media in Message
After uploading, use the file to send a media message:POST /backend/messages/send-media
Content-Type: multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
channel_id | UUID | Yes | Channel to send through |
remote_jid | string | Yes | Recipient (WhatsApp JID) |
message_type | string | Yes | image, audio, video, or document |
content | string | No | Media caption |
file | file | Yes | Media file |
Common Errors
| Code | Description |
|---|---|
400 | File not provided or invalid format |
413 | File exceeds 10 MB limit |