How Can I Programmatically Add Or Remove Users From Teams?

How Can I Programmatically Add Or Remove Users From Teams?


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:
        "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.

    • Related Articles

    • How Can I Programmatically Create Or Update Teams?

      This article explains how you can create or update teams using simple API calls. To add or remove users from teams, see this article. To add or remove custom variables from teams, see this article. Create Or Update Teams To create or update teams, ...
    • How Can I Programmatically Create Or Update Users?

      This article explains how you can create or update users using simple API calls. To add or remove users from teams, see this article. To add or remove custom variables from users, see this article. Create Or Update Users To create or update users, ...
    • How Can I Invite Users?

      There are two ways you can invite users: Send them an email yourself (recommended) Run the add user wizard Send Them An Email Yourself (Recommended) Invitation emails do NOT require any special invitation link. They can be sent directly by you to ...
    • How Can I Programmatically Retrieve Or Set Custom Variables

      This article explains how you can retrieve or set custom variables on users, teams, plans within your workspace using simple API calls. Retrieve Custom Variables To retrieve custom variables, follow these 2 steps: Step 1 - Get Your API key Step 2 - ...
    • How Can I Credit Multiple Users For One Transaction?

      You may want to issue commissions to multiple users over the same sales transaction. This may be necessary when multiple users contribute to a sale, or because you have a multi-level commission structure (ex: override commissions). There are two ways ...