8
API Users
Lukas Metzger edited this page 2018-04-05 17:04:49 +02:00
Users
Where not otherwise noted all calls in this section can only be used by admin users.
Get list of users
GET /users?page=5&pagesize=10&query=foo&type=admin,user&sort=id-asc,name-desc,type-asc
parameter | explanation |
---|---|
page | The page of the results to return, if ommited returns page 1 |
pagesize | How many items should be on each page, if ommited page size is infinite therefore all results are returned |
type | Types of the retrieved users comma separated |
query | A search query |
sort | A comma separated list of field names to sort (in this order) combined with the sort order (see example) |
Response
code | result |
---|---|
200 | Everything was successful |
{
"paging": {
"page": 5,
"total": 20,
"pagesize": 10
},
"results": [
{
"id": 1,
"name": "administrator",
"type": "admin",
"native": true
}
]
}
Create new user
POST /users
This will create a native user.
Body
{
"name": "administrator",
"type": "admin",
"password": "supersecretpassword"
}
Response
code | result |
---|---|
201 | Everything was successful, user has been created |
400 | If type is invalid |
409 | A user with that name already exists |
422 | One of the required fields is missing |
{
"id": 21,
"name": "administrator",
"type": "admin"
}
Delete user
DELETE /users/{id}
Will work for any user. But users from a not native backend can relogin if they exist there.
Response
code | result |
---|---|
204 | Everything was successful, the answer body is therefore empty |
404 | The given user id does not exist |
Get single user
GET /users/{id}
This call with me
as id (/users/me
) can be called by any user and refers to the current user.
Response
code | result |
---|---|
200 | Call was successful |
404 | The given user id does not exist |
{
"id": 1,
"name": "administrator",
"type": "admin",
"native": true
}
Update user
PUT /users/{id}
This call with me
as id (/users/me
) can be called by any user and refers to the current user. In this case only the password property is valid.
Name and password are only valid for native users for others they are ignored. Type can be changed for any user.
Body
{
"name?": "administrator",
"type?": "admin",
"password?": "supersecretpassword"
}
Response
code | result |
---|---|
204 | Everything was successful, the answer body is therefore empty |
404 | The given user id does not exist |
409 | A user with that name already exists |