HTTP Method | URL | Requires Auth |
---|---|---|
POST | /api/v1/users.update | yes |
{% hint style="info" %}
- To update the password for the user,
edit-other-user-password
permission must be set using an administrator account (Administration > Permissions). - This endpoint requires 2FA with your password. Refer to #call-an-endpoint-with-2fa {% endhint %}
Argument | Example | Description |
---|---|---|
userId * | BsNr28znDkG8aeo7W | The user ID to update. |
data * | "data" : {} | The object that includes the user information to update with the following parameters. Note: If you provide an empty object, the user details are returned. |
email | example@example.com | The email address for the user. |
name | Example User | The display name of the user. |
password | pass@w0rd | The password for the user. |
username | example | The username for the user. |
active | false | Whether the user is active, which determines if they can login or not. |
roles | ["moderator", "user", "653fb63ba2f73c7460e18e90"] | The roles the user has been assigned. The default value is
Refer to Roles for more information. |
joinDefaultChannels | false | Whether the user should join the default channels. |
requirePasswordChange | true | Whether the user should be required to change their password when they login. |
sendWelcomeEmail | true | Whether the user should get a welcome email. |
verified | true | Whether the user's email address should be verified. |
customFields | { twitter: '@example' } | Any custom fields the user should have on their account. |
{% hint style="info" %}
- To save
customFields
, you must first define the custom fields in the admin panel (Administration > Settings > Accounts > Registration > Custom Fields). For details on how to configure this field, see Custom Fields. - For information on how to view the custom fields, see the Get Users List endpoint. {% endhint %}
curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
-H "Content-type:application/json" \
http://localhost:3000/api/v1/users.update \
-d '{"userId": "BsNr28znDkG8aeo7W",
"data": {
"name": "new name",
"email": "newemail@user.tld" }}'
{
"user":{
"_id": "BsNr28znDkG8aeo7W",
"createdAt": "2016-09-13T14:57:56.037Z",
"services": {
"password": {
"bcrypt": "$2a$10$5I5nUzqNEs8jKhi7BFS55uFYRf5TE4ErSUH8HymMNAbpMAvsOcl2C"
}
},
"username": "uniqueusername",
"emails": [
{
"address": "newemail@user.tld",
"verified": false
}
],
"type": "user",
"status": "offline",
"active": true,
"roles": [
"user"
],
"_updatedAt": "2016-09-13T14:57:56.175Z",
"name": "new name",
"customFields": {
"twitter": "userstwitter"
}
},
"success": true
}
Version | Description |
---|---|
0.48.0 | Renamed to users.update |
0.35.0 | Added as user.update |