К содержанию
Esc
Отправить фото

Messages

POST /v1/messages

Фото или видео клиенту, который писал Вам за последние 24 часа: type равен image или video, а в поле с тем же названием media_id загруженного файла или публичная ссылка https в url, и подпись в caption, до 1024 символов, по желанию. У Instagram только url, а подпись уходит отдельным сообщением. Фото это JPEG или PNG до 5 МБ, видео MP4 или 3GP с H.264 и AAC до 16 МБ. На Android видео в профиле H.264 High с B-кадрами может не открыться, надёжнее Main без B-кадров или Baseline.

Returns the message object.

Headers

Idempotency-Key string
Makes a retry safe: the same key with the same body within 24 hours returns the first response and sends nothing again. Use an id of your own for the message, for example the order number. Up to 255 characters, not blank.

Body

to string required
The customer: an E.164 number on WhatsApp, or the from of their message on Instagram. Up to 32 characters.
channel string required
whatsapp, instagram, or auto for the channel the customer last wrote on.
type string required
image, or video for a video, with the same fields under video.
image.media_id string
The id of a file uploaded with ⁠POST /v1/media, on WhatsApp, up to 64 characters. Give this or image.url.
image.url string
An https link to the file, up to 2,048 characters. Give this or image.media_id.
image.caption string
A caption under the file, up to 1,024 characters.
video.media_id string
The id of a file uploaded with ⁠POST /v1/media, on WhatsApp, up to 64 characters. Give this or video.url.
video.url string
An https link to the file, up to 2,048 characters. Give this or video.media_id.
video.caption string
A caption under the file, up to 1,024 characters.

Errors

CodeHTTPWhat it means
invalid_request422Запрос заполнен неверно.
invalid_phone422Укажите номер в международном формате, например +77011234567.
channel_unavailable422Канал недоступен: он не подключён к организации или отключён. Подключите его на странице «Каналы».
payment_required402Канал не оплачен, отправка через него остановлена.
recipient_unknown422Человек ещё не писал в Instagram. В to укажите from из его сообщения.
channel_unresolved422Клиент ещё не писал Вам ни в один из подключённых каналов, и auto не может выбрать канал. Укажите его явно, например whatsapp.
outside_window422Клиент не писал Вам последние 24 часа, а свободный текст WhatsApp пропускает только в ответ. Отправьте одобренный шаблон.
media_not_found404Такого файла нет. Ключ видит только файлы своей организации и своего режима, боевого или тестового. Файл, загруженный для одного канала, уходит только в этот канал, а GET /v1/media/{id} скачивает только файлы, которые прислали клиенты.
media_expired410Канал больше не хранит этот файл: WhatsApp хранит присланный клиентом файл 7 дней, а загруженный 30. Файл клиента скачивайте раньше, а свой загрузите заново.
media_format422Формат файла не подходит. Фото принимается в JPEG или PNG, видео в MP4 или 3GP (H.264 и AAC), аудио в AAC, AMR, MP3, M4A или OGG (Opus, моно), а голосовое сообщение только в OGG с кодеком Opus, моно: загруженным файлом такого формата или ссылкой, которая заканчивается на .ogg или .opus.
meta_payment422Meta не отправляет сообщения: к аккаунту WhatsApp не привязана рабочая карта. Добавьте карту в Meta и повторите.
idempotency_mismatch422С этим Idempotency-Key уже был другой запрос. Для нового сообщения возьмите новый ключ.
idempotency_in_progress409Запрос с этим Idempotency-Key ещё выполняется. Повторите его чуть позже.

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

Язык кода
// npm install @airboxhq/api
// AIRBOX_API_KEY=YOUR_API_KEY node send_image.mjs
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: "Ваш заказ №1042 собран",
  channel: "whatsapp",
}, { idempotencyKey: "order-1042-photo" });

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

console.log(data);
Response 201
{
    "id": "0199c5e2-7b3a-7c51-9f0e-3a1d2b4c5e6f",
    "to": "+77011234567",
    "contact_id": "0199c5e2-1f0a-7a42-8d1e-5b7c9a2e4f10",
    "channel": "whatsapp",
    "type": "image",
    "image": {
        "url": "https://shop.example.kz/orders/1042.jpg",
        "caption": "Ваш заказ №1042 собран"
    },
    "status": "sent",
    "error": null,
    "sent_by": "api",
    "created_at": "2026-10-09T09:30:00+00:00",
    "sent_at": "2026-10-09T09:30:00+00:00",
    "delivered_at": null,
    "read_at": null
}