Skip to content
Get started
Esc
Upload a file

Media

POST /v1/media

A file to send: multipart, the file in file and the channel it goes on in channel: whatsapp. Instagram takes no uploads, only links. The response's id is the media_id a send names, valid until expires_at, 30 days on WhatsApp. The channel keeps the file, and we keep only its id. WhatsApp takes a photo as JPEG or PNG up to 5 MB, a video as MP4 or 3GP (H.264 and AAC) up to 16 MB, and audio as AAC, AMR, MP3, M4A or OGG (Opus, mono) up to 16 MB. With a test key the file is checked and stays on the simulator.

Form fields

file file required
The file. A photo as JPEG or PNG up to 5 MB, a video as MP4 or 3GP and audio as AAC, AMR, MP3, M4A or OGG, each up to 16 MB.
channel string required
The channel the file goes on: whatsapp. Instagram takes files only by link.

Errors

CodeHTTPWhat it means
invalid_request422The request is not filled in correctly.
channel_unavailable422The channel is unavailable: it is not connected to the workspace or was disconnected. Connect it on the workspace's Channels page.
media_format422The file's format does not fit. A photo goes as JPEG or PNG, a video as MP4 or 3GP (H.264 and AAC), audio as AAC, AMR, MP3, M4A or OGG (Opus, mono), and a voice note only as OGG with the Opus codec, mono: an uploaded file of that format, or a link ending in .ogg or .opus.
media_too_large422The file is larger than the channel takes: up to 5 MB for a photo, 16 MB for audio and video.
media_rejected422The channel did not take the file: its format did not fit or its link did not open. Check the format and size, and that the link opens without signing in.
channel_error422The channel did not take the message. Try again later, and if it still fails, write to us.

Any request can also get the codes on Errors, such as unauthenticated and rate_limited.

Code language
// npm install @airboxhq/api
// AIRBOX_API_KEY=YOUR_API_KEY node upload_media.mjs
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);
Response 201
{
    "id": "med_0199c5e2-5c18-7a3f-9d2e-1b0c4a6e8f72",
    "channel": "whatsapp",
    "mime_type": "audio/ogg",
    "size": 14695,
    "expires_at": "2026-11-08T09:30:00+00:00"
}