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

> Update a user by ID. A user can be updated only by themselves or an account owner. You can use this request to update a user password. In this case, you need to pass the old password and new password to the update user request.

#### Recipes

<AccordionGroup>
  <Accordion title="Update user password">
    <Steps>
      <Step title="1. Use a `user` parameter to set a new password">
        ```curl {5} theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H "QB-Token: 7483d80bb9caddd504764d85b050c85755aecc84" \
        -d '{  
          "user":{
            "old_password":"myoldpassword!" \
            "password":"mynewpassword!"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="2. Set an old password">
        Use an `old_password` parameter to set an old password.

        ```curl {6} theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H "QB-Token: 7483d80bb9caddd504764d85b050c85755aecc84" \
        -d '{  
          "user":{
            "old_password":"myoldpassword!" \
            "password":"mynewpassword!"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="3. Set a new password">
        Use a `password` parameter to set a new password.

        ```curl {7} theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H "QB-Token: 7483d80bb9caddd504764d85b050c85755aecc84" \
        -d '{  
          "user":{
            "old_password":"myoldpassword!" \
            "password":"mynewpassword!"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a user with an updated password.">
        ```curl theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H "QB-Token: 7483d80bb9caddd504764d85b050c85755aecc84" \
        -d '{  
          "user":{
            "old_password":"myoldpassword!" \
            "password":"mynewpassword!"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Update user">
    <Steps>
      <Step title="1. Use a `user` parameter to update a user">
        ```curl {5} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: 7483d80bb9caddd504764d85b050c85755aecc84" \
        -d '{  
          "user":{  
            "login":"Jen_Lesser",
            "email":"jen_lesser@gmail.com",
            "external_user_id":"1433712",
            "facebook_id":"125553",
            "full_name":"Jen Lesser",
            "phone":"+965234215",
            "website":"https://jen.com",
            "tag_list":"android,web",
            "custom_data":"Head of marketing"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="2. Set new values for the fields">
        You can update any field of the user.

        ```curl {6-14} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: 7483d80bb9caddd504764d85b050c85755aecc84" \
        -d '{  
          "user":{  
            "login":"Jen_Lesser",
            "email":"jen_lesser@gmail.com",
            "external_user_id":"1433712",
            "facebook_id":"125553",
            "full_name":"Jen Lesser",
            "phone":"+965234215",
            "website":"https://jen.com",
            "tag_list":"android,web",
            "custom_data":"Head of marketing"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="3. As a result, the API returns a user with the specified updated fields.">
        ```curl theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: 7483d80bb9caddd504764d85b050c85755aecc84" \
        -d '{  
          "user":{  
            "login":"Jen_Lesser",
            "email":"jen_lesser@gmail.com",
            "external_user_id":"1433712",
            "facebook_id":"125553",
            "full_name":"Jen Lesser",
            "phone":"+965234215",
            "website":"https://jen.com",
            "tag_list":"android,web",
            "custom_data":"Head of marketing"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Update user 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' \
        -d '{  
          "user":{
            "login":"Jen_Lesser",
            "email":"jen_lesser@gmail.com",
            "external_user_id":"1433712",
            "facebook_id":"125553",
            "full_name":"Jen Lesser",
            "phone":"+965234215",
            "website":"https://jen.com",
            "tag_list":"android,web",
            "custom_data":"Head of marketing"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="2. Use a `user` parameter to update a user">
        ```curl {5} theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{  
          "user":{
            "login":"Jen_Lesser",
            "email":"jen_lesser@gmail.com",
            "external_user_id":"1433712",
            "facebook_id":"125553",
            "full_name":"Jen Lesser",
            "phone":"+965234215",
            "website":"https://jen.com",
            "tag_list":"android,web",
            "custom_data":"Head of marketing"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="3. Set new values for the fields">
        You can update any field of the user.

        ```curl {6-14} theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{  
          "user":{
            "login":"Jen_Lesser",
            "email":"jen_lesser@gmail.com",
            "external_user_id":"1433712",
            "facebook_id":"125553",
            "full_name":"Jen Lesser",
            "phone":"+965234215",
            "website":"https://jen.com",
            "tag_list":"android,web",
            "custom_data":"Head of marketing"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a user with the specified updated fields.">
        ```curl theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{  
          "user":{
            "login":"Jen_Lesser",
            "email":"jen_lesser@gmail.com",
            "external_user_id":"1433712",
            "facebook_id":"125553",
            "full_name":"Jen Lesser",
            "phone":"+965234215",
            "website":"https://jen.com",
            "tag_list":"android,web",
            "custom_data":"Head of marketing"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Update user password 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' \
        -d '{  
          "user":{
            "password":"newpasswordforuser!"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="2. Use a `user` parameter to set a new password">
        ```curl {5} theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{  
          "user":{
            "password":"newpasswordforuser!"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="3. Set a new password">
        Use a `password` parameter to set a new password for the specified user

        ```curl {6} theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{  
          "user":{
            "password":"newpasswordforuser!"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a user with an updated password.">
        ```curl theme={null}
        curl -X PUT\
        -H "Content-Type: application/json" \
        -H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
        -d '{  
          "user":{
            "password":"newpasswordforuser!"
          }
        }' \
        https://api.quickblox.com/users/96831397.json
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

#### Path Parameters

<ParamField path="user_id" type="integer" required> ID of the user. Generated automatically by the server after user creation.</ParamField>

#### Body Parameters

<ParamField body="user" type="object" required>
  <Expandable title="User object 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 session token. See [Authentication](/reference/authentication) page to learn more about the session token. </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="200">
    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="twitter_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="403">
    An error response

    <ResponseField name="errors" type="object">
      <Expandable title="properties">
        <ResponseField name="base" type="array of strings" />
      </Expandable>
    </ResponseField>
  </Accordion>

  <Accordion title="422">
    An error response

    <ResponseField name="errors" type="object">
      <Expandable title="properties">
        <ResponseField name="base" type="array of strings" />

        <ResponseField name="email" type="array of strings" />

        <ResponseField name="login" type="array of strings" />

        <ResponseField name="facebook_id" type="array of strings" />

        <ResponseField name="twitter_id" type="array of strings" />

        <ResponseField name="tag" type="array of strings" />

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

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT \
  -H "Content-Type: application/json" \
  -H "QB-Token: 7483d80bb9caddd504764d85b050c85755aecc84" \
  -d '{  
    "user":{  
      "login":"Jen_Lesser",
      "email":"jen_lesser@gmail.com",
      "external_user_id":"1433712",
      "facebook_id":"125553",
      "full_name":"Jen Lesser",
      "phone":"+965234215",
      "website":"https://jen.com",
      "tag_list":"android,web",
      "custom_data":"Head of marketing"
    }
  }' \
  https://api.quickblox.com/users/96831397.json
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "user": {
      "id": 96831397,
      "full_name": "Jen Lesser",
      "email": "jen_lesser@gmail.com",
      "login": "Jen_Lesser",
      "phone": "+965234215",
      "website": "https://jen.com",
      "created_at": "2019-08-29T19:15:17Z",
      "updated_at": "2019-09-01T14:03:58Z",
      "last_request_at": "2019-09-01T14:02:54Z",
      "external_user_id": 1433712,
      "facebook_id": "125553",
      "twitter_id": "998800",
      "blob_id": null,
      "custom_data": "Head of marketing",
      "age_over16": true,
      "allow_statistics_analysis": false,
      "allow_sales_activities": false,
      "parents_contacts": "",
      "user_tags": "android,web"
    }
  }
  ```

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

  ```json 403 theme={null}
  {
    "errors": {
      "base": [
        "You are not owner of this object"
      ]
    }
  }
  ```

  ```json 422 theme={null}
  // Validation errors
  {
    "errors": {
      "email": [
        "has already been taken."
      ],
      "login": [
        "has already been taken"
      ],
      "facebook_id": [
        "has already been taken"
      ],
      "twitter_id": [
        "has already been taken"
      ],
      "tag": [
        "length should between 3..15 symbols",
        "should contain alphanumeric characters and start with a letter"
      ],
      "phone": [
        "is not a number"
      ]
    }
  }

  // Incorrect old password
  {
    "errors": {
      "base": [
        "Incorrect old password provided"
      ]
    }
  }
  ```
</ResponseExample>
