Users
User accounts are configured on the platform as entities. They, like other entities, have a number of required and optional fields, the values of which are written to the configuration. Accordingly, the user can manage his account not only through the graphical interface of the platform, but also through the API by implementing the following actions:
- Getting a list of users.
- Getting information about one user.
- Creating a new account.
- Editing a new account.
- Deleting a new account.
- Publication of a token for the user.
Getting a list of users
When you receive the list of accounts of all users, you must send a request GET /api/v1/users
. In this case, the response will receive a list that includes only those users who are in the same group as the user who sent the request.
Request
GET /api/v1/users HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}
Response
HTTP/1.1 200 OK
[
{
"_id": "5d8a18d5d0025e0012fb6a34",
"login": "user_login",
"name": "user_name",
"email": "user_email",
"rights": 1.5,
"role": "5cc89f6af79a4969291dcbd7",
"messages": true
}
]
Getting information about one user
User accounts, like other entities, have their own identifier assigned to them by the system. Accordingly, if it is necessary to get data on any particular account, the request must specify the identification number of this account.
Request
GET /api/v1/users/:id HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}
Response
HTTP/1.1 200 OK
{
"_id": "5d8a18d5d0025e0012fb6a34",
"login": "user_login",
"name": "user_name",
"email": "user_email",
"rights": 1.5,
"role": "5cc89f6af79a4969291dcbd7",
"messages": true,
"success": true
}
Creating a new account
To create a new account, you need to specify all the necessary fields in the request body and assign them the corresponding values.
Request
POST /api/v1/users HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}
BODY
Response
HTTP/1.1 200 OK
BODY
Editing a new account
To edit a user account, send a request PATCH /api/v1/users/:id
with the editable entity ID.
Request
PATCH /api/v1/users/:id HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}
BODY
Response
HTTP/1.1 200 OK
BODY
Deleting a new account
To remove an account from a group, you must send a DELETE /api/v1/users/:id
request.
Request
DELETE /api/v1/users/:id HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}
Response
HTTP/1.1 200 OK
BODY
Publication of a token for the user
Since interaction with the platform through the use of the API is carried out only taking into account authorization, the user needs to publish a token to the requests that he needs to send. To do this, there is a special request POST /api/v1/users/tokens
, which allows publishing a token for a specific user.
Request
POST /api/v1/users/tokens HTTP/1.1
Content-Type: application/json
Response
HTTP/1.1 200 OK
BODY