Admin API: Login and access tokens
Operations to log in, log out, get the logged-in user, and create, list, and revoke access tokens. 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 |
|---|---|
| Log in with an email address and password and issue a session cookie | POST /admin/api/auth/login |
| Log out | POST /admin/api/auth/logout |
| Features available on the login screen | GET /admin/api/auth/settings |
| Start a CLI login | POST /admin/api/cli-logins |
| Receive the result of a CLI login | POST /admin/api/cli-logins/token |
| Logged-in user | GET /admin/api/me |
| List your access tokens | GET /admin/api/me/access-tokens |
| Create an access token (admin session only) | POST /admin/api/me/access-tokens |
| Revoke your access token | DELETE /admin/api/me/access-tokens/{id} |
Log in with an email address and password and issue a session cookie
Section titled “Log in with an email address and password and issue a session cookie”POST /admin/api/auth/login- Login: not required
Request body (application/json):
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
email |
string | Yes | ||
password |
string | Yes |
Responses:
| Status | Body | Reason |
|---|---|---|
200 |
MeResponse (application/json) |
|
400 |
Error (application/json) |
The input values break the rules (including JSON syntax errors). Errors with their locations are in issues |
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) |
429 |
Error (application/json) |
Too many failed logins. Try again after the number of seconds in Retry-After |
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/auth/login" \ -H "Content-Type: application/json" \ -d '{ "email": "<email>", "password": "<password>"}'Log out
Section titled “Log out”Logs out. If you call it with an access token, that token is revoked.
POST /admin/api/auth/logout- Login: required (session or access token)
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) |
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/auth/logout" \ -H "Authorization: Bearer <access token>"Features available on the login screen
Section titled “Features available on the login screen”GET /admin/api/auth/settings- Login: not required
Responses:
| Status | Body | Reason |
|---|---|---|
200 |
AuthSettings (application/json) |
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/auth/settings"Start a CLI login
Section titled “Start a CLI login”Starts a CLI login. No login is needed (the CLI does not have a token yet)
POST /admin/api/cli-logins- Login: not required
Request body (application/json):
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
clientName |
string | Yes | Used as the token’s name (the CLI sends the computer’s name) |
Responses:
| Status | Body | Reason |
|---|---|---|
201 |
StartLoginResponse (application/json) |
|
400 |
Error (application/json) |
The input values break the rules (including JSON syntax errors). Errors with their locations are in issues |
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/cli-logins" \ -H "Content-Type: application/json" \ -d '{ "clientName": "<clientName>"}'Receive the result of a CLI login
Section titled “Receive the result of a CLI login”The CLI polls for the result. If the login was approved, a token is created and returned here (only once)
POST /admin/api/cli-logins/token- Login: not required
Request body (application/json):
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
pollToken |
string | Yes |
Responses:
| Status | Body | Reason |
|---|---|---|
200 |
PollResponse (application/json) |
|
400 |
Error (application/json) |
The input values break the rules (including JSON syntax errors). Errors with their locations are in issues |
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/cli-logins/token" \ -H "Content-Type: application/json" \ -d '{ "pollToken": "<pollToken>"}'Logged-in user
Section titled “Logged-in user”The logged-in user and the spaces the user is a member of.
GET /admin/api/me- Login: required (session or access token)
Responses:
| Status | Body | Reason |
|---|---|---|
200 |
MeResponse (application/json) |
|
401 |
Error (application/json) |
Not logged in, or the access token is wrong, expired, or revoked |
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/me" \ -H "Authorization: Bearer <access token>"List your access tokens
Section titled “List your access tokens”GET /admin/api/me/access-tokens- Login: required (session or access token)
Responses:
| Status | Body | Reason |
|---|---|---|
200 |
Array of AccessToken (application/json) |
|
401 |
Error (application/json) |
Not logged in, or the access token is wrong, expired, or revoked |
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/me/access-tokens" \ -H "Authorization: Bearer <access token>"Create an access token (admin session only)
Section titled “Create an access token (admin session only)”POST /admin/api/me/access-tokens- Login: required (session or access token)
Request body (application/json):
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
expiresIn |
ExpiresIn or null | |||
name |
string | Yes | ||
scope |
TokenScope or null |
Responses:
| Status | Body | Reason |
|---|---|---|
201 |
AccessTokenCreated (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) |
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/me/access-tokens" \ -H "Authorization: Bearer <access token>" \ -H "Content-Type: application/json" \ -d '{ "name": "<name>"}'Revoke your access token
Section titled “Revoke your access token”DELETE /admin/api/me/access-tokens/{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 |
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/me/access-tokens/<id>" \ -H "Authorization: Bearer <access token>"