К содержанию
Esc
Написать как клиент

Testing

Написать как клиент

POST /v1/test/inbound

Test keys only

Только с тестовым ключом. Выдуманный клиент пишет на симулятор: приходит вебхук message.received, и до free_text_until из него этому номеру можно отвечать текстом. С type равным voice, audio, image или video вместо text клиент присылает пример файла, к фото и видео с подписью из caption, а ⁠GET /v1/media/{id} его скачивает.

Returns the incoming message.

Body

from string required
The made-up customer's number in E.164, up to 32 characters.
type string
text when left out, or voice, audio, image or video for a sample file.
text.body string
What the customer writes, up to 4,096 characters. Required unless type names a file.
name string
The customer's name, up to 120 characters, or null.
caption string
A caption for a sample photo or video, up to 1,024 characters, or null.

Errors

CodeHTTPWhat it means
test_key_required403Это работает только с тестовым ключом.
invalid_request422Запрос заполнен неверно.
invalid_phone422Укажите номер в международном формате, например +77011234567.

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 test_inbound.mjs
import { Airbox } from "@airboxhq/api";

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

const { data, error } = await client.test.inbound({
  from: "+77011234567",
  text: {
    body: "Здравствуйте! Когда будет готов мой заказ?",
  },
  name: "Асель",
});

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

console.log(data);
Response 201
{
    "id": "0199c5e2-6a29-7b40-8e0d-2f1c3a4b5d6e",
    "contact_id": "0199c5e2-1f0a-7a42-8d1e-5b7c9a2e4f10",
    "from": "+77011234567",
    "name": "Асель",
    "channel": "simulator",
    "type": "text",
    "text": {
        "body": "Здравствуйте! Когда будет готов мой заказ?"
    },
    "received_at": "2026-10-09T09:30:00+00:00",
    "free_text_until": "2026-10-10T09:30:00+00:00"
}