Users
For more information about users, see the Users section of the Administrator guide.
Getting the list of users
You can get a list of users with their data: ID, login, role, account status, and other data if specified (e.g., first name, last name, phone, etc.).
To get the list of users, send a GET request to /v1/users with the limit parameter - the maximum number of users in the response (from 1 to 500).
Request example:
curl --request GET \
--url 'https://geoflow.2gis.ru/public/api/v1/users?limit=3' \
--header 'Authorization: Bearer <token>'
Response example:
response.json
{
"items": [
{
"id": "0d359647-af89-43f6-9721-a18e24a726c5",
"username": "ivanov",
"first_name": "Ivan",
"last_name": "Ivanov",
"roles": [
"super_admin"
],
"status": "active"
},
{
"id": "a62cc015-a4a4-405f-a972-3754e436474e",
"username": "petrov",
"first_name": "Petr",
"last_name": "Petrov",
"roles": [
"user"
],
"status": "active"
},
{
"id": "a2e633f5-a6be-4895-8386-b560669f8918",
"username": "ivanpetrov",
"first_name": "Ivan",
"last_name": "Petrov",
"second_name": "Sergeevich",
"phone": "+7 (999) 999-99-99",
"roles": [
"user"
],
"status": "active"
}
],
"cursor": {}
}
Role mapping in the response corresponds to roles in the administrator web panel:
super_admin- Main administratoradmin- Company administratordispatcher- Dispatcheragent_group_admin- Agent group manageruser- Employee
Getting a user by ID
You can get user data by user ID: login, role, account status, and other data if specified (e.g., first name, last name, phone, etc.).
To get user data, send a GET request to /v1/users/{id}, where {id} is the user ID.
Request example:
curl --request GET \
--url 'https://geoflow.2gis.ru/public/api/v1/users/590cef82-d71f-48a1-8f81-3118db444b92' \
--header 'Authorization: Bearer <token>'
Response example:
response.json
{
"id": "590cef82-d71f-48a1-8f81-3118db444b92",
"username": "ivanpetrov",
"first_name": "Ivan",
"last_name": "Petrov",
"second_name": "Sergeevich",
"roles": [
"user"
],
"status": "active"
}
Role mapping in the response corresponds to roles in the administrator web panel:
super_admin- Main administratoradmin- Company administratordispatcher- Dispatcheragent_group_admin- Agent group manageruser- Employee
Creating a user
To create a mobile application user with the Employee (user) role, send a POST request to /v1/users with the following parameters:
first_name(mandatory parameter) - user's first name.second_name- user's patronymic.last_name(mandatory parameter) - user's last name.username(mandatory parameter) - user's login.
Request example:
curl --request POST \
--url 'https://geoflow.2gis.ru/public/api/v1/users' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "Ivan",
"second_name": "Sergeevich",
"last_name": "Petrov",
"username": "ivanpetrov"
}'
Response example:
response.json
{
"id": "590cef82-d71f-48a1-8f81-3118db444b92",
"username": "ivanpetrov",
"first_name": "Ivan",
"last_name": "Petrov",
"second_name": "Sergeevich",
"roles": [
"user"
],
"status": "pending"
}
Inviting a user
To send the user an invitation to the mobile application with a temporary password, send a POST request to /v1/users/invite/by-login with the username parameter - the user's login.
Request example:
curl --request POST \
--url 'https://geoflow.2gis.ru/public/api/v1/users/invite/by-login' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"username": "ivanpetrov"
}'
Response example:
response.json
{
"id": "590cef82-d71f-48a1-8f81-3118db444b92",
"username": "ivanpetrov",
"temporary_password": "OY!iA25Q#CP8R6Mv",
"status": "pending"
}