Admin API: Spaces
Operations that create, get, and delete spaces. 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 spaces | GET /admin/api/spaces |
| Create a space and make the creator its owner | POST /admin/api/spaces |
| Get a space | GET /admin/api/spaces/{slug} |
| Delete a space | DELETE /admin/api/spaces/{slug} |
List spaces
Section titled “List spaces”The spaces you are a member of. For environment administrators, all spaces.
GET /admin/api/spaces- Login: required (session or access token)
Responses:
| Status | Body | Reason |
|---|---|---|
200 |
Array of SpaceView (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. The meaning of each status is in the list of errors.
Example:
curl "https://<hostname>.hakocms.net/admin/api/spaces" \ -H "Authorization: Bearer <access token>"Create a space and make the creator its owner
Section titled “Create a space and make the creator its owner”Creates a space and makes the creator its owner. Only environment administrators can do this.
POST /admin/api/spaces- Login: required (session or access token)
Request body (application/json):
| Name | Type | Required | Constraints | Description |
|---|---|---|---|---|
name |
string | Yes | Display name | |
slug |
string | Yes | Slug (the ID used in URLs) |
Responses:
| Status | Body | Reason |
|---|---|---|
201 |
SpaceView (application/json) |
|
400 |
Error (application/json) |
An input value breaks a rule (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) |
The slug is already in use. Or a usage limit was reached (limit in the body) |
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. The meaning of each status is in the list of errors.
Example:
curl -X POST "https://<hostname>.hakocms.net/admin/api/spaces" \ -H "Authorization: Bearer <access token>" \ -H "Content-Type: application/json" \ -d '{ "slug": "<slug>", "name": "<name>"}'Get a space
Section titled “Get a space”A space you are not a member of is treated as nonexistent and returns 404.
GET /admin/api/spaces/{slug}- 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 |
SpaceView (application/json) |
|
401 |
Error (application/json) |
Not logged in, or the access token is wrong, expired, or revoked |
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. The meaning of each status is in the list of errors.
Example:
curl "https://<hostname>.hakocms.net/admin/api/spaces/<slug>" \ -H "Authorization: Bearer <access token>"Delete a space
Section titled “Delete a space”Deletes all entries, media, and settings. This cannot be undone. Requires space.manage (owner among the default roles). Environment administrators who are not members can also do this.
DELETE /admin/api/spaces/{slug}- 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 |
|---|---|---|
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. The meaning of each status is in the list of errors.
Example:
curl -X DELETE "https://<hostname>.hakocms.net/admin/api/spaces/<slug>" \ -H "Authorization: Bearer <access token>"