> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quickblox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Message

> Update a dialog message.

#### Recipes

<AccordionGroup>
  <Accordion title="Mark messages as delivered">
    <Steps>
      <Step title="1. Specify if you want to mark messages as delivered">
        Set a `delivered` parameter to `1` to mark all messages as delivered.

        ```curl {5} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "delivered":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="2. Set the ID of the dialog">
        Set a `chat_dialog_id` to refer to a specific dialog.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "delivered":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="3. As a result, the API retuns a '200 OK' status code which implies that all messages of the specified dialog were marked as delivered.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "delivered":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Update message text">
    <Steps>
      <Step title="1. Type an updated message">
        Enter an updated message text using the `message` parameter.

        ```curl {5} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="2. Set the ID of the dialog">
        Set a `chat_dialog_id` to refer to a specific dialog.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="3. Set the ID of the message">
        Set the ID of the message to refer to a particular message.

        ```curl {8} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="4. As a result, the API returns '200 OK' status code which implies that the message was successfully updated.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Mark messages as read">
    <Steps>
      <Step title="1. Specify if you want to mark messages as read.">
        Set a `read` parameter to `1` to mark all messages as read.

        ```curl {5} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "read":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="2. Set the ID of the dialog.">
        Set the `chat_dialog_id` to refer to a specific dialog.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "read":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="3. As a result, the API retuns a '200 OK' status code which implies that all messages of the specified dialog were marked as read.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "read":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Mark messages as delivered with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "delivered":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="2. Use 'On-Behalf-Of' header to pass user id">
        To execute a request on behalf of a specific user

        ```curl {4} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "delivered":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="3. Specify if you want to mark messages as delivered">
        Set a `delivered` parameter to `1` to mark all messages as delivered.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "delivered":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="4. Set the ID of the dialog">
        Set a `chat_dialog_id` to refer to a specific dialog.

        ```curl {7} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "delivered":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="5. As a result, the API retuns a '200 OK' status code which implies that all messages of the specified dialog were marked as delivered.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "delivered":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Update message text with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="2. Use 'On-Behalf-Of' header to pass user id">
        To execute a request on behalf of a specific user

        ```curl {4} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="3. Type an updated message">
        Enter an updated message text using the `message` parameter.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="4. Set the ID of the dialog">
        Set a `chat_dialog_id` to refer to a specific dialog.

        ```curl {7} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="5. Set the ID of the message">
        Set the ID of the message to refer to a particular message.

        ```curl {9} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="6. As a result, the API returns '200 OK' status code which implies that the message was successfully updated.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "message":"updated message",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Mark messages as read with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "read":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="2. Use 'On-Behalf-Of' header to pass user id">
        To execute a request on behalf of a specific user.

        ```curl {4} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "read":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="3. Specify if you want to mark messages as read">
        Set a `read` parameter to `1` to mark all messages as read.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "read":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="4. Set the ID of the dialog.">
        Set the `chat_dialog_id` to refer to a specific dialog.

        ```curl {7} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "read":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>

      <Step title="5. As a result, the API retuns a '200 OK' status code which implies that all messages of the specified dialog were marked as read.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "read":"1",
          "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Mark all messages as read">
    <Steps>
      <Step title="1. Specify if you want to mark messages as read.">
        Set a `read` parameter to `1` to mark all messages as read.

        ```curl {5} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
            "read":"1",
            "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message.json
        ```
      </Step>

      <Step title="2. Set the ID of the dialog.">
        Set the `chat_dialog_id` to refer to a specific dialog.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
            "read":"1",
            "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message.json
        ```
      </Step>

      <Step title="3. Don't set any message ID to the path">
        To mark all messages of specified dialog as read keep the path without message ID

        ```curl {8} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
            "read":"1",
            "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message.json
        ```
      </Step>

      <Step title="4. As a result, the API retuns a '200 OK' status code which implies that all messages of the specified dialog were marked as read.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
            "read":"1",
            "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Mark all messages as delivered">
    <Steps>
      <Step title="1. Specify if you want to mark messages as delivered">
        Set a `delivered` parameter to `1` to mark all messages as delivered.

        ```curl {5} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
            "delivered":"1",
            "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message.json
        ```
      </Step>

      <Step title="2. Set the ID of the dialog">
        Set a `chat_dialog_id` to refer to a specific dialog.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
            "delivered":"1",
            "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message.json
        ```
      </Step>

      <Step title="3. Don't set any message ID to the path">
        To mark all messages of specified dialog as delivered keep the path without message ID

        ```curl {8} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
            "delivered":"1",
            "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message.json
        ```
      </Step>

      <Step title="4. As a result, the API retuns a '200 OK' status code which implies that all messages of the specified dialog were marked as delivered.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
            "delivered":"1",
            "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
        }' \
        https://api.quickblox.com/chat/Message.json
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

#### Path Parameters

<ParamField path="chat_message_id" type="string" requires> ID of the message. Generated automatically by the server after message creation. </ParamField>

#### Body Parameters

<ParamField body="read" type="integer"> Update a message status to read. Set `read=1` to perform. As a result, the user ID is added to the array of `read_ids` field. See the [Messages](/reference/chat#messages) model for more details. </ParamField>
<ParamField body="delivered" type="integer"> Update a message status to delivered. Set `delivered=1` to perform. As a result, the user ID is added to the array of `delivered_ids` field. See the [Messages](/reference/chat#messages) model for more details. </ParamField>
<ParamField body="message" type="string"> Update message's text. </ParamField>
<ParamField body="chat_dialog_id" type="string" required> ID of the dialog containing a message for update. </ParamField>

#### Headers

<ParamField header="QB-Token" type="string" required> A user or application session token. See [Authentication](/reference/authentication) page to learn more about session tokens. Must be used either QB-Token or Authorization. </ParamField>
<ParamField header="Authorization" type="string" default="ApiKey {your_api_key}"> API key from Dashboard. Expected format: `ApiKey {your_api_key}`. Must be used either QB-Token or Authorization.</ParamField>
<ParamField header="On-Behalf-Of" type="string">User ID. The user ID of the user on whose behalf the request is being made.</ParamField>

#### Responses

<AccordionGroup>
  <Accordion title="200">
    A successful response
  </Accordion>

  <Accordion title="403">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>

  <Accordion title="404">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT \
  -H "Content-Type: application/json" \
  -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
  -d '{  
    "read":"1",
    "chat_dialog_id":"53a99a7be4b094c7c6d31b41"
  }' \
  https://api.quickblox.com/chat/Message/53aabe15e4b077ddd43e7fd3.json
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  Empty body
  ```

  ```json 403 theme={null}
  {
    "errors": [
      "You don't have appropriate permissions to perform this operation"
    ]
  }
  ```

  ```json 404 theme={null}
  {
    "errors": [
      "The resource wasn't found"
    ]
  }
  ```
</ResponseExample>
