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

# Delete Dialog

> Delete a chat dialog.

#### Recipes

<AccordionGroup>
  <Accordion title="Delete dialogs from your own chat history">
    <Steps>
      <Step title="1. Set dialogs IDs that should be removed">
        Specify as many `dialogs IDs` as you need via comma.

        ```curl {4} theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>

      <Step title="2. As a result, the dialogs will be removed for a user who has sent the request, not for all dialog participants.">
        ```curl theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Delete dialogs from all chat histories">
    <Steps>
      <Step title="1. Specify if you want to delete dialogs for all dialog participants">
        You can delete dialogs from the histories of all dialog participants. Just set the `force=1` and dialogs will be removed for all users participating in the dialog.

        ```curl {4} theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d "force=1" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>

      <Step title="2. Set dialogs IDs that should be removed">
        Specify as many dialogs IDs as you need via comma.

        ```curl {5} theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d "force=1" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>

      <Step title="3. As a result, the API will return the `SuccessfullyDeleted` response.">
        If you're not the owner of the dialog, the API will return the following message: "WrongPermissions". This means that a user doesn't have permissions to delete dialogs from all users' histories.

        ```curl theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d "force=1" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Delete dialogs from specific user chat history with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.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 DELETE \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>

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

        ```curl {5} theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>

      <Step title="4. As a result, the dialogs will be removed for a user who has sent the request, not for all dialog participants.">
        ```curl theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Delete dialogs with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.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 DELETE \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>

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

        ```curl theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>

      <Step title="4. As a result, the dialogs will be removed for all dialog participants.">
        ```curl theme={null}
        curl -X DELETE \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        https://api.quickblox.com/chat/Dialog/5d75626ea28f9a1490cb0f98,5d7562d4a28f9a1694cb0f9b,5d7562d4a2123a1694cb0f9b.json
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

Each user from a dialog’s `occupant_ids` field can remove the dialog. It does not mean that this dialog will be removed completely for all users in this dialog. It will be removed only for a current user.

To completely remove a dialog, pass `force=1`. Only the **owner** can do it.

#### Path Parameters

<ParamField path="chat_dialog_id" type="string" required> ID of the dialog to which a current message is connected. Generated automatically by the server after message creation</ParamField>

#### Body Parameters

<ParamField body="force" type="integer">Delete a dialog for everyone. Set `force=1` to perform. Only the owner can do it. </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="type" type="array of strings" />
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE \
  -H "Content-Type: application/json" \
  -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
  https://api.quickblox.com/chat/Dialog/53aabe15e4b077ddd43e7fd6.json
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  // Delete Dialog (one)
  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>
