Webhook api обзор: интеграция и автоматизация

Вебхуки

Используйте вебхуки для получения событий сообщений немедленно в вашей системе.

Доступны два типа вебхуков:

  1. Вебхук статуса доставки для исходящих сообщений.
  2. Вебхук входящих сообщений для SMS и других поддерживаемых каналов.

1. Вебхук статуса доставки

Настройте этот вебхук в настройках устройства для получения обновлений статуса без опроса API.

{
  "sms_id": int,
  "status_id": int,
  "status_message": string,
  "sendto": string,
  "senttime": datetime,
  "channel_id": int,
  "device_id": int
}
  • 1 - Ожидание СМС
  • 2 - SMS, принятые по телефону
  • 3 - В очереди для отправки. Certainly, it would have been more logical to place the status "queued for sending" before "SMS taken by phone," but for backward compatibility, the statuses are in the following order: 1, 3, 2."
  • 5 - Входящее SMS
  • 6 - Отправленное SMS по телефону
  • 7 - SMS доставлено
  • 8 - SMS не было доставлено
  • 9 - SMS не отправлено вовсе - обобщенный сбой. (Читайте что делать с этой ошибкой здесь)
  • Другое, меньше распространенных ошибок:
  • 10 - SMS не отправлено - No Service
  • 11 - SMS не отправлено - Null PDU
  • 12 - SMS не отправлено - Radio Off
  • 100, 101 - SMS не отправлено - NOT ALLOWED. (Разрешения для отправки SMS в приложении не были предоставлены)

2. Вебхук входящих сообщений

Настройте этот вебхук для пересылки входящих сообщений в CRM, хелпдеск или бэкенд.

The payload includes a "type" field that indicates whether the incoming message is a text message or an image (e.g. from WhatsApp).

Text message (type = "text")

Sent for incoming SMS and incoming text messages from WhatsApp / WhatsApp Business / RCS.

{
  "address": string,
  "date": datetime,
  "date_sent": datetime,
  "body": string,
  "internal_id": int,
  "channel_id": int,
  "sms_id": int,
  "device_id": int,
  "device_name": string,
  "type": "text"
}

Image message (type = "img")

Sent for incoming images from WhatsApp / WhatsApp Business. The image is already uploaded to our S3 storage — your backend only needs to store the URL, no need to download and re-upload the file.

{
  "address": string,
  "date": datetime,
  "date_sent": datetime,
  "body": "",
  "internal_id": null,
  "sim": int,
  "sms_id": int,
  "type": "img",
  "img_url": "https://smsgateway24.s3.eu-central-1.amazonaws.com/..."
}

Notes:

  • "img_url" is a permanent public link to the image stored on our S3 bucket.
  • "body" is empty and "internal_id" is null for image messages — use "sms_id" as the unique identifier.
  • The webhook URL is taken from the same channel slot setting as text messages (WhatsApp = slot 3, WhatsApp Business = slot 2).
Доступность вебхука зависит от вашего тарифного плана.