Skip to main content

User API Examples

User management

The Users API contains, among other things, basic CRUD operations for user objects. When working with user objects, note that userId is the ID assigned by Trivore ID, not the identifier the user signs in with. A user ID looks like, for example, 5b0cfba4e2bb230ff8b535e6.

The examples here are meant as a general introduction to accessing the Management API — the reference at your instance's /apidoc endpoint is meant to be easy to understand and contain all the information needed to use the API.

Listing users

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

Replace CLIENT_ID and CLIENT_SECRET with your Management API client credentials.

curl "https://{your-id-server}/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 request to the /user endpoint. The example below creates a user in your Management API client's primary namespace.

username may be provided, or omitted to have one generated automatically — how that works depends on the namespace's configuration.

curl -X POST "https://{your-id-server}/api/rest/v1/user" \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"username": "mynewuser",
"email": "[email protected]",
"name": {
"givenName": "MyNew",
"familyName": "User"
}
}'

Deleting user accounts

User accounts can be deleted with a DELETE request sent to the /user endpoint.