К содержанию
Esc
Переписка

Contacts

GET /v1/contacts/{id}/messages

Переписка с контактом, сначала новые сообщения: что он написал, как это приносит message.received, и что ушло ему, как это показывает ⁠GET /v1/messages/{id}, у каждого сообщения своё direction, inbound или outbound. Тестовый ключ видит только сообщения симулятора, боевой все остальные. На странице до limit сообщений, и пока has_more равно true, следующую страницу отдаёт запрос с id последнего сообщения в after.

Path parameters

id string required
The contact's id, as ⁠GET /v1/contacts or a message's contact_id gives it.

Query parameters

limit integer
How many items a page has, from 1 to 100, 20 by default.
after string
The id of the last message on the page before, for the next page.

Errors

CodeHTTPWhat it means
not_found404Ничего не найдено. Ключ видит только сообщения своей организации и своего режима, боевого или тестового.
invalid_request422Запрос заполнен неверно.

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

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

const { data, error } = await client.contacts.listMessages("0199c5e2-1f0a-7a42-8d1e-5b7c9a2e4f10", {
  limit: 50,
});

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

console.log(data);
Response 200
{
    "data": [
        {
            "direction": "outbound",
            "id": "0199c5e2-7b3a-7c51-9f0e-3a1d2b4c5e6f",
            "to": "+77011234567",
            "contact_id": "0199c5e2-1f0a-7a42-8d1e-5b7c9a2e4f10",
            "channel": "whatsapp",
            "type": "text",
            "text": {
                "body": "Здравствуйте! Ваш заказ №1042 готов, забрать его можно сегодня до 20:00."
            },
            "status": "read",
            "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": "2026-10-09T09:30:02+00:00",
            "read_at": "2026-10-09T09:31:15+00:00"
        },
        {
            "direction": "inbound",
            "id": "0199c5e2-6a29-7b40-8e0d-2f1c3a4b5d6e",
            "contact_id": "0199c5e2-1f0a-7a42-8d1e-5b7c9a2e4f10",
            "from": "+77011234567",
            "name": "Асель",
            "channel": "whatsapp",
            "type": "text",
            "text": {
                "body": "Здравствуйте! Когда будет готов мой заказ?"
            },
            "received_at": "2026-10-09T09:28:00+00:00",
            "free_text_until": "2026-10-10T09:28:00+00:00"
        }
    ],
    "has_more": false
}