Skip to main content

User Management via API

The following procedures summarize verified calls for managing users in the ABRA Flexi cloud environment via API.

Written by Alexander Pečeňák

What to distinguish

When working with users via API, distinguish between two separate operations:

  1. Creating a global user – the user is created at the service level.

  2. Adding a user to a specific company – the user gains access to the selected company with a specific role.

Without being added to a company, simply creating the user will have no practical impact on access to that company.

💡 Info: The procedures below have been verified in the Postman app against a Flexi cloud instance.


Creating a global user

You create a global user by sending a PUT or POST request to the endpoint /u.json

JSON is supported in the request body. The available fields for editing can be found by sending a GET request to the same endpoint /u.json

Server permissions (suitable for the ADMIN role) with true/false values corresponding to this setting:

  • createCompany > allows creating companies

  • deleteCompany > allows deleting companies

  • createUser > allows creating users

  • changePassword > allows changing users' passwords

  • grantPermisson > allows granting permissions to users

  • licenseMgmt > allows managing licenses

Procedure

  1. Send a PUT to the endpoint /u

  2. Set the Content-Type: application/json header.

  3. Include in the JSON body the fields you want to set

  4. Once completed successfully, the global user is created.

Verified example

PUT

https://alpe.flexibee.eu:5434/u.json
Content-Type: application/json
{
"username": "json",
"givenName": "name",
"familyName": "familyN",
"email": "json@admin.cz",
"userType": "READ_ONLY",
"password": "heslo_uzivaele_123",
"blocked": false,
"permissions": {
"manageAll": false,
"createCompany": false,
"deleteCompany": false,
"createUser": false,
"changePassword": false,
"grantPermission": false,
"licenseMgmt": false
},
"defaultRole": "UZIVATEL",
"overrideRole": false,
"apiAccessEnabled": false
}

This call creates the user json.


Editing a user

Editing a user is done by calling PUT on the endpoint /u/{uzivatel}.json

and supports JSON in the request body.

Procedure

  1. Send a PUT to the endpoint /u/{uzivatel}.json

  2. Set the Content-Type: application/json header.

  3. Include in the JSON body the fields you want to update

Verified example

PUT

https://alpe.flexibee.eu:5434/u/api_new.json
Content-Type: application/json
{
"email": "new_email@email.cz"
}

Adding a user to a company

After creating a global user, you need to add them to a specific company. This is done via the company's user record endpoint.

Procedure

  1. Send a PUT to the endpoint /c/{firma}/uzivatel

  2. Set the Content-Type: application/json header

  3. Include in the JSON body the user and the role they should have in the given company

Verified example

PUT

https://alpe.flexibee.eu:5434/c/sk_firma_cloud/uzivatel
Content-Type: application/json
{ "winstrom": { "uzivatel": [ { "id": "code:api_new", "role": "code:ADMIN" } ] } }

In this example, the user api_new is added to the company sk_firma_cloud with the role ADMIN.

💡 Info: The default role assigned when creating a global user and the role assigned within a company are two different things.


Editing a user's role in a company

Just like adding a user, editing is done by calling PUT on the endpoint /c/{firma}/uzivatel

with the values provided in the JSON request body.

Procedure

  1. Send a PUT to the endpoint /c/{firma}/uzivatel

  2. Set the Content-Type: application/json header.

  3. Include in the JSON body the fields you want to update, for example changing the role to SKLADNIK

Verified example

PUT

https://alpe.flexibee.eu:5434/c/flexi_gui_s_r_o_/uzivatel
Content-Type: application/json
{
"winstrom": {
"uzivatel": [
{
"id": "code:api_new",
"role": "code:SKLADNIK"
}
]
}
}

Removing a user from a company

If you need to revoke a user's access to a specific company, delete their link to the company in the uzivatel record.

Procedure

  1. Send a PUT to the endpoint /c/{firma}/uzivatel.

  2. Set the Content-Type: application/json header.

  3. In the body, use the delete action along with the user's identification.

Verified example

PUT

https://alpe.flexibee.eu:5434/c/sk_firma_cloud/uzivatel
Content-Type: application/json
{ "winstrom": { "uzivatel": [ { "@action": "delete", "id": "code:api_new" } ] } }

This call removes the user api_new from the company sk_firma_cloud.

⚠️ Warning: This step removes the user from a specific company, but if that is their only assigned company, the user will be deleted globally.

If the user already has historical records linked to them in the database, removal will fail. In such a case, use User blocking instead.


Blocking a user

Blocking the user normal_v1 with cURL:

curl -u "user:password" -X POST -d "blocked=true" "https://moje.flexibee.eu/u/normal_v1.json"

In Postman:

POST

https://alpe.flexibee.eu:5434/u/normal_v1.json

JSON body

{
"blocked": true,
"blocked@message": "Blocked from API"
}

⚠️ Warning: Blocking a user frees up their license and prevents them from logging in. To unblock, use the same call with the value "false".


Listing all users

To review all global users, use a listing query against the endpoint /u.json.

Procedure

GET

https://alpe.flexibee.eu:5434/u.json

Returns a list of all users.


Listing users of a specific company

If you need to find out which users are connected to a specific company, use the company's user record.

Procedure

GET

https://alpe.flexibee.eu:5434/c/sk_firma_cloud/uzivatel.json?limit=0&detail=full

Returns users linked to the specific company.

⚠️ Warning
The parameter limit=0 removes the default limit of 20 records, returning an unlimited number of results, so you can retrieve all users of the given company.

The parameter detail=full displays all fields and their values for full detail.


Listing roles in a company

You can find out the roles available in a company by querying the role record.

Procedure

  1. Send a GET to c/{firma}/role.json

  2. In the JSON body, set the desired level of output detail.

  3. For a clear list, return only the ID, code, and name.

Verified example

GET

https://alpe.flexibee.eu:5434/c/sk_firma_cloud/role.json?limit=0

This way you get an overview of the roles available in the selected company.

⚠️ Warning
Here, the parameter detail=full returns a list of all configured permissions, i.e. over 10,000 rows per single role. If you need to read the permission settings for a role, it's recommended to limit the query to just one role, for example the ADMIN role:

https://alpe.flexibee.eu:5434/c/sk_firma_cloud/role/code:ADMIN.json?detail=full 

Endpoint overview

Operation

Method and endpoint

Note

Creating a global user

PUT or POST /u

JSON body

Editing a global user

PUT /u

JSON body

Editing a user in a company

PUT /c/{firma}/uzivatel

JSON body

Adding a user to a company

PUT /c/{firma}/uzivatel

JSON body

Removing a user from a company

PUT /c/{firma}/uzivatel

@action: delete

Blocking a user

POST/u/{uzivatel}.json

the value blocked=true is sent in Postman via an x-www-form-urlencoded body

Listing all users

GET /u.json

Global users

Listing users in a company

GET/c/{firma}/uzivatel.json?limit=0&detail=full

Users of a specific company

Listing roles

GET/c/{firma}/role.json?limit=0

Recommended custom detail
use caution with ?detail=full!


What to watch out for

⚠️ Warning: Creating a user and adding them to a company are two separate operations. Both need to be performed.

⚠️ Warning: Listings using detail=full can be significantly large and less readable.

⚠️ Warning: It's recommended to test and fine-tune user management via API in a testing environment or against a test database.

⚠️ Warning: Roles are currently read-only; they cannot be written via the API.


Related articles

Did this answer your question?