Update message delivery status

Method

POST https://amojo.kommo.com/v2/origin/custom/{scope_id}/{msgid}/delivery_status

Description

The method allows you to update the delivery status of a specific message.

Headers & Authorization type

The request headers are the same as the ones for all Chat API requests. Information about them is explained in details in the connect a chat channel page.

Header Description
Date Date and time when the request was generated.
Content-type Request data type.
Content-MD5 For the request body
X-Signature Signature of the request as a string.

Example of the body

{
    "msgid": "3419eef6-2aa3-464c-b6e4-4386d0f8f3ca",
    "delivery_status": -1,
    "error_code": 905,
    "error": "Message is not the last one"
}

Body parameters

Parameter Data type Description
msgid string Message ID on Kommo side. Must match the msgid in the method URL
delivery_status int Delivery status. Available statuses are described below
error_code int Error type. Available types are described below. Don’t send in case of status not error.
error string Error text. Will be displayed to the user. Don’t send in case of status not error.

Note: You should write the body in your request exactly the same as written when calculating the headers.

Message status
Status When status should be used Enum status value
Sent The message was sent from Kommo
Delivered The message was delivered to destination 1
Read Message was read by recipient 2
Error Message was not delivered -1
Error codes
Error code When should the code be sent?
901 The user has deleted the message
902 Integration disabled on channel side
903 Internal server error
904 Unable to create a conversation (For example, the user is not registered in WhatsApp)
905 Any other, along with this error code, you must send the error text

Example in PHP

$secret = 'fb50586ff7b68cd831fe0ef356345903f644c0d2';
$method = 'POST';
$contentType = 'application/json';
$date =  "Wed, 07 Dec 2022 16:00:00 +0000";
$path = '/v2/origin/custom/f62a0162-46a7-430e-b06c-0ef798d56b21_52fd2a28-d2eb-4bd8-b862-b57934927b38/44c8ca9a-c64b-42ec-9d55-8104df503345/delivery_status';

$url = "https://amojo.kommo.com" . $path;

$body = [
   'msgid' => '3419eef6-2aa3-464c-b6e4-4386d0f8f3ca',
   'delivery_status' => 2
];

$requestBody = json_encode($body);

$checkSum = md5($requestBody);

$str = implode("\n", [
    strtoupper($method),
    $checkSum,
    $contentType,
    $date,
    $path,
]);

$signature = hash_hmac('sha1', $str, $secret);

$headers = [
    'Date' => $date,
    'Content-Type' => $contentType,
    'Content-MD5' => strtolower($checkSum),
    'X-Signature' => strtolower($signature),
];

$curlHeaders = [];
foreach ($headers as $name => $value) {
    $curlHeaders[] = $name . ": " . $value;
}

echo $method . ' ' . $url . PHP_EOL;
foreach ($curlHeaders as $header) {
    echo $header . PHP_EOL;
}
echo PHP_EOL . $requestBody . PHP_EOL;

Example of the cURL request

curl --location --request POST 'https://amojo.kommo.com/v2/origin/custom/f62a0162-46a7-430e-b06c-0ef798d56b21_52fd2a28-d2eb-4bd8-b862-a67934927b38/3419eef6-2aa3-464c-b6e4-4386d0f8f3ca/delivery_status' \
--header 'Content-Type: application/json' \
--header 'Date: Mon, 12 Dec 2022 10:30:00 +0000' \
--header 'Content-MD5: b78f5baf6b4a03e53ff0fdb137f89f38' \
--header 'X-Signature: 05ac9b8f4f78dd3bc8aebf85a489b2d93bec8fcd' \
--header 'Cookie: session_id=djr98niasqivr1hg2ap2g8sh5p' \
--data-raw '{"msgid":"3419eef6-2aa3-464c-b6e4-4386d0f8f3ca","delivery_status":2}'

Data type header when the request is successful

Content-Type: application/json

Data type header in case of an error

Content-Type: application/json

HTTP Response Codes

Response code Condition
200 Status updated successfully
404 Message does not exist
403 Request signature is incorrect
400 Incorrect data transmitted. Details are available in the response body

Response

This method doesn’t return output.

Examples about the results

Body to change message delivery status to Read

{
    "msgid": "3419eef6-2aa3-464c-b6e4-4386d0f8f3ca",
    "delivery_status": 2
}

status read
Body to change message delivery status to Error

{
    "msgid": "3419eef6-2aa3-464c-b6e4-4386d0f8f3ca",
    "delivery_status": -1,
    "error_code": 905,
    "error": "Message is not the last one"
}

status error

Next, let’s discuss how to show if the client is typing.