Create User

Description

The endpoint Create User is used to create a new Leapwork user (with no team(s)). After the successful creation of a Leapwork user, the Id of the user is returned in the response. The details of the created user can be validated with the help of the 'Get All Users' endpoint.

Please note that for Leapwork Enterprise Edition, this ‘Create User’ endpoint along with ‘Add User To Teams’ endpoint is used to a create user with different teams.

You can refer to this user management settings article:

https://www.leapwork.com/product/documentation/administration/user-management

Request URL

(PUT) http://{controllerMachine}:{controllerPort}/api/v4/user/new

 

Input parameters

Field

Type

Description

Comment

accessKey

string

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

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

requestBody

application/json

Unique identifiers for the Leapwork User comprising the following parameters:

 

 

 

FullName

 

 

 

UserName

UserName should be unique

 

 

Password

Password should meet password complexity security policy

 

 

ForceChangePasswordOnFirstLogin

Possible values: true| false

 

 

Access

Possible values: Reader, NoAccess, Contributor, Administrator

Examples

Curl

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

   "FullName": "Test User", \

   "UserName": "User01", \

   "Password": "Test%40123", \

   "ForceChangePasswordOnFirstLogin": true, \

   "Access": "reader" \

}' 'http://localhost:9001/api/v4/user/new'

PowerShell 

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

$requestBody = @'
{
    "
FullName": "Test User",
    "
UserName": "User01",
    "
Password": "Test%40123",
    "
ForceChangePasswordOnFirstLogin": true,
     "
Access": "reader"
}
'@ 

Invoke-WebRequest -Uri "http://localhost:9001/api/v4/user/new" -ContentType "application/json" -Headers $headers -Method PUT  -Body $requestBody

Response 

Create a new user by returning UserId in the response.

{

"$id": "1",

"UserId": "3940e00a-164c-4693-be0b-14ff4746c4a6",

"OperationCompleted": true

}

Response Object

Field

Type

Description

Values

$id

string

ID of internal object

 

UserId

string

Unique Id of user created

 

OperationCompleted

bool

Returns ‘true’ if the user is created successfully

true | false

Response Code

  • 200 (OK)
  • 400 (Bad Request – eg: “The password must contain at least one lowercase letter, one uppercase letter, one digit, one special (non-alphanumeric) character. The password length must be at least 10 characters.”, “Spaces are not allowed in username”, “Invalid User Access”)
  • 401 (Unauthorized - eg: “Incorrect Accesskey”)
  • 403 (Forbidden – eg: “AccessKey does not have the relevant scope permission”)
  • 409 (Conflict – eg: “Duplicate Username”)
  • 500 (Internal Server Error)