Create a new user in your workspace. This endpoint is typically used by admins to create user accounts in the workspace.
Permissions required:
create-user
: Permission to create usersedit-other-user-active-status
: Permission to enable or disable other accounts
Changelog
Version | Description |
---|---|
0.48.0 | role property is now roles which is an array of strings for the roles to create the user with. |
0.45.0 | Users created via this now join the default channels. |
0.40.0 | Added |
The authenticated user ID.
The authenticated user token.
The display name of the user.
The password for the user.
The username for the user.
Set the users' active status. If the user is deactivated, they can not login. By default, the user is active.
The nickname for the user.
The bio for the user.
Select whether users should automatically join default channels once they are created. By default, it is set to true
.
The status text of the user.
The roles to be assigned to this user. If it is not specified, the user
role is assigned by default.
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.
Should the user be required to change their password when they login? It is set to false
by default
Should the user be assigned a random password once they are created? It is set to false
by defualt.
Should the user get a welcome email? It is set to true
by default.
Should the user's email address be verified when created? It is set to false
by default.
A valid JSON object of key-value pairs consisting of additional fields to be
added during user registration. By default, the value is undefined
.
To save custom fields, you must first define them in the workspace admin settings.
For information on how to view the custom fields, see the Get Users List endpoint.
OK
{
"user": {
"_id": "BsNr28znDkG8aeo7W",
"createdAt": "2016-09-13T14:57:56.037Z",
"services": {
"password": {
"bcrypt": "$2a$i7BFS55uFYRf5TE4ErSUH8HymMNAbpMAvsOcl2C"
}
},
"username": "uniqueusername",
"emails": [
{
"address": "[email protected]",
"verified": false
}
],
"type": "user",
"status": "offline",
"active": true,
"roles": [
"user"
],
"_updatedAt": "2016-09-13T14:57:56.175Z",
"name": "name",
"settings": {}
},
"success": true
}
Bad Request
{
"success": false,
"error": "Adding user is not allowed [error-action-not-allowed]",
"errorType": "error-action-not-allowed",
"details": {
"method": "insertOrUpdateUser",
"action": "Adding_user"
}
}
Unauthorized
{
"status": "error",
"message": "You must be logged in to do this."
}