Skip to content

Admin API: Space imports

Operations that import an exported file as a new space. 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 imports GET /admin/api/imports
Send a ZIP to import POST /admin/api/imports
List spaces whose import stopped GET /admin/api/imports/leftovers
Delete a space whose import stopped DELETE /admin/api/imports/leftovers/{slug}
Multipart upload settings GET /admin/api/imports/settings
Start a multipart upload POST /admin/api/imports/uploads
A multipart upload and its received parts GET /admin/api/imports/uploads/{id}
Complete a multipart upload POST /admin/api/imports/uploads/{id}/complete
Receive a part PUT /admin/api/imports/uploads/{id}/parts/{n}
Destination of a part POST /admin/api/imports/uploads/{id}/parts/{n}/target
Get one import GET /admin/api/imports/{id}
Delete an import record and its ZIP DELETE /admin/api/imports/{id}
Start importing a sent ZIP POST /admin/api/imports/{id}/start

Returns up to 20 items, newest first.

GET /admin/api/imports
  • Login: required (session or access token)

Responses:

Status Body Reason
200 TransferList (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)

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/imports" \
-H "Authorization: Bearer <access token>"

The body is the ZIP itself. Returns a summary of the contents. The import does not start yet. Start it with POST /imports/{id}/start (imports start in the CLI).

POST /admin/api/imports
  • Login: required (session or access token)

Request body (application/zip):

Send the file content as is.

Responses:

Status Body Reason
201 TransferView (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) Exceeds the amount that can be stored
413 Error (application/json) The file is too large

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/imports" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/zip" \
--data-binary "@<file>"

Spaces whose import stopped partway and that were left in the importing state.

GET /admin/api/imports/leftovers
  • Login: required (session or access token)

Responses:

Status Body Reason
200 LeftoverList (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)

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/imports/leftovers" \
-H "Authorization: Bearer <access token>"

Deletes what was imported partway, including the files in storage.

DELETE /admin/api/imports/leftovers/{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

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/imports/leftovers/<slug>" \
-H "Authorization: Bearer <access token>"

Values that the browser uses for checks (before sending).

GET /admin/api/imports/settings
  • Login: required (session or access token)

Responses:

Status Body Reason
200 UploadSettings (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)

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/imports/settings" \
-H "Authorization: Bearer <access token>"

Creates an unfinished upload.

POST /admin/api/imports/uploads
  • Login: required (session or access token)

Request body (application/json):

Name Type Required Constraints Description
fileName string Yes
size integer Yes 0 or more

Responses:

Status Body Reason
201 UploadView (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) There are too many unfinished uploads, or this exceeds the amount that can be stored
413 Error (application/json) The file is too large
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/imports/uploads" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{
"fileName": "<fileName>",
"size": 0
}'

The unfinished upload and the parts received.

GET /admin/api/imports/uploads/{id}
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
id path string Yes ID

Responses:

Status Body Reason
200 UploadView (application/json)
401 Error (application/json) Not logged in, or the access token is wrong, expired, or revoked
404 Error (application/json) Not found

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/imports/uploads/<id>" \
-H "Authorization: Bearer <access token>"

Marks the upload as finished. Checks that all parts are present, checks the ZIP’s table of contents and hako-space.json, and makes the import ready to start.

POST /admin/api/imports/uploads/{id}/complete
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
id path string Yes ID

Responses:

Status Body Reason
200 TransferView (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) Some parts have not arrived, or the upload is already finished

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/imports/uploads/<id>/complete" \
-H "Authorization: Bearer <access token>"

Receives the nth part (through the app). The size is checked with Content-Length before the body is read, and reading is cut off if the size goes over the limit partway through. If the SHA-256 matches, the part is stored (if a part with the same number is sent again, it is stored again).

PUT /admin/api/imports/uploads/{id}/parts/{n}
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
id path string Yes ID
n path string Yes Part number (starting from 1)

Request body (application/octet-stream):

Send the file content as is.

Responses:

Status Body Reason
204 None
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)
404 Error (application/json) Not found
413 Error (application/json) The part is larger than the set size

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 PUT "https://<hostname>.hakocms.net/admin/api/imports/uploads/<id>/parts/<n>" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/octet-stream" \
--data-binary "@<file>"

The destination to send the nth part to.

POST /admin/api/imports/uploads/{id}/parts/{n}/target
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
id path string Yes ID
n path string Yes Part number (starting from 1)

Request body (application/json):

Name Type Required Constraints Description
md5 string or null Required when sending directly to storage (GCS checks content only with MD5)
sha256 string Yes
size integer Yes 0 or more

Responses:

Status Body Reason
200 PartTarget (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)
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. The meaning of each status is in the list of errors.

Example:

ターミナルウィンドウ
curl -X POST "https://<hostname>.hakocms.net/admin/api/imports/uploads/<id>/parts/<n>/target" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{
"size": 0,
"sha256": "<sha256>"
}'
GET /admin/api/imports/{id}
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
id path string Yes ID

Responses:

Status Body Reason
200 TransferView (application/json)
401 Error (application/json) Not logged in, or the access token is wrong, expired, or revoked
404 Error (application/json) Not found

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/imports/<id>" \
-H "Authorization: Bearer <access token>"

An import that is waiting or running cannot be deleted (409).

DELETE /admin/api/imports/{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 import is waiting or running

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/imports/<id>" \
-H "Authorization: Bearer <access token>"

Returns 409 if the slug is already in use or the import has already started.

POST /admin/api/imports/{id}/start
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
id path string Yes ID

Request body (application/json):

Name Type Required Constraints Description
name string Yes Name of the space to create by importing
slug string Yes Slug of the space to create by importing

Responses:

Status Body Reason
202 TransferView (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)
404 Error (application/json) Not found
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/imports/<id>/start" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{
"slug": "<slug>",
"name": "<name>"
}'