Skip to main content

User API examples

User management

The Users API contains, among other things, basic CRUD operations for user objects. It is to be noted that when dealing with user objects, the userId is the id assigned by the onePortal platform, not the ID that is used when signing in to the system. The user id can be, for example, 5b0cfba4e2bb230ff8b535e6.

The user management API description here is used as a general example on how to access the Management API. The manual found in the /apidoc endpoint is meant to be easy to understand and contain all the information needed to use the API.

Listing users

This example command will issue a GET request to the /user endpoint of the API. The request should include startIndex and count as parameters. The startIndex is a 0-based index of the first result in the current set of results. The count parameter tells the maximum number of items to return per page.

Replace CLIENT_ID and CLIENT_SECRET with your Management API Client credentials.

curl "https://fi.trivoreid.com/api/rest/v1/user?startIndex=0&count=50" \
-u "$CLIENT_ID:$CLIENT_SECRET"

Creating new user accounts

New user accounts can be created with a POST method HTTP request to the /user endpoint. The example command shows how to perform the request.

This example creates an User into the primary namespace of your Management API Client.

The username may be provided or it may be omitted and one will be generated. How this works depends on the namespace configuration.

curl -X POST "https://fi.trivoreid.com/api/rest/v1/user" \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"username": "mynewuser",
"email": "mynewuser@example.com",
"names": {
"givenName": "MyNew",
"familyName": "User"
}
}'

Deleting user accounts

User accounts can be deleted with a delete method request sent to the user endpoint.