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 (60 loc) · 5.42 KB

File metadata and controls

72 lines (60 loc) · 5.42 KB

Create User

Create a new workspace user.

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

{% hint style="info" %} Permission required: create-user {% endhint %}

Body Parameters

KeyExample ValueDescription
email*example@example.comThe email address for the user.
name*Example UserThe display name of the user.
password*pass@w0rdThe password for the user.
username*exampleThe username for the user.
activefalseWhether the user is active, which determines if they can login or not.
By default, the value is true.
bioEnginer|GitHub StarThe bio of the user.
nicknamelolaThe nickname of the user.
statusTextOn a vacationThe status text of the user.
roles["moderator", "user", "653fb63ba2f73c7460e18e90"]

The roles the user is assigned on creation. 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 when created. The default value is true.
requirePasswordChangetrueWhether the user be required to change their password when they login. The default value is false.
setRandomPasswordtrueSet random password for the user and send by email. If setRandomPassword is set to true, the password field can be left empty.
sendWelcomeEmailtrueWhether the user get a welcome email. The default value is false.
verifiedtrueWhether the user's email address be verified when created. The default value is false.
customFields{ twitter: '@example' }Any custom fields the user should have on their account. The default value is undefined.

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

{% code overflow="wrap" %}

curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
     -H "X-User-Id: aobEdbYhXfu5hkeqG" \
     -H "Content-type:application/json" \
     http://localhost:3000/api/v1/users.create \
     -d '{
          "name": "name", 
          "email": "email@user.tld", 
          "password": "anypassyouwant", 
          "username": "uniqueusername", 
          "roles":["bot","user"]}'

{% endcode %}

Example Response

{
   "user": {
      "_id": "BsNr28znDkG8aeo7W",
      "createdAt": "2016-09-13T14:57:56.037Z",
      "services": {
         "password": {
            "bcrypt": "$2a$i7BFS55uFYRf5TE4ErSUH8HymMNAbpMAvsOcl2C"
         }
      },
      "username": "uniqueusername",
      "emails": [
         {
            "address": "email@user.tld",
            "verified": false
         }
      ],
      "type": "user",
      "status": "offline",
      "active": true,
      "roles": [
         "user"
      ],
      "_updatedAt": "2016-09-13T14:57:56.175Z",
      "name": "name",
      "settings": {}
   },
   "success": true
}

Change Log

VersionDescription
0.48.0role property is now roles which is an array of strings for the roles to create the user with.
0.45.0Users created via this now join the default channels.
0.40.0Added