Skip to content

Admin API: API keys

Operations to issue API keys for the Content API, change their permissions, and revoke them. Common rules (authentication, error format, dates and times) are in the Admin API reference.

How to set permissions is in Create API keys and set permissions.

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 API keys GET /admin/api/spaces/{slug}/api-keys
Issue an API key POST /admin/api/spaces/{slug}/api-keys
Change an API key’s name and permissions PATCH /admin/api/spaces/{slug}/api-keys/{id}
Revoke an API key DELETE /admin/api/spaces/{slug}/api-keys/{id}
Reactivate a revoked API key POST /admin/api/spaces/{slug}/api-keys/{id}/reactivate
GET /admin/api/spaces/{slug}/api-keys
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space

Responses:

Status Body Reason
200 Array of ApiKeyView (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. A space you are not a member of also returns 404

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/spaces/<slug>/api-keys" \
-H "Authorization: Bearer <access token>"
POST /admin/api/spaces/{slug}/api-keys
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space

Request body (application/json):

Name Type Required Constraints Description
name string Yes Name for telling it apart
permissions ApiKeyPermissions or null

Responses:

Status Body Reason
201 ApiKeyCreated (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. A space you are not a member of also returns 404
409 Error (application/json) A usage limit set by the operator was reached (the body’s limit has the limit’s name and value)
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/spaces/<slug>/api-keys" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{
"name": "<name>"
}'

Change an API key’s name and permissions

Section titled “Change an API key’s name and permissions”
PATCH /admin/api/spaces/{slug}/api-keys/{id}
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
id path string Yes ID

Request body (application/json):

Name Type Required Constraints Description
name string or null Name for telling it apart
permissions ApiKeyPermissions or null

Responses:

Status Body Reason
200 ApiKeyView (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. A space you are not a member of also returns 404
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 PATCH "https://<hostname>.hakocms.net/admin/api/spaces/<slug>/api-keys/<id>" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{}'

A revoked key can no longer be used. It stays in the list, and you can reactivate it with api-keys reactivate.

DELETE /admin/api/spaces/{slug}/api-keys/{id}
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
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. A space you are not a member of also returns 404

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/spaces/<slug>/api-keys/<id>" \
-H "Authorization: Bearer <access token>"

The same key can be used again.

POST /admin/api/spaces/{slug}/api-keys/{id}/reactivate
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
id path string Yes ID

Responses:

Status Body Reason
200 ApiKeyView (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. A space you are not a member of also returns 404
409 Error (application/json) A usage limit set by the operator was reached (the body’s limit has the limit’s name and value)

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/spaces/<slug>/api-keys/<id>/reactivate" \
-H "Authorization: Bearer <access token>"