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

# Create Dialog

> Create a public/group/private dialog.

#### Recipes

<AccordionGroup>
  <Accordion title="Create private dialog">
    <Steps>
      <Step title="1. Set a private dialog type">
        Use a `type` parameter to set a dialog type. Set it to `3` to create a private dialog.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "type":3,
          "occupants_ids":"102433721"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="2. Set the ID of the opponent">
        Use an `occupants_ids` parameter to set the ID of the opponent who is going to participate in the dialog.

        ```{6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{
          "type":3,
          "occupants_ids":"102433721"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. As a result, the API returns a newly created private dialog.">
        ```
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{
          "type":3,
          "occupants_ids":"102433721"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create public dialog">
    <Steps>
      <Step title="1. Set a public dialog type">
        Use a `type` parameter to set a dialog type. Set it to `1` to create a public dialog.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="2. Set a name of the public dialog">
        Use a `name` parameter to set a name for the group dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set an avatar for the dialog">
        You can set an avatar for a public dialog. Just set the ID of the file in the `photo` field.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a newly created public dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create group dialog">
    <Steps>
      <Step title="1. Set a group dialog type">
        Set a `type` parameter to `2` to create a group dialog.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="2. Set a name of the group dialog">
        Use a `name` parameter to set a name for the group dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set IDs of opponents">
        Use an `occupants_ids` parameter to set a list of opponents IDs who are going to participate in the dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a newly created group dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create dialog with custom parameters">
    <Steps>
      <Step title="1. Set a type of the dialog">
        You can set a type of dialog using a `type` parameter. Here, a `group` dialog is created since the `type` is set to `2`.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{ 
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "data":{ 
              "class_name":"ScoreTable",
              "game_mode_name":"rainbow dash",
              "expert_mode":"3",
              "progress":"56",
          }
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="2. Set a name of the dialog">
        Use a name parameter to set a name for the group dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{ 
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "data":{ 
              "class_name":"ScoreTable",
              "game_mode_name":"rainbow dash",
              "expert_mode":"3",
              "progress":"56",
          }
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set IDs of opponents">
        Use an `occupants_ids` parameter to set a list of opponents IDs who are going to participate in the dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{ 
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "data":{ 
              "class_name":"ScoreTable",
              "game_mode_name":"rainbow dash",
              "expert_mode":"3",
              "progress":"56",
          }
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Use a `data` parameter to refer to a custom object that should be added">
        You need to refer to the specific custom object in the request. See [this section](/reference/create-class) to learn how to create a custom object class.

        The `data` stores a set of unique keys each having an associated value parameter.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{ 
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "data":{ 
              "class_name":"ScoreTable",
              "game_mode_name":"rainbow dash",
              "expert_mode":"3",
              "progress":"56",
          }
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. Set a name of the class">
        Here, we refer to the `ScoreTable` custom object class.

        ```curl {9} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{ 
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "data":{ 
              "class_name":"ScoreTable",
              "game_mode_name":"rainbow dash",
              "expert_mode":"3",
              "progress":"56",
          }
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="6. Set custom object fields">
        Here, we refer to custom object fields of the `ScoreTable` class.

        ```curl {10-12} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{ 
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "data":{ 
              "class_name":"ScoreTable",
              "game_mode_name":"rainbow dash",
              "expert_mode":"3",
              "progress":"56",
          }
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="7. As a result, the API returns a newly created dialog with the specified custom parameters.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{ 
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "data":{ 
              "class_name":"ScoreTable",
              "game_mode_name":"rainbow dash",
              "expert_mode":"3",
              "progress":"56",
          }
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create group dialog with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.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 POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set a group dialog type">
        Set a `type` parameter to `2` to create a group dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Set a name of the group dialog">
        Use a name parameter to set a name for the group dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. Set IDs of opponents">
        Use an `occupants_ids` parameter to set a list of opponents IDs who are going to participate in the dialog.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="6. As a result, the API returns a newly created group dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create private dialog with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":3,
          "occupants_ids":"102433721"
        }' \
        https://api.quickblox.com/chat/Dialog.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 POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":3,
          "occupants_ids":"102433721"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set a private dialog type">
        Use a `type` parameter to set a dialog type. Set it to `3` to create a private dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":3,
          "occupants_ids":"102433721"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Set the ID of the opponent">
        Use an `occupants_ids` parameter to set the ID of the opponent who is going to participate in the dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":3,
          "occupants_ids":"102433721"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. As a result, the API returns a newly created private dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":3,
          "occupants_ids":"102433721"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create public dialog with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.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 POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set a public dialog type">
        Use a `type` parameter to set a dialog type. Set it to `1` to create a public dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Set a name of the public dialog">
        Use a name parameter to set a name for the group dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. Set an avatar for the dialog">
        You can set an avatar for a public dialog. Just set the ID of the file in the photo field.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="6. As a result, the API returns a newly created public dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{  
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create group dialog with is_join_required parameter (added in v2.34.0)">
    <Steps>
      <Step title="1. Set dialog type">
        Use the `type` parameter to define the dialog type.
        `type=2` creates a GROUP dialog.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "is_join_required":0
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="2. Set dialog name">
        Use the `name` parameter to define the name of the group dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "is_join_required":0
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set occupants IDs">
        Use the `occupants_ids` parameter to define users who will participate in the dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "is_join_required":0
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Disable join requirement">
        Set `"is_join_required": 0` to allow users to send and receive messages via XMPP without performing a join operation.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "is_join_required":0
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. Result">
        The API returns a newly created group dialog with `is_join_required` set to `0`.

        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
        -d '{
          "type":2,
          "name":"Chat with Bob, Sam, Garry",
          "occupants_ids":"96754523,96830631,96831328",
          "is_join_required": 0
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create group dialog with admin IDs (added in v2.52.0)">
    <Steps>
      <Step title="1. Set a group dialog type">
        Set a `type` parameter to `2` to create a group dialog.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="2. Set a name of the group dialog">
        Use a `name` parameter to set a name for the group dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set IDs of opponents">
        Use an `occupants_ids` parameter to set a list of opponents IDs who are going to participate in the dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Set IDs of admins">
        Use the `admin_ids` parameter to set a list of admin IDs who will moderate the dialog.

        ```curl {9} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. As a result, the API returns a newly created group dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create public dialog with admin IDs (added in v2.52.0)">
    <Steps>
      <Step title="1. Set a public dialog type">
        Use a `type` parameter to set a dialog type. Set it to `1` to create a public dialog.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="2. Set a name of the public dialog">
        Use a `name` parameter to set a name for the group dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set an avatar for the dialog">
        You can set an avatar for a public dialog. Just set the ID of the file in the `photo` field.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Set IDs of admins">
        Use the `admin_ids` parameter to set a list of admin IDs who will moderate the dialog.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. As a result, the API returns a newly created public dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create group dialog with admin IDs using API key (added in v2.52.0)">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.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 POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set a group dialog type">
        Set a `type` parameter to `2` to create a group dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Set a name of the group dialog">
        Use a name parameter to set a name for the group dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. Set IDs of opponents">
        Use an `occupants_ids` parameter to set a list of opponents IDs who are going to participate in the dialog.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="6. Set IDs of admins">
        Use the `admin_ids` parameter to set a list of admin IDs who will moderate the dialog.

        ```curl {9} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="7. As a result, the API returns a newly created group dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":2,
          "name":"New Year party",
          "occupants_ids":"96831397,96831328,96830631,96754523",
          "photo":"68123"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create public dialog with admin IDs using API key (added in v2.52.0)">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.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 POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="3. Set a public dialog type">
        Use a `type` parameter to set a dialog type. Set it to `1` to create a public dialog.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="4. Set IDs of admins">
        Use the `admin_ids` parameter to set a list of admin IDs who will moderate the dialog.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834",
          "admin_ids":"96831397,96831328"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. Set a name of the public dialog">
        Use a name parameter to set a name for the group dialog.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="5. Set an avatar for the dialog">
        You can set an avatar for a public dialog. Just set the ID of the file in the photo field.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>

      <Step title="6. As a result, the API returns a newly created public dialog.">
        ```curl theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -H "On-Behalf-Of: 123" \
        -d '{
          "type":1,
          "name":"Soccer news",
          "photo":"67834"
        }' \
        https://api.quickblox.com/chat/Dialog.json
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

Use `type=1` (PUBLIC\_GROUP) to create a public dialog. All users from your application will be able to join it. The server will create a public chat and return a detailed information about the newly created dialog. Field `xmpp_room_jid` will contain a Chat room JID to which you should connect to start chatting.

Use `type=2` (GROUP) to create a group dialog only for specific users provided in `occupants_ids`. The server will create a group chat (involving only members of this chat) and return a detailed information about the newly created dialog. Field `xmpp_room_jids` will contain a Chat room JID to which you should connect to start chatting.

Use `type=3` (PRIVATE) to create a private dialog between 2 users. The server will return a detailed information about the newly created dialog. If a user sends a chat message to some user and the private dialog wasn't created, it will be created automatically with the first chat message.

**Custom parameters**

Dialogs can store additional parameters. These parameters can be used to store additional data. Also, these parameters can be used in dialogs retrieval requests.

To start using additional parameters, create an additional schema of your parameters. This is a custom objects class. Just create an empty class with all fields that you need. These fields will be your dialog's additional parameters.

Next, to set additional parameters to a dialog, use next additional parameters in a creation request:

`data[class_name]` - should contain **Custom Objects class** name created above.\
`data[...]`\
`data[{field_name_N}]` - field N from Custom Object class.

**Admin role overview** (added in v2.52.0)

* Admins are like occupants, but with elevated permissions.
* Only supported in **public** and **group** dialogs (`type: 1`, `type: 2`).
* Users in `admin_ids` must also be in `occupants_ids`(group dialog). If not — they will be automatically added.
* Ignored in **private** dialogs (`type: 3`).

*Permissions:*

* Rename the dialog
* Change the photo
* Edit and delete **any** messages
* Remove other occupants (except the owner)
* Remove themselves from `admin_ids`

#### Body Parameters

<ParamField body="type" type="integer" required>
  Type of a new dialog.

  Possible values are: <br />
  `1` - PUBLIC\_GROUP <br />
  `2` - GROUP <br />
  `3` - PRIVATE <br />
</ParamField>

<ParamField body="name" type="string"> Name of a new dialog.Ignored when `type=3` (PRIVATE).The maximum length is 200 symbols.</ParamField>
<ParamField body="photo" type="string"> Photo of a new dialog. </ParamField>
<ParamField body="occupants_ids" type="string"> IDs of dialog occupants (users who will be able to chat in this dialog). Don't need to pass current user ID, it will be added automatically. Can be a String or Array of Integers. </ParamField>

<ParamField body="admin_ids" type="string">
  IDs of users with admin permissions in the dialog. Ignored when `type=3` (PRIVATE). Admins can update the name and photo, edit or delete any messages, and
  manage occupants. (added in v2.52.0)
</ParamField>

<ParamField body="is_join_required" type="integer">
  Defines whether a user must perform a join operation before sending and receiving messages via XMPP. Applies only to `type=2` (GROUP).

  Possible values: <br />
  `0` - join not required, <br />
  `1` - join required. <br />

  Default for GROUP dialogs is `0` when the field is not provided. The default value can be configured in the Dashboard → Settings. <br />
  Ignored for `type=1` (PUBLIC\_GROUP) and `type=3` (PRIVATE) — if provided in the request, the value is not stored (added in v2.34.0).
</ParamField>

<ParamField body="data" type="object">
  <Expandable title="propetries">
    <ParamField body="class_name" type="string"> Class name in Custom Objects. </ParamField>
    <ParamField body="{class_field_N}" type="string"> Field name of class in Custom Objects. Can be many 1..N. </ParamField>
  </Expandable>
</ParamField>

#### Headers

<ParamField header="QB-Token" type="string" required>
  A user or application session token. See our [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="201">
    A successful response

    <ResponseField name="_id" type="string" />

    <ResponseField name="created_at" type="string" />

    <ResponseField name="last_message" type="string" />

    <ResponseField name="last_message_date_sent" type="integer" />

    <ResponseField name="last_message_id" type="string" />

    <ResponseField name="last_message_user_id" type="integer" />

    <ResponseField name="name" type="string" />

    <ResponseField name="occupants_ids" type="array of integers" />

    <ResponseField name="admin_ids" type="array of integers (added in v2.52.0)" />

    <ResponseField name="photo" type="string" />

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

    <ResponseField name="updated_at" type="string" />

    <ResponseField name="user_id" type="integer" />

    <ResponseField name="xmpp_room_jid" type="string" />

    <ResponseField name="unread_messages_count" type="string" />

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

  <Accordion title="400">
    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>

  <Accordion title="422">
    An error response

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

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
  -d '{  
    "type":3,
    "occupants_ids":"102433721"
  }' \
  https://api.quickblox.com/chat/Dialog.json
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "_id": "5e261c72a28f9a4f779f10bb",
    "created_at": "2020-01-20T21:32:34Z",
    "last_message": "Hello world",
    "last_message_date_sent": 1597748932,
    "last_message_id": "5f3bb6c4a28f9a69552944d1",
    "last_message_user_id": 102433734,
    "name": "Bob",
    "occupants_ids": [
      102433721,
      102433734
    ],
    "admin_ids": [],
    "photo": null,
    "type": 3,
    "updated_at": "2020-08-18T11:08:52Z",
    "user_id": 102433721,
    "xmpp_room_jid": null,
    "unread_messages_count": null,
    "is_join_required": null
  }
  ```

  ```json 400 theme={null}
  // Occupants_ids doesn't contain opponent ID
  {
    "errors": ["Occupants_ids is missing opponent ID."]
  }
  // Invalid admin_ids format (must be an array of int)
  {
    "errors": ["Incorrect format for parameter \"admin_ids\"."]
  }
  ```

  ```json 404 theme={null}
  {
    "errors": ["Users with these IDs for \"admin_ids\" do not exist."]
  }
  ```

  ```json 422 theme={null}
  {
    "type": ["is wrong."]
  }
  ```
</ResponseExample>
