Creating and updating users
Creating users
To create a user, use the following endpoint:
- POST
/admin/v1/users
Create a minimal user
The minimum creation criteria for a user is the username
. For
example, the following request creates a user with the user name "amartin".
{
"data": {
"attributes": {
"username": "amartin"
}
}
}
The following is the response payload.
POST /admin/v1/users
{
"data": {
"attributes": {
"active": true,
"displayName": "",
"externalUser": false,
"id": "cc:SVA-tE4oV6qcNvofjff8v",
"username": "amartin",
"vacationStatus": {
"code": "atwork",
"name": "At work"
}
},
"checksum": "590697d4d0c3ccc1728d9f2d1d8c4051",
"links": {
"self": {
"href": "/admin/v1/users/cc:SVA-tE4oV6qcNvofjff8v",
"methods": [
"get",
"patch"
]
}
}
}
}
Create a typical user
You can specify additional information about a user as specified in the User schema. For example, the following payload creates a user with the following attributes:
- First name: Adriana
- Last name: Diaz
- User name: adiaz
- Employee number: ACME-02027
- Roles: account manager (
account_manager
) and adjuster (adjuster
)
POST /admin/v1/users
{
"data": {
"attributes": {
"firstName": "Adriana",
"lastName": "Diaz",
"username": "adiaz",
"employeeNumber": "ACME-02027",
"roles" : [
{
"id": "account_manager"
},
{
"id": "adjuster"
}
]
}
}
}
Updating users
Use the following endpoint to modify an existing user:
- PATCH
/admin/v1/users/{userId}
Modifying user role assignment
You can use the PATCH /admin/v1/users/{userId}
endpoint to assign or
unassign roles to an existing user by modifying the roles
array.
Note that, within Cloud API, PATCHing an array does not add the PATCH members to the members already existing in the array. Instead, the PATCH replaces the existing members with the PATCH members. If you want a PATCH to be additive to an array, you must first determine the existing members of the array, and then specify an array in the PATCH with the existing members as well as the ones you wish to add.
For example, suppose you have an existing user named Adriana Diaz with an ID of cc:111 and the following roles:
- account manager (
account_manager
) - adjuster (
adjuster
)
You want to add the Claims Supervisor role
(claims_supervisor
) to this user. To do so, you must use the following
payload. (Note that the payload specifies the existing roles and the new role.)
PATCH /admin/v1/users/cc:111
{
"data": {
"attributes": {
"roles": [
{
"id": "account_manager"
},
{
"id": "adjuster"
},
{
"id": "claims_supervisor"
}
]
}
}
}