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
- Company
- Application group
- User group
- Profile
- Permission
Verify available companies that can be assigned to the user:
See: API Specification
GET /v1/organizations/{organizationCode}/users/companies
Query parameters:
page
(optional): Page number (default: 0)size
(optional): Items per page (default: 100)
The resulting companies can be used to update a user with the company
field.
Thus giving the user the right to access the assets of the corresponding company.
Retrieve available authorization models (application groups):
See: API Specification
GET /v1/organizations/{organizationCode}/users/authorizations
This returns available authorization models (application groups) with:
- Model ID
- Name
- Description
- Available applications
The resulting authorization models can be used to update a user with the authorization.modelId
field.
Thus giving the user the right to access the corresponding applications.
Get available user groups:
See: API Specification
GET /v1/organizations/:organizationCode/users/groups
The resulting groups can be used to create a user with the groupUids
field.
Retrieve available user profiles:
See: API Specification
GET /v1/organizations/{organizationCode}/users/profiles
The resulting profiles can be used to update a user with the profile
field.
Get the current list of available permissions:
See: API Specification
GET /v1/organizations/{organizationCode}/users/permissions?pageNumber=1&pageSize=10
Query parameters:
pageNumber
(required): Page numberpageSize
(required): Items per pagetype
(optional): Permission type (e.g., ASSET)subType
(optional): Permission sub-type (e.g., PORTFOLIO)q
(optional): Search query on labelsortField
(optional): Field to sort bysortOrder
(optional): Sort order (asc/desc)
The resulting permissions can be used to update a user with the permissionUids
field.
Thus giving the user the right to access the corresponding assets.
Step 2: Update the user
Update the user with the modified information:
See: API Specification
PUT /v1/organizations/{organizationCode}/users/{id}
Request body:
{
"firstName": "updatedFirstName",
"lastName": "updatedLastName",
"company": "updatedCompanyName",
"groupUids": ["0192d7b7-2994-7ad5-9952-26862f33c21a"],
"authorization": {
"modelId": "2b2e8a4b-bfbd-4c56-b8d6-c8cb1d8c58ba",
"profile": "Developer",
"asset": {
"all": false
}
},
"permissionUids": [
"0192d7b7-2994-7ad5-9952-26862f33c21a",
"0192d7b7-7073-7e58-896c-07113f22363a"
]
}
Required fields:
firstName
: User's first namelastName
: User's last namecompany
: Company name (must be from available companies)groupUids
: Array of group UIDsauthorization
: Authorization configurationmodelId
: ID of the authorization modelprofile
: User profileasset
: Asset access configuration
permissionUids
: Array of permission UIDs
Note: Unlike creation, the update request doesn't include the email address as it cannot be modified.
Possible responses:
- 204: 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 ID in the path
- Returns 204 (no content) on success instead of 201
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.
-
Asset Access:
- When modifying asset access, provide the complete new set of asset codes
- Setting
"all": true
overrides any specific permissions for the asset type
-
Permissions:
- Provide the complete new set of permission UIDs
- All existing permissions will be replaced
- All permission UIDs must be valid
-
Authorization Model:
- Changing the authorization model might affect user's access to various features
- Ensure the new model provides appropriate access levels
Error Handling
Common error scenarios:
- User not found (404)
- Invalid authorization model ID
- Invalid company name
- Invalid group UIDs
- Invalid permission UIDs
- Missing required fields
- Invalid format of asset codes
Best practices
- Always retrieve current user data before updating
- Validate all new values against the lookup endpoints
- Keep track of sensitive changes (authorization, permissions)
- Implement proper error handling for 404 responses