---
title: "Import, send and edit messages"
method: POST
path: "/{scope_id}"
---

# Import, send and edit messages

`POST /{scope_id}`

## Path parameters

- `scope_id` string, required

## Headers

- `Date` string, required
- `Content-type` string, required
- `Content-MD5` string
- `X-Signature` string

## Request body

- object
  - `RAW_BODY` object
    - `event_type` 'new_message' | 'edit_message' — Event type (`new_message` and `edit_message` are available)
    - `payload` object — An array contains the elements of the message.
      - `timestamp` integer, required — Message timestamp in Unix Timestamp format
      - `msec_timestamp` integer — Message timestamp in milliseconds
      - `msgid` string, required — Chat message ID on the integration side
      - `conversation_id` string — Chat ID on the integration side
      - `conversation_ref_id` string — Chat ID on Kommo side. It should be sent if the client responds to a message sent with “Write first” so the chat on your side is associated with the chat on the system.
      - `source` object — Message source.
        - `external_id` string — Chat source identifier on the integration side. The field length is 40 characters, you can use any printable ASCII characters and a space.
      - `sender` object — Message sender
        - `id` string, required — Chat participant ID on the integration side
        - `ref_id` string — Chat participant ID on the Chat API side
        - `name` string, required — Chat participant name
        - `avatar` string — Link to the chat participant’s avatar. The link must be available to third-party resources and provide an image for download
        - `profile_link` string — Link to the profile of the chat participant in a third-party chat system
        - `profile` object — Chat participant profile.
          - `phone` string — Phone number. When creating an incoming lead, the phone number will be added to the contact data
          - `email` string — Email address. When creating an incoming lead, the email address will be added to the contact data
      - `receiver` object — Message receiver
        - `id` string, required — Chat participant ID on the integration side
        - `ref_id` string — Chat participant ID on the Chat API side
        - `name` string, required — Chat participant name
        - `avatar` string — Link to the chat participant’s avatar. The link must be available to third-party resources and provide an image for download
        - `profile_link` string — Link to the profile of the chat participant in a third-party chat system
        - `profile` object — Chat participant profile.
          - `phone` string — Phone number. When creating an incoming lead, the phone number will be added to the contact data
          - `email` string — Email address. When creating an incoming lead, the email address will be added to the contact data
      - `message` object — An array contains the message components.
        - `type` 'text' | 'contact' | 'file' | 'video' | 'picture' | 'voice' | 'audio' | 'sticker' | 'location', required — Message type, one of the following: text, contact, file, video, picture, voice, audio, sticker, location
        - `text` string — The field is mandatory for the `text` type, can be empty for other types
        - `media` string — URL to the `file`, `video`, `picture`, `voice`, `audio`, or `sticker`. URL should be available for download. Optional field if the file does not change when editing the message.
        - `file_size` integer — The size of the file from the `media` field (optional)
        - `file_name` string — The name of the file from the `media` field URL, the field is optional. Ignored for the `voice` type. Optional field if the file does not change when editing the message.
        - `media_duration` integer — Optional. Duration for `video`/`audio`/`voice` messages
        - `contact` object — Mandatory fields for messages of type `contact` (contact information).
          - `name` string — Contact name
          - `phone` string — Contact phone
        - `location` object — Mandatory fields for messages of type `location` (geoposition)
          - `lon` number, float — Longitude
          - `lat` number, float — Latitude
        - `post` object — Optional field. Must be passed for comments.
          - `id` string, required — Unique post ID on the integration side
          - `url` string, required — Link to the post in the source
          - `preview_url` string — Link to preview if TTL links are limited. If preview_link is passed along with preview_permalink, preview_permalink will be used.
          - `preview_permalink	` string — Link to preview if the link is permanent. If preview_link is passed along with preview_permalink, preview_permalink will be used.
          - `username` string — The user who published the post
          - `caption` string — Post description
        - `delivery_status` object — Optional. Message delivery status object, can be passed both for `edit_message` and `new_message` types
          - `status_code` integer — Delivery status. Available statuses are described here: https://developers.kommo.com/reference/update-delivery-status
          - `error_сode` integer — Error type. Available error types are described here: https://es-developers.kommo.com/reference/actualizar-el-estado-de-entrega-del-mensaje
          - `error` string — Error text that will be displayed to the user.
        - `shared_post` object — Optional. Post shared by the user.
          - `url` string — Link to the post
          - `preview_link` string — Optional. Temporary link to the preview image. Used when the preview link is temporary and you need to download the image in Kommo.
          - `preview_permalink` string — Optional. Permanent link to the preview image. Used when the preview link is permanent and you don't need to upload the image to Kommo.
          - `type` 'post' — Post type. Currently, currently only `post` value is supported
          - `site_name` string — Optional. Post caption.
        - `sticker_id` string — Optional. A common identifier for the sticker being sent across all accounts.
        - `callback_data` string — Optional. Must be passed to WhatsApp List Messages for the bot to be launched correctly.
      - `silent` boolean — Defines whether to create an Incoming lead and send a notification for a message in your Kommo account. When editing a message, an Incoming lead is not created and no notification is sent.
      - `reply_to` object — The object of the embedded message. The message from a quote with a reply can only belong to the same chat as the message being sent.
        - `message` object — Required field. The object of the embedded message. A message from a quote with a reply can only belong to the same chat as the message being sent.
          - `id` string — The ID of the quoted message in the Chats API. If passed, the remaining fields do not need to be filled in, they will be determined automatically. In case of passing the ID, scrolling to the message will also work if the chat is in the same card.
          - `msgid` string — The ID of the quoted message on the integration side. If passed, the remaining fields do not need to be filled in, they will be determined automatically. In case of passing the ID, scrolling to the message will also work if the chat is in the same card.
          - `type` string — Mandatory if no ID is passed. Message type can be one of the following: text, contact, file, video, picture, voice, audio, sticker, location.
          - `text` string — Mandatory for the "text" type if no ID is passed. For other message types, this can be empty.
          - `file_name` string — Optional. File name
          - `file_size` integer — Optional. File size in bytes
          - `media_duration` integer — Optional. Duration for video/audio/voice messages
          - `location` object — Mandatory for location type messages if no ID is passed.
            - `lon` number, float — Longitude
            - `lat` number, float — Latitude
          - `sender` object
            - `id` string — Sender ID on the integration side, if passed, the remaining fields do not need to be filled in, they will be determined automatically.
            - `ref_id` string — Sender ID in the Chats API, if passed, the remaining fields do not need to be filled in, they will be determined automatically.
            - `name` string — Mandatory if no ID is passed. Sender name
      - `forwards` object — Optional. The object of the forwarded quote.
        - `messages` object[] — Mandatory. An array of embedded message objects. Currently, it is only possible to forward one message. Messages from a forwarded quote can belong to any external chat within the integration.
          - `id` string — The ID of the quoted message in the Chats API. If passed, the remaining fields do not need to be filled in, they will be determined automatically. In case of passing the ID, scrolling to the message will also work if the chat is in the same card.
          - `msgid` string — The ID of the quoted message on the integration side. If passed, the remaining fields do not need to be filled in, they will be determined automatically. In case of passing the ID, scrolling to the message will also work if the chat is in the same card.
          - `type` string — Mandatory if no ID is passed. Message type can be one of the following: text, contact, file, video, picture, voice, audio, sticker, location.
          - `text` string — Mandatory for the "text" type if no ID is passed. For other message types, this can be empty.
          - `file_name` string — Optional. File name
          - `file_size` integer — Optional. File name
          - `media_duration` integer — Optional. Duration for video/audio/voice messages
          - `location` object — Mandatory for location messages if an identifier is not provided.
            - `lon` number, float — Longtitude
            - `lat` number, float — Latitude
          - `contact` object — Mandatory for contact messages if ID is not provided.
            - `name` string — Mandatory. Contact name
            - `phone` string — Mandatory. Contact phone number
          - `sender` object — Mandatory if ID is not provided, message sender (short version).
            - `id` string — Sender ID on the integration side. If passed, the remaining fields are optional and will be defined automatically.
            - `ref_id` string — Sender ID on the Chats API side. If passed, the remaining fields are optional and will be defined automatically.
            - `name` string — Required if no ID is passed. Sender name
          - `timestamp` integer — Required if no ID is provided, message time, Unix timestamp.
          - `msec_timestamp` integer — Required if no ID is provided, message time in milliseconds.
        - `conversation_ref_id` string — Optional. Chat ID on the Chat API side. The chat must belong to the integration.
        - `conversation_id` string — Optional. Chat ID on the integration side.
      - `delivery_status` object — The object allows you to set the message delivery status when sending it. If no object is passed, status `sent` is set for the message. More information on the object params: https://developers.kommo.com/reference/update-delivery-status
        - `status_code` -1 | 1 | 2 — Message delivery status. Available statuses are described here: https://developers.kommo.com/reference/update-delivery-status#message-status-codes
        - `error_сode` 901 | 902 | 903 | 904 | 905 — Error type. Required only if `"status_code": -1`. Available types are described here: https://developers.kommo.com/reference/update-delivery-status#error-codes
        - `error` string — Error text that will be displayed in Kommo interface. Required only if `"status_code": -1` and `"error_code": 905"`

## Response `200`

200

- object
  - `new_message` object
    - `conversation_id` string
    - `sender_id` string
    - `receiver_id` string
    - `msgid` string
    - `ref_id` string

## Other responses

- `400` — 400
- `403` — 403

---

[API](https://skmtc.net/kommo/apis/kommo-api-references.md) · [All operations](https://skmtc.net/kommo/apis/kommo-api-references/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kommo/kommo-api-references/revisions/f17af4d23c7c/schema)
