Modifying a user
This guide explains how to update an existing user in the Stonal platform using the API. Similar to user creation, updating a user requires gathering current information before making changes.
- API access credentials
- A valid access token (see: Get a token)
- An organization code
If you wish to update an existing user by email, you can follow the previous creation process, as described: Here
The creation endpoint will update the user if it already exists.
Step 1: Lookup the user information that needs change
User groups
Get available user groups:
See: API Specification
GET /v1/organizations/:organizationCode/groups?pageNumber=1&pageSize=10
The resulting groups can be used to create a user with the groupUids
field.
Application groups
Retrieve available application groups:
See: API Specification
GET /v1/organizations/:organizationCode/users/permissions?pageNumber=1&pageSize=10&type=SCOPE_GROUP&subType=APPLICATION
The resulting application groups can be used to create a user with the permissions.uid
field.
Thus giving the user the right to access the corresponding applications.
Profiles
Get available user profiles:
See: API Specification
GET /v1/organizations/:organizationCode/users/permissions?pageNumber=1&pageSize=10&type=PROFILE
The resulting profiles can be used to create a user with the permissions.uid
field.
Assets
Here is the list of currently available ASSET
subtypes:
PORTFOLIO
COMPANY
FACILITY
BUILDING_GROUP
BUILDING
Companies
See: API Specification
GET /v1/organizations/:organizationCode/users/permissions?pageNumber=1&pageSize=10&type=ASSET&subType=COMPANY
The resulting permissions can be used to create a user with the permissions.uid
field.
Thus giving the user the right to access the corresponding companies.
Portfolios
See: API Specification
GET /v1/organizations/:organizationCode/users/permissions?pageNumber=1&pageSize=10&type=ASSET&subType=PORTFOLIO
The resulting permissions can be used to create a user with the permissions.uid
field.
Thus giving the user the right to access the corresponding portfolios.
Step 2: Update the user
Update the user with the modified information:
See: API Specification
PUT /v2/organizations/{organizationCode}/users/{uid}
Request body:
{
"email": "firstName.lastName@corp.com",
"firstName": "firstName",
"lastName": "lastName",
"password": "SecureP@ssw0rd!",
"fromExternalIdp": false,
"allAssets": false,
"userGroupUids": [
"019619df-4768-76b7-81e3-2c56d374df46"
],
"permissions": [
{
"uid": "019619df-4767-730f-8d31-143712a08141"
},
{
"uid": "019619df-4767-730f-8d31-143712a08142"
}
]
}
Required fields:
email
: User's email addressfirstName
: User's first namelastName
: User's last namegroupUids
: Array of group UIDspermissionUids
: Array of permission UIDs
Possible responses:
- 200: User updated successfully
- 404: User not found
Key Differences from Creation
When updating a user, note these important differences:
- Email address cannot be modified
- Use PUT instead of POST method
- Requires user UID in the path
Important Considerations
-
Partial Updates: The API does not support partial updates. You must provide all required fields in the update request, even if you're only changing one value.
-
Permissions:
- Provide the complete new set of permission UIDs
- All existing permissions will be replaced
- All permission UIDs must be valid
Error Handling
Common error scenarios:
- User isn't found (404)
- Invalid group UIDs
- Invalid permission UIDs
- Missing required fields
Best practices
- Always retrieve current user data before updating
- Validate all new values against the lookup endpoints
- Keep track of sensitive changes (permissions)
- Implement proper error handling for 404 responses