Creating a user
This guide walks through the process of creating a new user in the Stonal platform using the API. The process involves several steps to gather required information before creating the user.
- A valid set of API credentials
- A valid access token (see: Get a token)
- An organization code
Step 1: Search for an existing user
Before creating a new user, check if they already exist to avoid duplicates.
See: API Specification
POST /v1/organizations/{organizationCode}/users/search
Request body:
{
"email": "firstName.lastName@corp.com"
}
If the user exists, you'll receive a 200 response with user details (See: Modifying a user). If not, proceed with user creation.
Step 2: Lookup the necessary user information
- Company
- Profile
- User group
- Application group
- Assets
Get the list of 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 create a user with the company
field.
Thus giving the user the right to access the assets of the corresponding company.
Get available user profiles:
See: API Specification
GET /v1/organizations/{organizationCode}/users/profiles
The resulting profiles can be used to create a user with the profile
field.
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 authorization models:
See: API Specification
GET /v1/organizations/{organizationCode}/users/authorizations
The response includes:
- Model ID
- Name
- Description
- Available applications
The resulting authorization models can be used to create a user with the authorization.modelId
field.
Thus giving the user the right to access the corresponding applications.
Fetch 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 create a user with the permissionUids
field.
Thus giving the user the right to access the corresponding assets.
Step 3: Create the user
Finally, create the user with all gathered information:
See: API Specification
POST /v1/organizations/{organizationCode}/users
Request body:
{
"email": "firstName.lastName@corp.com",
"firstName": "firstName",
"lastName": "lastName",
"company": "companyName",
"fromExternalIdp": false,
"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:
email
: User's email addressfirstName
: 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
Possible responses:
- 201: User created successfully
- 202: User creation appears successful but cannot be confirmed
- 409: User already exists
Notes
- All email addresses must be unique in the system
- The company assignment affects which assets the user can access
- If
fromExternalIdp
is true, the user must authenticate through their identity provider - Asset access can be granted to all assets (
"all": true
) or specific assets usingpermissionUids
- Permission UIDs must be valid and retrieved from the permissions endpoint
Error Handling
Common error scenarios:
- Invalid authorization model ID
- Invalid company name
- Duplicate email address
- Invalid permission UIDs
- Missing required fields
Always check the response status and handle errors appropriately in your implementation.