Create or update user
This endpoint allows adding or updating user information within the business.
PUT /api/v2/businesses/{businessId}/users/{username}
Below is a detailed explanation of each field that may be part of the request body, with some being mandatory for a successful request.
|
Mandatory fields are marked with an asterisk (*). |
Request body
| JSON Analysis |
|---|
Details
|
Request example
After analyzing the various fields, here’s an example of the request:
PUT /api/v2/businesses/BUSINESSID/users/test.user@orquest.com
{
"username": "test.user@orquest.com",
"email": "test.user@orquest.com",
"nodes": [
5391, 5392
],
"roles": ["Manager"]
}
If the request is successful, the response will contain the information linked to the user: username, email, nodes and roles, with 200 OK if the user already existed or 201 Created (with a Location header) if it has been created.
Considerations
The email address linked to a user can be updated; simply specify the updated email in the request body.
|
Only nodes belonging to the business of the request can be added. The nodes in |
For roles, the role name must exactly match the one configured in the system under Business configuration > Roles.
If any roles were previously defined for the user, this information must also be sent in the update.
If the field is not sent, is set to null, or an empty array [] is sent, all roles will be removed.
|
An integration user will be able to assign any role defined at the business level. |
Error codes
In addition to the common errors, this endpoint can return the following codes:
| Code | Message | Description |
|---|---|---|
|
- |
The |
error.user_validation. [Nodes cannot be null] |
The |
|
error.user_validation. [Nodes cannot be empty] |
The |
|
error.user_validation. [User username cannot be null] |
The |
|
error.user_validation. [User email cannot be empty] |
The |
|
User email is not valid |
The |
|
error.node_not_found. [id] |
One of the |
|
error.role_not_found. [role] |
One of the |
|
error.email_already_exists. [email] |
The |
|
User not found. [] |
The |
|
|
Some role is not valid |
One of the user’s |
|
This endpoint has its own error handling that does not follow the general API format: the |
Useful links
What is a user?
What is a node? How to get business nodes?
What is the difference between an employee role and a user role?