> ## 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.

# Get Unread Messages Count

> Retrieve an unread count of your chat messages, split across dialogs or just a total value.

#### Recipes

<AccordionGroup>
  <Accordion title="Display total number of unread messages for each dialog">
    <Steps>
      <Step title="1. Set dialogs IDs.">
        Specify as many dialogs IDs as you need via comma.

        ```curl {3} theme={null}
        curl -X GET \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d "chat_dialog_ids=5d753421a28f9a2596cb0f98,5d75393ba28f9a17e1cb0f9e,5d75327ba28f9a0f32cb0f99,5d7539bca28f9a2cb3cb0f99" \
        https://api.quickblox.com/chat/Message/unread.json
        ```
      </Step>

      <Step title="2. As a result, the API returns a number of unread messages for each specified dialog.">
        ```curl theme={null}
        curl -X GET \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d "chat_dialog_ids=5d753421a28f9a2596cb0f98,5d75393ba28f9a17e1cb0f9e,5d75327ba28f9a0f32cb0f99,5d7539bca28f9a2cb3cb0f99" \
        https://api.quickblox.com/chat/Message/unread.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Display total number of unread messages for each dialog with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {2} theme={null}
        curl -X GET \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d "chat_dialog_ids=5d753421a28f9a2596cb0f98,5d75393ba28f9a17e1cb0f9e,5d75327ba28f9a0f32cb0f99,5d7539bca28f9a2cb3cb0f99" \
        https://api.quickblox.com/chat/Message/unread.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 {3} theme={null}
        curl -X GET \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d "chat_dialog_ids=5d753421a28f9a2596cb0f98,5d75393ba28f9a17e1cb0f9e,5d75327ba28f9a0f32cb0f99,5d7539bca28f9a2cb3cb0f99" \
        https://api.quickblox.com/chat/Message/unread.json
        ```
      </Step>

      <Step title="3. Set dialogs IDs">
        Specify as many dialogs IDs as you need via comma.

        ```curl {4} theme={null}
        curl -X GET \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d "chat_dialog_ids=5d753421a28f9a2596cb0f98,5d75393ba28f9a17e1cb0f9e,5d75327ba28f9a0f32cb0f99,5d7539bca28f9a2cb3cb0f99" \
        https://api.quickblox.com/chat/Message/unread.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a number of unread messages for each specified dialog.">
        ```curl theme={null}
        curl -X GET \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d "chat_dialog_ids=5d753421a28f9a2596cb0f98,5d75393ba28f9a17e1cb0f9e,5d75327ba28f9a0f32cb0f99,5d7539bca28f9a2cb3cb0f99" \
        https://api.quickblox.com/chat/Message/unread.json
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

#### Query Parameters

<ParamField query="chat_dialog_ids" type="string" requires>Array of dialogs IDs to get a count of unread messages for. You also can omit this parameter to receive just a total count of all unread messages.</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

    <ResponseField name="total" type="integer" />
  </Accordion>

  <Accordion title="404">
    An error response

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

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET \
  -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
  https://api.quickblox.com/chat/Message/unread.json
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "total": 15
  }
  ```

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