openapi: 3.1.0 info: title: MG Node Transport API Webhook version: 1.0.0 description: Webhook API транспорта MG Node webhooks: events: post: requestBody: $ref: '#/components/requestBodies/WebhookRequest' responses: '200': $ref: '#/components/responses/WebhookResponse' components: schemas: BaseWebhookRequestData: description: Базовая структура данных запроса webhook type: object properties: type: $ref: '#/components/schemas/WebhookType' meta: $ref: '#/components/schemas/WebhookRequestMeta' required: - type - meta WebhookRequestData: description: Общая структура данных запроса вебхука type: object properties: type: $ref: '#/components/schemas/WebhookType' meta: $ref: '#/components/schemas/WebhookRequestMeta' data: type: object discriminator: propertyName: type mapping: message_sent: '#/components/schemas/WebhookMessageSent' message_updated: '#/components/schemas/WebhookMessageUpdated' message_deleted: '#/components/schemas/WebhookMessageDeleted' message_read: '#/components/schemas/WebhookMessageRead' template_create: '#/components/schemas/WebhookTemplateCreate' template_update: '#/components/schemas/WebhookTemplateUpdate' template_delete: '#/components/schemas/WebhookTemplateDelete' reaction_add: '#/components/schemas/WebhookMessageReactionAdd' reaction_delete: '#/components/schemas/WebhookMessageReactionDelete' oneOf: - $ref: '#/components/schemas/WebhookMessageSent' - $ref: '#/components/schemas/WebhookMessageUpdated' - $ref: '#/components/schemas/WebhookMessageDeleted' - $ref: '#/components/schemas/WebhookMessageRead' - $ref: '#/components/schemas/WebhookTemplateCreate' - $ref: '#/components/schemas/WebhookTemplateUpdate' - $ref: '#/components/schemas/WebhookTemplateDelete' - $ref: '#/components/schemas/WebhookMessageReactionAdd' - $ref: '#/components/schemas/WebhookMessageReactionDelete' required: - type - meta - data WebhookType: description: Тип события вебхука type: string enum: - message_sent - message_updated - message_deleted - message_read - template_create - template_update - template_delete - reaction_add - reaction_delete WebhookRequestMeta: description: Метаданные запроса вебхука type: object properties: timestamp: type: number required: - timestamp WebhookMessageSent: description: Событие webhook при отправке сообщения allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - message_sent data: $ref: '#/components/schemas/WebhookMessageSentData' required: - data WebhookMessageUpdated: description: Событие вебхука обновления сообщения allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - message_updated data: $ref: '#/components/schemas/WebhookMessageUpdatedData' required: - data WebhookMessageDeleted: description: Событие webhook при удалении сообщения allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - message_deleted data: $ref: '#/components/schemas/WebhookMessageDeletedData' required: - data WebhookMessageRead: description: Событие вебхука прочтения сообщения allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - message_read data: $ref: '#/components/schemas/WebhookMessageReadData' required: - data WebhookTemplateCreate: description: Событие webhook при создании шаблона allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - template_create data: $ref: '#/components/schemas/WebhookTemplateCreateData' required: - data WebhookTemplateUpdate: description: Событие webhook при обновлении шаблона allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - template_update data: $ref: '#/components/schemas/WebhookTemplateUpdateData' required: - data WebhookTemplateDelete: description: Событие webhook при удалении шаблона allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - template_delete data: $ref: '#/components/schemas/WebhookTemplateDeleteData' required: - data WebhookMessageReactionAdd: description: Событие webhook при добавлении реакции к сообщению allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - reaction_add data: $ref: '#/components/schemas/WebhookMessageReactionAddData' required: - data WebhookMessageReactionDelete: description: Событие вебхука удаления реакции из сообщения allOf: - $ref: '#/components/schemas/BaseWebhookRequestData' - type: object properties: type: type: string enum: - reaction_delete data: $ref: '#/components/schemas/WebhookMessageReactionDeleteData' required: - data WebhookMessageMeta: type: object description: Метаданные для событий webhook properties: external_user_id: description: Внешний идентификатор пользователя example: user123 type: string external_chat_id: description: Внешний идентификатор чата example: chat456 type: string channel_id: description: Идентификатор канала example: 789 format: int64 type: integer required: - external_user_id - external_chat_id - channel_id WebhookMessageSentData: description: Данные события вебхука для отправленного сообщения allOf: - $ref: '#/components/schemas/WebhookMessageMeta' - type: object properties: id: description: Уникальный идентификатор сообщения в MessageGateway. Может отсутствовать для отложенной отправки до подтверждения сообщения в MessageGateway. example: 123456789 type: number type: $ref: '#/components/schemas/MessageType' content: description: Содержимое сообщения example: Hello, world! type: string quote_external_id: description: Внешний идентификатор цитируемого сообщения example: quote123 type: string quote_content: description: Содержимое цитируемого сообщения example: This is a quoted message. type: string in_app_id: description: Системный идентификатор сообщения example: 12345 format: int32 type: integer user: $ref: '#/components/schemas/WebhookUserData' bot: $ref: '#/components/schemas/WebhookBotData' customer: $ref: '#/components/schemas/WebhookCustomerData' product: $ref: '#/components/schemas/MessageProduct' order: $ref: '#/components/schemas/MessageOrder' items: description: Список медиа-вложений в сообщении items: $ref: '#/components/schemas/WebhookMessageFile' type: array template: $ref: '#/components/schemas/WebhookTemplateInfo' attachments: $ref: '#/components/schemas/MessageTransportAttachments' required: - type - content - quote_external_id - quote_content WebhookMessageUpdatedData: description: Данные события вебхука для обновлённого сообщения allOf: - $ref: '#/components/schemas/WebhookMessageMeta' - type: object properties: type: $ref: '#/components/schemas/MessageType' external_message_id: type: string description: Внешний идентификатор сообщения example: msg123 content: description: Содержимое сообщения example: Hello, world! type: string attachments: $ref: '#/components/schemas/MessageTransportAttachments' product: $ref: '#/components/schemas/MessageProduct' order: $ref: '#/components/schemas/MessageOrder' required: - type - external_message_id - content WebhookMessageDeletedData: description: Событие webhook при удалении сообщения allOf: - $ref: '#/components/schemas/WebhookMessageMeta' - type: object properties: external_message_id: type: string description: Внешний идентификатор сообщения example: msg123 required: - external_message_id WebhookMessageReadData: description: Событие вебхука прочтения сообщения allOf: - $ref: '#/components/schemas/WebhookMessageMeta' - type: object properties: external_message_id: type: string description: Внешний идентификатор сообщения example: msg123 required: - external_message_id WebhookMessageReactionData: description: Данные события вебхука реакций на сообщение allOf: - $ref: '#/components/schemas/WebhookMessageMeta' - type: object properties: external_message_id: type: string description: Внешний идентификатор сообщения example: msg123 new_reaction: type: string description: Новая реакция добавлена к сообщению example: 👍 old_reaction: type: string description: Удаляемая реакция example: ❤️ all_reactions: type: array description: Список всех реакций на сообщение items: $ref: '#/components/schemas/WebhookReactionItem' required: - external_message_id - all_reactions WebhookMessageReactionAddData: description: Данные события вебхука добавления реакции к сообщению allOf: - $ref: '#/components/schemas/WebhookMessageMeta' - $ref: '#/components/schemas/WebhookMessageReactionData' - type: object properties: new_reaction: type: string description: Новая реакция добавлена к сообщению example: 👍 required: - new_reaction WebhookMessageReactionDeleteData: description: Данные события вебхука удаления реакции из сообщения allOf: - $ref: '#/components/schemas/WebhookMessageMeta' - $ref: '#/components/schemas/WebhookMessageReactionData' WebhookTemplateCreateData: description: Данные события webhook при создании шаблона allOf: - $ref: '#/components/schemas/WebhookTemplateContent' - type: object properties: channel_id: type: number description: Идентификатор канала example: 789 required: - channel_id WebhookTemplateUpdateData: description: Данные события webhook при обновлении шаблона allOf: - $ref: '#/components/schemas/WebhookTemplateContent' - type: object properties: channel_id: type: number description: Идентификатор канала example: 789 code: type: string description: Код шаблона example: template123 required: - channel_id - code WebhookTemplateDeleteData: description: Данные события вебхука удаления шаблона allOf: - $ref: '#/components/schemas/WebhookTemplateContent' - type: object properties: channel_id: type: number description: Идентификатор канала example: 789 code: type: string description: Код шаблона example: template123 lang: type: string description: Код языка шаблона example: en required: - channel_id - code - lang WebhookEmptyResponse: description: Пустой ответ для событий webhook, не требующих ответа WebhookSendMessageResponseData: description: Данные ответа при отправке сообщения через webhook type: object properties: external_message_id: type: string description: Внешний идентификатор сообщения example: msg123 external_chat_id: type: string description: Внешний идентификатор чата example: chat456 external_customer_id: type: string description: Внешний идентификатор клиента example: cust789 error: $ref: '#/components/schemas/WebhookMessageSendingError' async: type: boolean description: Указывает, было ли сообщение отправлено асинхронно example: true required: - async WebhookTemplateCreateResponseData: description: Данные ответа на создание шаблона через вебхук type: object properties: code: type: string description: Код шаблона example: template123 required: - code WebhookMessageSendingError: description: Представляет ошибку, произошедшую при отправке сообщения type: object properties: code: $ref: '#/components/schemas/MessageErrorCode' message: type: string description: Сообщение об ошибке example: An error occurred while sending the message external_code: type: string description: Внешний код ошибки, если доступен example: ERR123 required: - code - message WebhookReactionItem: description: Представляет элемент реакции в вебхуке type: object properties: reaction: type: string WebhookUserData: type: object description: Представляет данные пользователя в вебхуке properties: id: description: Идентификатор пользователя example: 101 format: int64 type: integer first_name: description: Имя пользователя example: John type: string last_name: description: Фамилия пользователя example: Doe type: string avatar: description: URL аватара пользователя example: https://avatar.demo/user-avatar format: uri type: string required: - id - first_name - last_name - avatar WebhookBotData: type: object description: Представляет данные бота в вебхуке properties: id: description: Идентификатор бота example: 202 format: int64 type: integer name: description: Имя бота example: SupportBot type: string avatar: description: URL аватара бота example: https://avatar.demo/bot-avatar format: uri type: string required: - id - name - avatar WebhookCustomerData: type: object description: Представляет данные клиента в вебхуке properties: first_name: description: Имя клиента example: Jane type: string last_name: description: Фамилия клиента example: Smith type: string avatar: description: URL аватара клиента example: https://avatar.demo/customer-avatar format: uri type: string required: - first_name - last_name - avatar WebhookTemplateContent: type: object description: Представляет содержимое шаблона чата properties: name: description: Название шаблона example: Welcome Message type: string lang: description: Код языка шаблона example: en type: string category: description: Категория шаблона example: greetings type: string body: description: Содержимое тела шаблона example: Hello, {{name}}! Welcome to our service. type: string header: $ref: '#/components/schemas/TemplateHeader' footer: description: Содержимое футера шаблона example: Thank you for joining us! type: string buttons: $ref: '#/components/schemas/TemplateButtons' example: $ref: '#/components/schemas/TemplateExample' required: - name - lang - category - body WebhookTemplateInfo: description: Представляет информацию о шаблоне чата type: object properties: code: description: Код шаблона example: template123 type: string category: $ref: '#/components/schemas/WebhookTemplateCategory' args: description: Аргументы шаблона deprecated: true items: type: string type: array variables: allOf: - $ref: '#/components/schemas/WebhookTemplateArguments' WebhookTemplateArguments: description: Представляет аргументы шаблона type: object properties: header: $ref: '#/components/schemas/WebhookTemplateHeaderArguments' body: allOf: - $ref: '#/components/schemas/WebhookTemplateBodyArguments' buttons: description: Аргументы кнопки шаблона items: $ref: '#/components/schemas/WebhookTemplateButtonArguments' type: array WebhookTemplateHeaderArguments: description: Представляет аргументы для раздела заголовка шаблона type: object properties: type: description: Тип содержимого заголовка allOf: - $ref: '#/components/schemas/TemplateHeaderContentType' args: description: Аргументы для заголовка items: type: string type: array attachments: description: Вложения для заголовка items: $ref: '#/components/schemas/TemplateExampleAttachment' type: array required: - type WebhookTemplateBodyArguments: description: Представляет аргументы для основного раздела шаблона type: object properties: args: description: Аргументы для тела шаблона type: array items: type: string required: - args WebhookTemplateButtonArguments: description: Представляет аргументы для кнопки шаблона type: object properties: type: $ref: '#/components/schemas/TemplateButtonType' title: description: Заголовок кнопки example: Click Me type: string args: description: Аргументы для кнопки items: type: string type: array required: - type - title WebhookTemplateCategory: description: Категория шаблона type: string enum: - authentication - marketing - utility WebhookMessageFile: description: Прикреплённый файл сообщения type: object properties: id: description: UUID прикреплённого файла example: c425d178-eb6f-11ec-8ea0-0242ac120002 format: uuid type: string caption: description: Текстовое описание медиа-вложения example: demo caption type: string size: description: Размер вложения (в байтах) example: 34534 format: int type: integer height: description: Высота изображения в пикселях (только для сообщений с изображением) example: 1080 format: int type: integer width: description: Ширина изображения в пикселях (только для сообщений с изображениями) example: 1920 format: int type: integer MessageType: description: Тип сообщения type: string enum: - text - system - command - order - product - file - image - audio example: text Cost: description: Представляет денежную сумму с соответствующей валютой type: object properties: currency: description: Код валюты maxLength: 3 minLength: 3 type: string value: description: Числовое значение стоимости example: 256 format: double minimum: 0 type: number required: - currency - value MessageProduct: description: Описывает товар, упомянутый в сообщении type: object properties: id: description: Идентификатор товара example: 56 format: uint64 type: integer article: description: Описание товара example: 324-DFT-495 maxLength: 128 type: string cost: $ref: '#/components/schemas/Cost' img: description: URL изображения товара example: https://image.demo/demo-image format: uri maxLength: 2048 type: string name: type: string description: Название товара example: demo product maxLength: 255 minLength: 1 unit: description: Единицы измерения товара maxLength: 16 type: string url: description: URL товара example: https://product.demo/demo-product format: uri maxLength: 2048 type: string required: - id - name MessageOrderDelivery: description: Информация о доставке заказа type: object properties: address: description: Адрес доставки example: 2641 Webster St Berkeley, California(CA), 94705 type: string comment: description: Комментарий к доставке example: demo delivery comment type: string name: description: Название способа доставки example: dhl type: string price: $ref: '#/components/schemas/Cost' Quantity: description: Количество type: object properties: unit: description: Единицы измерения example: pcs maxLength: 16 type: string value: description: Количественное значение example: 5 format: double minimum: 0 type: number MessageOrderItem: description: Товар заказа type: object properties: external_id: description: Внешний идентификатор товара example: 45 format: int64 type: integer img: description: Изображение товара example: https://order-image.demo/demo-order-image format: uri maxLength: 2048 type: string name: description: Название товара example: demo order item maxLength: 255 type: string price: $ref: '#/components/schemas/Cost' quantity: allOf: - $ref: '#/components/schemas/Quantity' url: description: URL товара example: https://order-item.demo/demo-order-item format: uri maxLength: 2048 type: string MessageOrderPaymentStatus: description: Статус оплаты заказа type: object properties: name: description: Название оплаты example: demo-payment-status type: string payed: description: Индикатор выполнения оплаты example: true type: boolean MessageOrderPayment: description: Информация об оплате заказа type: object properties: amount: $ref: '#/components/schemas/Cost' name: description: Название оплаты example: paid type: string status: $ref: '#/components/schemas/MessageOrderPaymentStatus' MessageOrderStatusCode: description: Код статуса type: string enum: - new - approval - assembling - delivery - complete - cancel example: approval MessageOrderStatus: description: Статус заказа properties: code: allOf: - $ref: '#/components/schemas/MessageOrderStatusCode' name: description: Название статуса example: approval maxLength: 255 type: string MessageOrder: description: Представляет детали заказа в сообщении type: object properties: external_id: description: Внешний идентификатор заказа example: 56 format: int64 type: integer cost: $ref: '#/components/schemas/Cost' date: description: Дата создания заказа example: '2021-12-29T14:18:37.051393Z' format: date-time type: string delivery: $ref: '#/components/schemas/MessageOrderDelivery' discount: $ref: '#/components/schemas/Cost' items: description: Массив товаров заказа items: $ref: '#/components/schemas/MessageOrderItem' type: array number: description: Номер заказа example: '23546' maxLength: 255 type: string payments: description: Массив платежей items: $ref: '#/components/schemas/MessageOrderPayment' type: array status: $ref: '#/components/schemas/MessageOrderStatus' url: description: URL заказа example: https://url.demo/demo-url format: uri maxLength: 2048 type: string TemplateHeaderContentType: type: string description: Тип секции заголовка enum: - text - document - image - video example: text TemplateExampleAttachment: description: Пример вложения шаблона type: object properties: id: description: UID загруженного файла format: uuid type: string caption: description: Оригинальное имя файла maxLength: 1024 minLength: 1 type: string required: - id TemplateButtonType: description: Тип кнопки type: string enum: - plain - phone - url example: plain SuggestionType: type: string description: Тип быстрого ответа enum: - text - email - phone - url example: phone Suggestion: description: Предложение быстрого ответа type: object properties: payload: description: Данные быстрого ответа example: https://demo-payload.demo type: string title: description: Название быстрого ответа example: phone number type: string type: allOf: - $ref: '#/components/schemas/SuggestionType' MessageTransportAttachments: description: Транспортные вложения properties: suggestions: description: Быстрые ответы items: $ref: '#/components/schemas/Suggestion' type: array type: object TemplateHeaderContent: description: Содержимое заголовка шаблона type: object properties: type: $ref: '#/components/schemas/TemplateHeaderContentType' body: description: Текстовое содержимое секции заголовка (для типа контента `text`) type: string required: - type TemplateHeader: description: Секция заголовка шаблона type: object properties: content: allOf: - $ref: '#/components/schemas/TemplateHeaderContent' TemplateButton: description: Кнопка шаблона type: object properties: label: description: Название кнопки type: string type: $ref: '#/components/schemas/TemplateButtonType' phone: type: string description: Номер телефона (для типа кнопки `phone`) url: type: string format: uri description: URL (для типа кнопки `url`) required: - label - type TemplateButtons: description: Список кнопок шаблона type: object properties: items: type: array items: $ref: '#/components/schemas/TemplateButton' example: - label: Click me type: plain - label: Call us type: phone phone: '+1234567890' - label: Visit our website type: url url: https://example.com TemplateExample: description: Пример шаблона type: object properties: attachments: description: Вложения шаблона items: $ref: '#/components/schemas/TemplateExampleAttachment' maxLength: 1 type: array body: description: Массив примерных значений тела шаблона example: - Max - e3459 - '328' items: type: string type: array buttons: description: Массив примерных значений кнопок шаблона items: items: type: string type: array type: array header: description: Массив примерных значений для секции заголовка шаблона example: - Alex items: type: string type: array MessageErrorCode: description: Код ошибки сообщения type: string enum: - unknown - network_error - malformed_response - async_send_timeout - general - customer_not_exists - reply_timed_out - spam_suspicion - access_restricted example: malformed_response requestBodies: WebhookRequest: description: Тело запроса вебхука content: application/json: schema: $ref: '#/components/schemas/WebhookRequestData' required: true responses: WebhookResponse: description: Вернуть статус 200 для подтверждения успешного получения данных content: application/json: schema: oneOf: - $ref: '#/components/schemas/WebhookEmptyResponse' - $ref: '#/components/schemas/WebhookSendMessageResponseData' - $ref: '#/components/schemas/WebhookTemplateCreateResponseData'