Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Latest commit

 

History

History
72 lines (61 loc) · 4.92 KB

File metadata and controls

72 lines (61 loc) · 4.92 KB

Update User

HTTP MethodURLRequires Auth
POST/api/v1/users.updateyes

{% 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 %}

Body Parameters

ArgumentExampleDescription
userId*BsNr28znDkG8aeo7WThe 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.
emailexample@example.comThe email address for the user.
nameExample UserThe display name of the user.
passwordpass@w0rdThe password for the user.
usernameexampleThe username for the user.
activefalseWhether 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 user.


Note:

  • For default roles, the role name and ID are the same. For custom roles, the name and ID are different.
  • If you are setting a custom role for a user, make sure to enter the custom role ID, and not the role name.

Refer to Roles for more information.

joinDefaultChannelsfalseWhether the user should join the default channels.
requirePasswordChangetrueWhether the user should be required to change their password when they login.
sendWelcomeEmailtrueWhether the user should get a welcome email.
verifiedtrueWhether 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 %}

Example Call

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" }}'

Example Response

{
   "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
}

Change Log

Version Description
0.48.0 Renamed to users.update
0.35.0 Added as user.update