Media API
Get media file API
Get the details and download URL of one file in your media library by its ID. Use it to check a file still exists before you send it.
https://wbiztool.com/api/v1/media/{media_id}/Body: Query string, or a JSON body with POST
Replace {media_id} in the path with the id returned by Upload media or List media, for example /api/v1/media/5122/.
Quick example#
curl -G https://wbiztool.com/api/v1/media/5122/ \
--data-urlencode client_id=12345 \
--data-urlencode api_key=YOUR_API_KEYimport requests
media_id = 5122
response = requests.get(
f"https://wbiztool.com/api/v1/media/{media_id}/",
params={"client_id": 12345, "api_key": "YOUR_API_KEY"},
timeout=60,
)
result = response.json()
if result["status"] == 1:
media = result["data"]
print(media["original_file_name"], media["file_size_display"], media["file_url"])
else:
print("Failed:", result["message"])// Node.js 18+ (built-in fetch). Save as .mjs to use top-level await.
const mediaId = 5122;
const url = new URL(`https://wbiztool.com/api/v1/media/${mediaId}/`);
url.search = new URLSearchParams({ client_id: "12345", api_key: "YOUR_API_KEY" });
const response = await fetch(url);
const result = await response.json();
if (result.status === 1) {
const media = result.data;
console.log(media.original_file_name, media.file_size_display, media.file_url);
} else {
console.error("Failed:", result.message);
}<?php
$mediaId = 5122;
$query = http_build_query(['client_id' => 12345, 'api_key' => 'YOUR_API_KEY']);
$ch = curl_init("https://wbiztool.com/api/v1/media/$mediaId/?" . $query);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (($result['status'] ?? 0) === 1) {
echo $result['data']['original_file_name'] . ': ' . $result['data']['file_url'];
} else {
echo 'Failed: ' . ($result['message'] ?? 'no response');
}Replace 12345 and YOUR_API_KEY with your own values. See Authentication for where to find them.
Request parameters#
Send client_id and api_key in the query string of a GET request, or as a JSON body in a POST request. If client_id is in the query string, the JSON body is ignored.
Path
media_idintegerrequiredID of the media file. It must be a whole number; anything else returns an HTML "page not found" response instead of JSON.
Authentication
client_idintegerrequiredYour API Client ID from Settings → API keys.
api_keystringrequiredYour API key from the same page.
Response#
{
"status": 1,
"message": "Media file retrieved successfully",
"data": {
"id": 5122,
"file_name": "media_12345_17895804001234.pdf",
"original_file_name": "invoice-4821.pdf",
"file_url": "https://wbiztool-static.s3.ap-southeast-1.amazonaws.com/media/org_12345/media_12345_17895804001234.pdf",
"file_type": "file",
"file_size": 248312,
"file_size_display": "242.5 KB",
"mime_type": "application/pdf",
"is_image": false,
"file_extension": "pdf",
"created_at": "2026-09-16T10:20:31.512934+00:00",
"modified_at": "2026-09-16T10:20:31.512961+00:00",
"uploaded_by": "[email protected]"
}
}
| Field | Type | Description |
|---|---|---|
status | integer | 1 on success, 0 if the request failed. |
message | string | Media file retrieved successfully, otherwise the error. |
data.id | integer | ID of the media file. |
data.file_name | string | Name the file is stored under. |
data.original_file_name | string | The name the file had when it was uploaded. |
data.file_url | string | Direct download URL. Use it as img_url or file_url when sending. |
data.file_type | string | image or file. |
data.file_size | integer | Size in bytes. |
data.file_size_display | string | Readable size with one decimal, for example 242.5 KB. |
data.mime_type | string | MIME type, for example application/pdf. |
data.is_image | boolean | true when file_type is image. |
data.file_extension | string | Lower-case extension of original_file_name, without the dot. |
data.created_at | string | Upload time, ISO 8601 in UTC with a +00:00 offset. |
data.modified_at | string | When the file record was last changed, in the same format. |
data.uploaded_by | string or null | Login username (usually the email address) of the team member who uploaded the file. |
Errors#
Errors also return HTTP 200, with status set to 0:
{ "status": 0, "message": "Media file not found" }
One exception: if media_id isn't a number, the URL doesn't match any endpoint and you get an HTML 404 page instead of JSON.
| Message | How to fix it |
|---|---|
client_id is required | Add client_id. |
api_key is required | Add api_key. |
client_id must be a valid integer | Send client_id as a number. |
Invalid API key | Check the key exists and hasn't been deleted or disabled. |
Invalid client_id for this API key | The key belongs to a different client_id. |
Media file not found | No file with this ID exists in the API key's workspace, or it was deleted. |
Error retrieving media file: … | Something went wrong on our side. Try again. |
Check a file before sending it#
Fetch the file by ID, stop if it no longer exists, then send its file_url: as img_url with msg_type 1 for images, or as file_url with msg_type 2 for anything else.
import requests
BASE = "https://wbiztool.com/api/v1"
AUTH = {"client_id": 12345, "api_key": "YOUR_API_KEY"}
result = requests.get(f"{BASE}/media/5122/", params=AUTH, timeout=60).json()
if result["status"] != 1:
raise SystemExit("Can't use this file: " + result["message"])
media = result["data"]
message = {
**AUTH,
"whatsapp_client": 678,
"country_code": "91",
"phone": "9876543210",
"msg": "Here is the document you asked for.",
}
if media["is_image"]:
message.update(msg_type=1, img_url=media["file_url"])
else:
message.update(msg_type=2, file_url=media["file_url"], file_name=media["original_file_name"])
print(requests.post(f"{BASE}/send_msg/", json=message, timeout=60).json())// Node.js 18+ (built-in fetch). Save as .mjs to use top-level await.
const BASE = "https://wbiztool.com/api/v1";
const auth = { client_id: 12345, api_key: "YOUR_API_KEY" };
const url = new URL(`${BASE}/media/5122/`);
url.search = new URLSearchParams(auth);
const result = await (await fetch(url)).json();
if (result.status !== 1) throw new Error(`Can't use this file: ${result.message}`);
const media = result.data;
const message = {
...auth,
whatsapp_client: 678,
country_code: "91",
phone: "9876543210",
msg: "Here is the document you asked for.",
...(media.is_image
? { msg_type: 1, img_url: media.file_url }
: { msg_type: 2, file_url: media.file_url, file_name: media.original_file_name }),
};
const sent = await fetch(`${BASE}/send_msg/`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(message),
});
console.log(await sent.json());Non-image files such as .doc, .ppt, .csv, .zip, .wav and .mov are delivered with .pdf added to the name, and images over 16 MB fail to send. See Upload media → Upload and send.
Tips#
- Deleted files return
Media file not found, even though theirfile_urlmay still download. Check with this endpoint rather than by fetching the URL. Uploaded file URLs are public and permanent; see Upload media → Upload and send. - Files are per workspace. A file uploaded in one workspace can't be read with an API key from another.
- Don't know the ID? Search by name with List media.
