Media
Upload Media
Upload media files to WhatsApp (Meta) for use in messages and templates. Returns a media_id valid for 30 days.
POST /api/v1/public/media/upload
info
Content-Type: This endpoint uses multipart/form-data, not JSON.
The returned media_id can be used in send message or template payloads. Media expires after 30 days on Meta servers.
Supported File Types
| Type | Formats | Max Size |
|---|---|---|
| Image | JPEG, PNG, WebP | 5 MB |
| Video | MP4, 3GP | 16 MB |
| Audio | OGG, MP3, AMR | 16 MB |
| Document | PDF, DOC, DOCX | 16 MB |
Example Request
- cURL
- JavaScript
- Python
curl -X POST "https://chat.api.co.id/api/v1/public/media/upload" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/image.jpg"
const formData = new FormData();
formData.append("file", fileBlob, "image.jpg");
const response = await fetch("https://chat.api.co.id/api/v1/public/media/upload", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY"
},
body: formData
});
const { data } = await response.json();
// Use data.media_id in your send message payload
import requests
with open("image.jpg", "rb") as f:
response = requests.post(
"https://chat.api.co.id/api/v1/public/media/upload",
headers={"Authorization": "Bearer YOUR_API_KEY"},
files={"file": ("image.jpg", f, "image/jpeg")}
)
media_id = response.json()["data"]["media_id"]
Response
{
"success": true,
"data": {
"media_id": "1234567890",
"type": "image",
"mime_type": "image/jpeg",
"file_name": "image.jpg",
"file_size": 245000,
"whatsapp_phone_number_id": "clyyy9876543210",
"expires_in": "30 days"
}
}
Usage: Send Uploaded Media
After uploading, use the media_id as media_url in your send message request:
{
"phone_number": "628123456789",
"channel": "whatsapp",
"message_type": "image",
"media_url": "1234567890",
"caption": "Check this out!"
}
Try it out
tip
Press Try it and paste your API key (kc_live_...) into the API key (Bearer) field. Get the key from API Keys. Requests run against your live account, so endpoints that send, create, or delete act on real data.
- POST/api/v1/public/media/uploadUpload Media
Was this page helpful?