Skip to content

Admin API: Entries

Operations that create, change, publish, and delete entries the same way as in the admin, and operations on revision history. Common rules (authentication, error format, dates and times) are in the Admin API reference.

The shape of an entry’s values (data) is described in Field types and value formats and Rich text format.

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 entries GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries
Create an entry (draft or published) POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries
Get an entry GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}
Delete an entry DELETE /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}
Save a draft PUT /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/draft
Discard the draft and go back to the published revision DELETE /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/draft
Publish an entry POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/publish
Set scheduled publishing and scheduled unpublishing PUT /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/reservation
List revisions of an entry GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/revisions
Get one revision of an entry with its values GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/revisions/{revision_id}
Unpublish an entry POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/unpublish
GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
limit query integer 0 or more
offset query integer 0 or more
q query string Full-text search
status query string published draft closed reserved, comma-separated (matches any of them)
orders query string updatedAt publishedAt createdAt. Prefix with - for descending order

Responses:

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

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

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)

Request body (application/json):

Name Type Required Constraints Description
data any Yes
id string or null If omitted, an ID is assigned automatically
publish boolean If true, publishes immediately. If false (default), creates the entry as a draft

Responses:

Status Body Reason
201 Entry (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 ID is already in use, you tried to create a second entry in a single, a unique value is duplicated, 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/<slug>/content-types/<endpoint>/entries" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{
"data": {}
}'
GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
id path string Yes ID

Responses:

Status Body Reason
200 Entry (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>/content-types/<endpoint>/entries/<id>" \
-H "Authorization: Bearer <access token>"
DELETE /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
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) Other entries refer to it (including drafts)

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>/content-types/<endpoint>/entries/<id>" \
-H "Authorization: Bearer <access token>"

Saves a draft. If the entry is published, the published revision stays as is, and the status becomes “公開中(下書きあり)” (Published, with draft).

PUT /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/draft
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
id path string Yes ID

Request body (application/json):

Name Type Required Constraints Description
data any Yes

Responses:

Status Body Reason
200 Entry (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) A unique value is duplicated, or the revision is outdated (someone else saved first)
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 PUT "https://<hostname>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/draft" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{
"data": {}
}'

Discard the draft and go back to the published revision

Section titled “Discard the draft and go back to the published revision”
DELETE /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/draft
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
id path string Yes ID

Responses:

Status Body Reason
200 Entry (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) There is no draft to discard

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>/content-types/<endpoint>/entries/<id>/draft" \
-H "Authorization: Bearer <access token>"
POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/publish
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
id path string Yes ID

Request body (application/json, optional):

PublishRequest or null.

Responses:

Status Body Reason
200 Entry (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) There are no values to publish, a unique value is duplicated, or the revision is outdated
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>/content-types/<endpoint>/entries/<id>/publish" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{}'

Set scheduled publishing and scheduled unpublishing

Section titled “Set scheduled publishing and scheduled unpublishing”

Fields you omit are not changed. Passing null cancels that schedule.

PUT /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/reservation
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
id path string Yes ID

Request body (application/json):

Name Type Required Constraints Description
closeAt string or null Date and time of scheduled unpublishing (RFC 3339). null cancels it. If omitted, it is not changed
publishAt string or null Date and time of scheduled publishing (RFC 3339). null cancels it. If omitted, it is not changed

Responses:

Status Body Reason
200 Entry (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) There are no values to publish on schedule
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 PUT "https://<hostname>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/reservation" \
-H "Authorization: Bearer <access token>" \
-H "Content-Type: application/json" \
-d '{}'

Values are not included. Get the values of one revision with GET .../revisions/{revision_id} (entries revisions get in the CLI). cursor is the last revision number on the previous page.

GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/revisions
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
id path string Yes ID
limit query integer 0 or more
cursor query string

Responses:

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

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>/content-types/<endpoint>/entries/<id>/revisions" \
-H "Authorization: Bearer <access token>"

Get one revision of an entry with its values

Section titled “Get one revision of an entry with its values”

Use this to compare with an earlier revision or to go back to an earlier revision.

GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/revisions/{revision_id}
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
id path string Yes ID
revision_id path string Yes ID of the revision

Responses:

Status Body Reason
200 Revision (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>/content-types/<endpoint>/entries/<id>/revisions/<revision_id>" \
-H "Authorization: Bearer <access token>"

Unpublishes the entry. The draft remains. If there is no draft, the published values become the draft.

POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/unpublish
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space
endpoint path string Yes Endpoint of the content type (such as blog-posts)
id path string Yes ID

Responses:

Status Body Reason
200 Entry (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) The entry is not published

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>/content-types/<endpoint>/entries/<id>/unpublish" \
-H "Authorization: Bearer <access token>"