Skip to content

Admin API: Schema applies

Operations to apply a schema file to an existing 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 schema applies GET /admin/api/spaces/{slug}/schema-applies
Send a schema file and compute the diff POST /admin/api/spaces/{slug}/schema-applies
Get a schema apply GET /admin/api/spaces/{slug}/schema-applies/{id}
Delete a schema apply record DELETE /admin/api/spaces/{slug}/schema-applies/{id}
Accept the diff and start the schema apply POST /admin/api/spaces/{slug}/schema-applies/{id}/apply

Returns up to 20 items, newest first.

GET /admin/api/spaces/{slug}/schema-applies
  • 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 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)
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>/schema-applies" \
-H "Authorization: Bearer <access token>"

The diff is computed in a job. Check the result with schema-applies get.

POST /admin/api/spaces/{slug}/schema-applies
  • 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):

Object.

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. 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. The meaning of each status is in the list of errors.

Example:

ターミナルウィンドウ
curl -X POST "https://<hostname>.hakocms.net/admin/api/spaces/<slug>/schema-applies" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{}'
GET /admin/api/spaces/{slug}/schema-applies/{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
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. 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>/schema-applies/<id>" \
-H "Authorization: Bearer <access token>"

Queued or running ones cannot be deleted (409).

DELETE /admin/api/spaces/{slug}/schema-applies/{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
409 Error (application/json) Queued 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/spaces/<slug>/schema-applies/<id>" \
-H "Authorization: Bearer <access token>"

Accept the diff and start the schema apply

Section titled “Accept the diff and start the schema apply”

Returns 409 in these cases: the diff is not ready yet, the apply has already started, there are changes that cannot be applied even with confirm or prune, there is nothing to apply, or applying would exceed the limit on the number of content types. When there are changes that cannot be applied, message has one reason per line. When the limit would be exceeded, limit has the limit’s name and value.

POST /admin/api/spaces/{slug}/schema-applies/{id}/apply
  • 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
confirm boolean Also apply changes that current entries violate. If omitted, false
prune boolean Delete content types that disappear (delete), along with their entries. If omitted, false

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. A space you are not a member of also returns 404
409 Error (application/json) The diff is not finished yet, or the apply has already started
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/<slug>/schema-applies/<id>/apply" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{}'