Remove User From Teams

Description

The endpoint Remove User From Teams is used to remove an existing Leapwork or Active Directory user from multiple teams in the Leapwork application, using userId and TeamIds. After the successful removal from a team, the completed operation is returned in the response. The userId used as the input can be obtained from the Get All Users endpoint with the UserType as “Leapwork” or “ActiveDirectory”. The TeamIds used as the input can be obtained from the Get All Teams endpoint.

Please note this endpoint will work with the Leapwork Enterprise Edition only.

Request URL

(DELETE)

http://{controllerMachine}:{controllerPort}/api/v4/user/{userId}/RemoveUserFromTeams

Input parameters

Field

Type

Description

Comment

accessKey

string

An access key is required to restrict unauthorized access to the API.

The Access Key should include user scope to access user related APIs.

userId

string

Unique identifier for the user

This can be obtained from the Get All Users endpoint with the UserType as “Leapwork” or "ActiveDirectory"

requestBody

application/json

Unique identifiers for the Leapwork User comprising the following parameter:

 

 

 

TeamsIds (comma separated)

This can be obtained from the Get All Teams endpoint

Examples

Curl

curl -X DELETE --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'accessKey: UsctfG8Mg1LVa29L' -d '{ \

   "TeamIds": [ \

     "9fb4ef50-6924-471d-8261-052aa8b572c9","bc53d9e0-6dcd-4eb2-be1d-ccefdf55c1bf" \

   ] \

}' 'http://localhost:9001/api/v4/user/3940e00a-164c-4693-be0b-14ff4746c4a6/RemoveUserFromTeams'

 

PowerShell 

$headers = @{}
$headers.Add("accessKey","UsctfG8Mg1LVa29L")

$requestBody = @'
{
    "
TeamIds": @("9fb4ef50-6924-471d-8261-052aa8b572c9","bc53d9e0-6dcd-4eb2-be1d-ccefdf55c1bf")
}
'@ 

Invoke-WebRequest -Uri "http://localhost:9001/api/v4/user/3940e00a-164c-4693-be0b-14ff4746c4a6/RemoveUserFromTeams" -ContentType "application/json" -Headers $headers -Method DELETE -Body $requestBody

Response 

If a user is removed successfully from the provided team, it will return a 'true' value. 

{

"$id": "1",

"OperationCompleted": true

}

Response Object

Field

Type

Description

Values

$id

string

ID of internal object

 

OperationCompleted

bool

Returns ‘true’ if the user is successfully removed from all the provided teams 

true | false

Response Code

  • 200 (OK)
  • 400 (Bad Request)
  • 401 (Unauthorized - eg: “Incorrect Accesskey”)
  • 403 (Forbidden – eg: “AccessKey does not have the relevant scope permission”)
  • 404 (Not Found – eg: “User not found”, “Team(s) not found”, “User does not exist in a team(s).”)
  • 409 (Conflict – eg: “At least one team should contain an administrator”)
  • 500 (Internal Server Error)