This article explains how you can add or remove users from teams using simple API calls. To do this, you will either create or delete team member records which represent membership of users within teams.
Create Or Delete Team Members
To add or remove a user from a team, follow these 2 steps:
- Step 1 - Get Your API key
- Step 2 - Submit Team Member Changes
Step 1 - Get Your API Key
To obtain your API key:
- Login to your workspace
- On the left pane, click on "Account > My Profile"
- Click on the "Security" tab (if needed)
- Copy the API key
- Note: you must be full admin in your workspace
Step 2 - Submit Team Member Changes
To add or delete a team member:
- Prepare a POST call to either
- Set HTTP header X-ApiKey to your API key
- POST a single JSON object, such as:
- {
"systemUserId": "7812068d-b46f-46a7-aa91-c517b692dee0",
"teamId": "9bd7b69a-50dc-4313-8ebe-0fc49efae883",
}
Sample Code
The following samples show how to make calls (using C#):
// Add a user to a team
dynamic expando = new ExpandoObject();
expando.systemUserId = new Guid("7812068d-b46f-46a7-aa91-c517b692dee0");
expando.teamId = new Guid("9bd7b69a-50dc-4313-8ebe-0fc49efae883");
string json = JsonConvert.SerializeObject(expando);
WebClient webClient = new WebClient();
webClient.Headers.Add("X-ApiKey", apiKey);
string result = webClient.UploadString(url, json);
// Remove a user from a team
dynamic expando = new ExpandoObject();
expando.systemUserId = new Guid("7812068d-b46f-46a7-aa91-c517b692dee0");
expando.teamId = new Guid("9bd7b69a-50dc-4313-8ebe-0fc49efae883");
string json = JsonConvert.SerializeObject(expando);
WebClient webClient = new WebClient();
webClient.Headers.Add("X-ApiKey", apiKey);
string result = webClient.UploadString(url, json);
Getting IDs
To retrieve user and team IDs, you can make OData API calls. User and team IDs must be valid within your workspace.
To visually explore the API:
- Login to your workspace
- On the left pane, click on "Settings > Connections > OData API"
- Alternatively, you can connect using a BI tool such as Microsoft Power BI to view entities
No-Op Creates
If you submit a create request, and there already is a team member for the specified user and team, no action will be performed. No errors will be returned.
No-Op Deletes
If you submit a delete request, and there is no team member for the specified user and team, no action will be performed. No errors will be returned.