Skip to content
Get started
Esc
Files and media

Building

Updated 4 December 2026

Photos, videos, voice notes and audio files go by a link, or on WhatsApp as a file uploaded first.

Give an https link in url. It has to open without signing in. Instagram takes files only this way.

Code language
import { Airbox } from "@airboxhq/api";

const client = new Airbox(process.env.AIRBOX_API_KEY);

const { data, error } = await client.messages.sendImage({
  to: "+77011234567",
  url: "https://shop.example.kz/orders/1042.jpg",
  caption: "Your order #1042 is packed",
  channel: "whatsapp",
}, { idempotencyKey: "order-1042-photo" });

if (error) {
  throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}

console.log(data);

By upload

On WhatsApp, upload the file with ⁠POST /v1/media, then send its id as media_id. An uploaded file can be sent for 30 days.

Code language
import { readFile } from "node:fs/promises";
import { Airbox } from "@airboxhq/api";

const client = new Airbox(process.env.AIRBOX_API_KEY);

const { data, error } = await client.media.upload(await readFile("voice.ogg"), {
  filename: "voice.ogg",
  contentType: "audio/ogg",
});

if (error) {
  throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}

console.log(data);

Formats and sizes

Type Formats Up to
image JPEG, PNG 5 MB
video MP4, 3GP (H.264 and AAC) 16 MB
audio AAC, AMR, MP3, M4A, OGG (Opus, mono) 16 MB
voice OGG with the Opus codec, a link ending in .ogg or .opus 16 MB

A photo or a video takes a caption of up to 1,024 characters. On Instagram the caption goes as a message of its own.

Files customers send

A file in an incoming message comes with its media_id, mime_type and expires_at. Download it with ⁠GET /v1/media/{id} before then: the channel keeps it 7 days, and we keep no copy.

Code language
import { writeFile } from "node:fs/promises";
import { Airbox } from "@airboxhq/api";

const client = new Airbox(process.env.AIRBOX_API_KEY);

const { data, error } = await client.media.download("med_0199c5e2-6a2a-7b41-8e0d-2f1c3a4b5d6f");

if (error) {
  throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}

await writeFile("voice.ogg", data);