Users Create
Only users with Admin role can create other users.
To create a new User, make a POST
request to /users.json
with the user data in
request body.
POST /users.json
Request data
The request body expects the following request data
Parameter | Description | Required | Validation Constraints |
---|---|---|---|
username | Username for this login. This is also their email address | Yes |
|
role_id | ID of the role to be assigned to this user. | No |
|
profile | Profile data for the new user | Yes | |
profile.first_name | First name for the new user | Yes |
|
profile.last_name | Last name for the new user | Yes |
|
Possible responses
Code | Description |
---|---|
200 | OK The User was created. The response body will contain the newly created user object |
400 | Bad Request Some of the data validation failed. |
403 | Authentication Failure The user making the request is not authenticated |
Examples
Successful request
And a valid request body will look like:
POST /users.json
{
"username": "[email protected]",
"profile": {
"first_name": "John",
"last_name": "Doe"
},
"role_id": "<uuid_of_the_role_object>"
}
Validation error response
A successful request must pass all the validation checks. For example sending a blank request body will return:
{
"header": {
"id": "a91e1c30-568f-4889-8eec-dd78c0a00543",
"status": "error",
"servertime": 1554981597,
"action": "a1a15b91-72f6-5708-8d7f-6940e51d8595",
"message": "Could not validate user data.",
"url": "\/users.json",
"code": 400
},
"body": {
"username": {
"_required": "A username is required."
},
"profile": {
"_required": "This field is required"
}
}
}
Last updated
This article was last updated on April 23rd, 2019.You can also find the latest OpenAPI 2.0 specifications directly on the dedicated repository.
OpenAPI Specs repository