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

> Creates a new user.

#### Recipes

<AccordionGroup>
  <Accordion title="Create user 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' \
        -d '{
            "user": {
              "login": "johndoe",
              "password":"quickblox",
              "full_name": "John Doe"
            }
        }' \
        https://api.quickblox.com/users.json
        ```
      </Step>

      <Step title="2. Use a `user` parameter to create a new user">
        ```curl {5} theme={null}
        curl -X POST \
        -H 'Content-Type: application/json' \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{
            "user": {
              "login": "johndoe",
              "password":"quickblox",
              "full_name": "John Doe"
            }
        }' \
        https://api.quickblox.com/users.json
        ```
      </Step>

      <Step title="3. Set values for the fields">
        ```curl {6-8} theme={null}
        curl -X POST \
        -H 'Content-Type: application/json' \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{
            "user": {
              "login": "johndoe",
              "password":"quickblox",
              "full_name": "John Doe"
            }
        }' \
        https://api.quickblox.com/users.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a created user">
        ```curl theme={null}
        curl -X POST \
        -H 'Content-Type: application/json' \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{
            "user": {
              "login": "johndoe",
              "password":"quickblox",
              "full_name": "John Doe"
            }
        }' \
        https://api.quickblox.com/users.json
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

<Info>
  Trailing whitespaces in string data (except for the password) will be trimmed.
</Info>

The request can contain all, some or none of the optional parameters. Login, email, Facebook ID, and the external user ID should not be taken previously.

If you want to create a user with some content (for example, with an avatar) you have to create a blob first. The blob is the entity that is a file in a system. To learn how to create a blob, review [this section](/reference/create-file).

You can assign tags to the user. The same tags can be used for any number of users.

#### Body Parameters

<ParamField body="user" type="object" required>
  <Expandable title="properties">
    <ParamField body="login" type="string" required> User login. Must be **unique**. Only **one** required: `login` or `email`. </ParamField>
    <ParamField body="email" type="string" required> User e-mail. Must be **unique**. Only **one** required: `login` or `email`. </ParamField>
    <ParamField body="password" type="string" required> User password. </ParamField>
    <ParamField body="blob_id" type="integer"> ID of the file/blob. Generated automatically by the server after file/blob creation (for example, user photo). </ParamField>
    <ParamField body="external_user_id" type="integer"> ID of the user in the external system (<Tooltip tip="External User ID- a unique identifier of the user in the integrated external system; used for cross- referencing. For example, a user has an internal user ID within the QuickBlox system and external ID, provided by the integrated external (client) system. When an API call with reference to the user has to be submitted, the user can be referenced by either internal or external identifiers.">External User ID</Tooltip>.). Must be **unique**. </ParamField>
    <ParamField body="facebook_id" type="string"> ID of the user's Facebook account. Must be **unique**. </ParamField>
    <ParamField body="full_name" type="string"> User's full name. </ParamField>
    <ParamField body="phone" type="string"> User's phone. </ParamField>
    <ParamField body="website" type="string"> User's website. </ParamField>
    <ParamField body="custom_data" type="string"> User's additional info. </ParamField>
    <ParamField body="tag_list" type="string"> User tags. </ParamField>
    <ParamField body="allow_sales_activities" type="boolean" deprecated> ~~Marketing info.~~ </ParamField>
    <ParamField body="allow_statistics_analysis" type="boolean" deprecated> ~~Marketing info.~~ </ParamField>
    <ParamField body="age_over16" type="boolean" deprecated> ~~GDPR info.~~ </ParamField>
    <ParamField body="parents_contacts" type="string" deprecated> ~~GDPR info.~~</ParamField>
  </Expandable>
</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" required default="ApiKey {your_api_key}"> API key from Dashboard. Expected format: `ApiKey {your_api_key}`. Must be used either QB-Token or Authorization.</ParamField>

#### Responses

<AccordionGroup>
  <Accordion title="201">
    A successful response

    <ResponseField name="user" type="object">
      <Expandable title="properties">
        <ResponseField name="id" type="integer" />

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

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

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

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

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

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

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

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

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

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

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

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

        <ResponseField name="age_over16" type="boolean" />

        <ResponseField name="allow_statistics_analysis" type="boolean" />

        <ResponseField name="allow_sales_activities" type="boolean" />

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

        <ResponseField name="user_tags" type="string" />
      </Expandable>
    </ResponseField>
  </Accordion>

  <Accordion title="400">
    An error response

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

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

  <Accordion title="422">
    An error response

    <ResponseField name="errors" type="object">
      <Expandable title="properties">
        <ResponseField name="full_name" type="array of strings"> Errors related to full name </ResponseField>
        <ResponseField name="email" type="array of strings"> Errors related to email </ResponseField>
        <ResponseField name="login" type="array of strings"> Errors related to login </ResponseField>
        <ResponseField name="password" type="array of strings"> Errors related to password </ResponseField>
        <ResponseField name="facebook_id" type="array of strings"> Errors related to Facebook ID </ResponseField>
        <ResponseField name="external_user_id" type="array of strings"> Errors related to external user ID </ResponseField>
        <ResponseField name="phone" type="array of strings"> Errors related to phone number </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \
  -d '{  
    "user":{  
      "login":"Peter",
      "password":"!Peter009",
      "email":"peter@gmail.com",
      "external_user_id":1236672,
      "facebook_id":"8887366",
      "full_name":"Peter Smith",
      "phone":"+73123555",
      "website":"https://mysite.com",
      "tag_list":"marketing,seo",
      "custom_data":"lead of marketing team"
    }
  }' \
  https://api.quickblox.com/users.json
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "user": {
      "id": 96752798,
      "full_name": "Peter Smith",
      "email": "peter@gmail.com",
      "login": "Peter",
      "phone": "+73123555",
      "website": "https://mysite.com",
      "created_at": "2019-08-27T20:19:08Z",
      "updated_at": "2019-08-27T20:19:08Z",
      "last_request_at": null,
      "external_user_id": 1236672,
      "facebook_id": "8887366",
      "blob_id": null,
      "custom_data": "lead of marketing team",
      "age_over16": false,
      "allow_statistics_analysis": false,
      "allow_sales_activities": false,
      "parents_contacts": "",
      "user_tags": "marketing,seo"
    }
  }
  ```

  ```json 400 theme={null}
  {
    "code": null,
    "message": "No data was provided"
  }
  ```

  ```json 422 theme={null}
  {
    "errors": {
      "full_name": [
        "is invalid",
        "is too long (maximum is 200 characters)"
      ],
      "email": [
        "should look like an email address"
      ],
      "login": [
        "has already been taken"
      ],
      "password": [
        "is too short (minimum is 8 characters)"
      ],
      "facebook_id": [
        "should be hexadecimal or decimal number"
      ],
      "external_user_id": [
        "must be less than 4 bytes"
      ],
      "phone": [
        "is not a number"
      ]
    }
  }
  ```
</ResponseExample>
