Managing users

This page will show you how to manage users

This page will explain how to manage users by API and has the following sections:

Users can also be managed manually from the user management section of our web app.

Creating a user

A user can be created as follows:

curl {baseURL}/users  
-H "Authorization:your-api-key"  
-H "Content-type: application/json"  
-X POST  
-d '{
  "firstName": "John",
  "lastName": "Smith",
  "gender": "M",
  "email":"[email protected]",
  "roles":["ROLE_TRADER_STANDARD"],
  "mobileNumberCountryCode": "44",
  "mobileNumber": "7777123456",
  "customerUserId": "ID2345" 
}'

Only the email and roles fields are mandatory. The other fields are optional. Possible values for roles are ROLE_TRADER_STANDARD and ROLE_TRADER_ADMIN. Possible values for gender are M and F.

The mobileNumber and mobileNumberCountryCode are not mandatory but they are required for two-factor authentication for card payments ("3D Secure"). You will not be able to create cards for this user if the user doesn't have a mobile number.

The customerUserId is an optional field allowing you to add the id under which this user is known in your own system.

After creating a user, the response to the API will look as follows:

{
  "id":"user-id",
  "firstName": "John",
  "lastName": "Smith",
  "gender": "M",
  "email":"[email protected]",
  "roles":["ROLE_TRADER_STANDARD"],
  "traderId": "your-trader-id",
  "mobileNumberCountryCode": "44",
  "mobileNumber": "7777123456",
  "customerUserId": "ID2345", 
  "enabled": true,
  "emailConfirmed": false
}

After creating a user in Yordex, the user will receive an email to set their password. Once they set that, emailConfirmed will be true.

Getting user details

Getting a list of all users is done as follows:

curl {baseURL}/users 
-H "Authorization:your-api-key"  
-X GET

The response will look as follows:

{
  "users": [
    {
      "id":"user-id-1",
      "firstName": "John",
      "lastName": "Smith",
      "gender": "M",
      "email":"[email protected]",
      "roles":["ROLE_TRADER_STANDARD"],
      "traderId": "your-trader-id",
      "mobileNumberCountryCode": "44",
      "mobileNumber": "7777123456",
      "customerUserId": "ID2345", 
      "enabled": true,
      "emailConfirmed": true
    }, 
    {
      "id":"user-id-2",
      "firstName": "Delia",
      "lastName": "Smith",
      "gender": "F",
      "email":"[email protected]",
      "roles":["ROLE_TRADER_ADMIN"],
      "traderId": "your-trader-id",
      "mobileNumberCountryCode": "44",
      "mobileNumber": "7777123457",
      "customerUserId": "ID3456", 
      "enabled": true,
      "emailConfirmed": true
    }
  ]
}

Getting an individual user is done as follows:

curl {baseURL}/users/user-id
-H "Authorization:your-api-key"  
-X GET

The response will be similar as when getting a list of users.

Updating a user

Updating a user works in exactly the same way as creating a user:

curl {baseURL}/users/user-id  
-H "Authorization:your-api-key"  
-H "Content-type: application/json"  
-X PUT  
-d '{
  "firstName": "John",
  "lastName": "Smith",
  "gender": "M",
  "roles":["ROLE_TRADER_STANDARD"],
  "mobileNumberCountryCode": "44",
  "mobileNumber": "7777123456",
  "customerUserId": "ID2345"
}'

The only field that cannot be updated is the email address.

Suspending a user

Suspending a user is done as follows:

curl {baseURL}/users/user-id/suspend
-H "Authorization:your-api-key"  
-X POST

Suspended user data will still be available but they will not be able to login to the system.


What’s Next