Managing users in Management API
On this page
This guide explains how to create, list, edit and delete users with the Management API.
See GET /api/v1/users/, POST /api/v1/users/ and PATCH /api/v1/users/{user_id}/ in the API reference.
Limitations
User management endpoints are only available when using an API key generated in the Adverity user interface. These keys use the Bearer scheme in the Authorization header. For more information, see Creating a Connect API key in Adverity.
Prerequisites
Before you complete the procedures in this guide, perform all of the following actions:
-
Use a Connect API key with the following permissions:
-
User: Read-only (
user:read) to list and view users. -
User: Write (
user:write) to create, update, or delete users.
You can select the User permission only on a key for the root workspace, and only if you are an Administrator. Picking Write for a permission also gives the key its Read-only access. Without the permission a request needs, Management API returns HTTP
403. You cannot change the permissions of a key, so to add one, create a new key. For more information, see Creating a Connect API key in Adverity. -
Listing existing users
To list existing users, follow these steps:
-
Create a GET request to the following endpoint:
https://{{INSTANCE}}/api/v1/users/ -
Configure the pagination parameters:
Scroll horizontally to see the full table.
Parameter
Default value
page1
page_size50
The endpoint with the default parameters looks the following way:
https://{{INSTANCE}}/api/v1/users/?page=1&page_size=50 -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
Send the request.
As a result, you obtain the list of existing users in Management API in the response.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request GET 'https://{{INSTANCE}}/api/v1/users/?page=1&page_size=50' \
--header 'Authorization: Bearer {{KEY}}'
Response fields
The response contains an object for each user with the following fields:
Scroll horizontally to see the full table.
Field | Description |
|---|---|
| The numeric ID of the user. |
| The user’s email address. |
| The user’s first name. |
| The user’s last name. |
| Boolean. |
| List of group IDs the user belongs to. |
| List of workspace IDs the user has access to. |
| List of workspace names associated with the user. |
| Timestamp of when the user account was created. |
| Timestamp of the user’s most recent login. |
| Timestamp of the last modification to the user account. |
Creating a new user
To create a new user, follow these steps:
-
Create a POST request to the following endpoint:
https://{{INSTANCE}}/api/v1/users/ -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
In the HTTP request header, include the parameter
Content-Typewith valueapplication/json. -
In the HTTP request body, include the following parameters with their respective values:
{ "email": "user@example.com", "first_name": "string", "last_name": "string", "groups": [], "workspaces": [], "active": true } -
Send the request.
As a result, you created a new user through Management API.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request POST 'https://{{INSTANCE}}/api/v1/users/' \
--header 'Authorization: Bearer {{KEY}}' \
--header 'Content-Type: application/json' \
-d '{
"email": "user@example.com",
"first_name": "string",
"last_name": "string",
"groups": [],
"workspaces": [],
"active": true
}'
Viewing a user
To view an existing user, follow these steps:
-
Create a GET request to the following endpoint:
https://{{INSTANCE}}/api/v1/users/{{user_id}}/ -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
Send the request.
As a result, you obtain the details of the selected user in Management API in the response.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request GET 'https://{{INSTANCE}}/api/v1/users/{{user_id}}/' \
--header 'Authorization: Bearer {{KEY}}'
Editing a user
To edit an existing user, follow these steps:
-
Create a PATCH request to the following endpoint:
https://{{INSTANCE}}/api/v1/users/{{user_id}}/ -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
In the HTTP request header, include the parameter
Content-Typewith valueapplication/json. -
In the HTTP request body, include the parameters that you want to update out of the following:
{ "email": "user@example.com", "first_name": "string", "last_name": "string", "groups": [], "workspaces": [], "active": true } -
Send the request.
As a result, you updated the selected user through Management API.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request PATCH 'https://{{INSTANCE}}/api/v1/users/{{user_id}}/' \
--header 'Authorization: Bearer {{KEY}}' \
--header 'Content-Type: application/json' \
-d '{
"email": "user@example.com",
"first_name": "string",
"last_name": "string",
"groups": [],
"workspaces": [],
"active": true
}'
Deleting a user
To delete an existing user, follow these steps:
-
Create a DELETE request to the following endpoint:
https://{{INSTANCE}}/api/v1/users/{{user_id}}/ -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
Send the request.
As a result, you deleted the selected user through Management API.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request DELETE 'https://{{INSTANCE}}/api/v1/users/{{user_id}}/' \
--header 'Authorization: Bearer {{KEY}}'