Create user
Request to create a new user:
POST /api/v2/users.json
The request body contains the user object. name and role_id are
required. Attributes that are not included take their default values.
For example:
{
"user": {
"name": "John Smith",
"role_id": "5b139cee-f13a-11e5-9615-e03f497dbdff",
"groups": ["47f53fcc-9201-11e5-b4ef-e03f497dbdff"],
"timezone": "Europe/London",
"fieldset_login": {
"can_login": true,
"login": "j.smith",
"password": "Pa$$w0rd1234",
"authenticate_type": "password"
},
"fieldset_recording": {
"extensions": ["2001", "2002"],
"record": "always",
"record_direction": ["in", "out"]
},
"fieldset_licensing": {
"recording_seat": true
}
}
}
The tenant of the new user is taken from the first group in groups (or from group_id). When
no group is given, the user is created in the tenant of the API user.
To create the user without a password and let them choose one, set
fieldset_login.create_password_type to SEND_WELCOME_EMAIL_WITH_CREATE_PASS_LINK and provide
email. This requires SMTP to be configured and password reset to be enabled in the password
policy.
Response contains HTTP status code as shown in the following table.
| Response | Description |
|---|---|
| 201 Created | The user has been successfully created. The |
| Location: /api/v2/users/e011c408-f288-11e4-9b73-e03f497dbdff.json |
{"url": "/api/v2/users/e011c408-f288-11e4-9b73-e03f497dbdff.json"} | | 400 Bad Request |
The request cannot be completed because the supplied JSON object has invalid data.
The response contains a detailed description of the error, like:
{"error": "InvalidRecord", "explanation": "Record Validation errors", "details": {"fieldset_login.login": "Such login already exists"}} |
| 403 Forbidden | The request cannot be completed because API user has no permission to create users, or has no permission to edit the Role settings of users |
| 404 Not Found | The group_id is not a valid UUID |