Admin API: Users
Operations to create, list, and delete users of the environment. Only environment administrators can use them. Common rules (authentication, error format, dates and times) are in the Admin API reference.
In the examples, replace <hostname> with the hostname of your environment and <access token> with an access token that starts with hako_pat_. Replace other values in angle brackets, such as <slug>, with the values described in each operation’s parameter table.
| Operation | Method and path |
|---|---|
| List users of the environment (environment administrators only) | GET /admin/api/users |
| Create a user (environment administrators only) | POST /admin/api/users |
| Delete a user | DELETE /admin/api/users/{id} |
| Anonymize a deleted user | POST /admin/api/users/{id}/anonymize |
| Issue a password link (environment administrators only) | POST /admin/api/users/{id}/password-links |
List users of the environment (environment administrators only)
Section titled “List users of the environment (environment administrators only)”GET /admin/api/users- Login: required (session or access token)
Parameters:
| Name | In | Type | Required | Constraints | Description |
|---|---|---|---|---|---|
deleted |
query | boolean | Include deleted users |
Responses:
| Status | Body | Reason |
|---|---|---|
200 |
Array of UserSummary (application/json) |
|
400 |
Error (application/json) |
The input values break the rules (including JSON syntax errors). Errors with their locations are in issues |
401 |
Error (application/json) |
Not logged in, or the access token is wrong, expired, or revoked |
403 |
Error (application/json) |
Insufficient permission (including writes with a read-only access token and writes from another origin with a session) |
If the request fails, you get a 4xx or 5xx status and a JSON body with message. What each status means is in the error list.
Example:
curl "https://<hostname>.hakocms.net/admin/api/users" \ -H "Authorization: Bearer <access token>"Create a user (environment administrators only)
Section titled “Create a user (environment administrators only)”If you omit the password, the user is created without the ability to log in with a password. Issue a password link and give it to the user.
POST /admin/api/users- Login: required (session or access token)
Request body (application/json):
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
email |
string | Yes | Email address (used to log in) | |
isAdmin |
boolean | Make the user an environment administrator (can create spaces) | ||
name |
string or null | Display name. If omitted, the part of the email address before @ | ||
password |
string or null | If omitted, a user without a password is created (the user sets one through a password link) |
Responses:
| Status | Body | Reason |
|---|---|---|
201 |
User (application/json) |
|
400 |
Error (application/json) |
The input values break the rules (including JSON syntax errors). Errors with their locations are in issues |
401 |
Error (application/json) |
Not logged in, or the access token is wrong, expired, or revoked |
403 |
Error (application/json) |
Insufficient permission (including writes with a read-only access token and writes from another origin with a session) |
409 |
Error (application/json) |
A user with the same email address exists, or a usage limit was reached (the body’s limit) |
415 |
Error (application/json) |
Content-Type: application/json is missing |
422 |
Error (application/json) |
The JSON has the wrong shape (a required key is missing, a type is wrong, or there is an unknown key) |
If the request fails, you get a 4xx or 5xx status and a JSON body with message. What each status means is in the error list.
Example:
curl -X POST "https://<hostname>.hakocms.net/admin/api/users" \ -H "Authorization: Bearer <access token>" \ -H "Content-Type: application/json" \ -d '{ "email": "<email>"}'Delete a user
Section titled “Delete a user”The user is logged out immediately and removed from their spaces. The user’s record is kept.
DELETE /admin/api/users/{id}- Login: required (session or access token)
Parameters:
| Name | In | Type | Required | Constraints | Description |
|---|---|---|---|---|---|
id |
path | string | Yes | ID |
Responses:
| Status | Body | Reason |
|---|---|---|
204 |
None | |
401 |
Error (application/json) |
Not logged in, or the access token is wrong, expired, or revoked |
403 |
Error (application/json) |
Insufficient permission (including writes with a read-only access token and writes from another origin with a session) |
404 |
Error (application/json) |
Not found |
409 |
Error (application/json) |
The user is yourself, the last environment administrator, or the last owner of some space (the body’s spaces) |
If the request fails, you get a 4xx or 5xx status and a JSON body with message. What each status means is in the error list.
Example:
curl -X DELETE "https://<hostname>.hakocms.net/admin/api/users/<id>" \ -H "Authorization: Bearer <access token>"Anonymize a deleted user
Section titled “Anonymize a deleted user”Deleted users only. This cannot be undone.
POST /admin/api/users/{id}/anonymize- Login: required (session or access token)
Parameters:
| Name | In | Type | Required | Constraints | Description |
|---|---|---|---|---|---|
id |
path | string | Yes | ID |
Responses:
| Status | Body | Reason |
|---|---|---|
200 |
UserSummary (application/json) |
|
401 |
Error (application/json) |
Not logged in, or the access token is wrong, expired, or revoked |
403 |
Error (application/json) |
Insufficient permission (including writes with a read-only access token and writes from another origin with a session) |
404 |
Error (application/json) |
Not found |
409 |
Error (application/json) |
The user has not been deleted yet |
If the request fails, you get a 4xx or 5xx status and a JSON body with message. What each status means is in the error list.
Example:
curl -X POST "https://<hostname>.hakocms.net/admin/api/users/<id>/anonymize" \ -H "Authorization: Bearer <access token>"Issue a password link (environment administrators only)
Section titled “Issue a password link (environment administrators only)”Issuing a new link makes the previous link unusable. Give it to someone who forgot their password or who was created without a password.
POST /admin/api/users/{id}/password-links- Login: required (session or access token)
Parameters:
| Name | In | Type | Required | Constraints | Description |
|---|---|---|---|---|---|
id |
path | string | Yes | ID |
Request body (application/json, optional):
PasswordLinkRequest or null.
Responses:
| Status | Body | Reason |
|---|---|---|
201 |
PasswordLinkCreated (application/json) |
|
400 |
Error (application/json) |
The input values break the rules (including JSON syntax errors). Errors with their locations are in issues |
401 |
Error (application/json) |
Not logged in, or the access token is wrong, expired, or revoked |
403 |
Error (application/json) |
Insufficient permission (including writes with a read-only access token and writes from another origin with a session) |
404 |
Error (application/json) |
Not found |
415 |
Error (application/json) |
Content-Type: application/json is missing |
422 |
Error (application/json) |
The JSON has the wrong shape (a required key is missing, a type is wrong, or there is an unknown key) |
If the request fails, you get a 4xx or 5xx status and a JSON body with message. What each status means is in the error list.
Example:
curl -X POST "https://<hostname>.hakocms.net/admin/api/users/<id>/password-links" \ -H "Authorization: Bearer <access token>" \ -H "Content-Type: application/json" \ -d '{}'