Skip to content

Content API reference

The Content API is the API that sites and apps use to read and write entries and media with an API key. This page lists every operation and its rules. The steps for using them are on the pages linked from each item.

https://<hostname>.hakocms.net/api/v1

<hostname> is the hostname of your environment. It is the same as in the admin address https://<hostname>.hakocms.net/admin.

The space is determined by the API key. If you want to specify the space in the path, you can also use the form /s/<space slug>/api/v1/…. If you write a slug different from the key’s space, 401 is returned.

Send the API key in one of the following headers. For issuing API keys and their permissions, see Create API keys and set permissions.

Header Value
Authorization Bearer <API key>
X-HAKOCMS-API-KEY <API key>. When another authentication layer in front prevents using Authorization
  • When both are present, only X-HAKOCMS-API-KEY is used
  • When the key is missing, wrong, or revoked, 401 is returned
Key permission What it allows
read ([読み取り](Read)) Read published entries
preview ([プレビュー](Preview)) Also read drafts with preview=true. Also requires read
create ([作成](Create)) Create entries
update ([更新](Update)) Change and discard drafts
publish ([公開](Publish)) Publish, unpublish, and schedule
delete ([削除](Delete)) Delete entries
Media read create update delete List and get media, upload, change alternative text and tags, delete

You can call it from any origin (CORS: Access-Control-Allow-Origin: *). Only keys with just [読み取り] are safe to give to the browser.

<type> is the content type ID ([エンドポイント](Endpoint) on the screen), and <ID> is the entry ID.

Method and path What it does Permission On success Steps
GET /content/<type> List a collection. For a single, that one entry read 200 Get
GET /content/<type>/<ID> One entry of a collection read 200 Get
POST /content/<type> Create (draft) create 201, Location header Write
PUT /content/<type>/<ID> Replace the draft. Create it if it does not exist update (also create when creating) 200 or 201 Write
PATCH /content/<type>/<ID> Change part of the draft update 200 Write
PUT, PATCH /content/<single> Replace or partly change a single. Create it if it does not exist Same as above Same as above Write
POST /content/<type>/<ID>/publish Publish publish 200 Write
POST /content/<type>/<ID>/unpublish Unpublish publish 204 Write
PUT /content/<type>/<ID>/schedule Schedule the publish and unpublish dates and times publish 200 Write
DELETE /content/<type>/<ID>/draft Discard the draft update 204 Write
DELETE /content/<type>/<ID> Delete delete 204 Write
GET /media List media Media read 200
GET /media/<ID> One media item Media read 200
POST /media Upload (file in multipart/form-data) Media create 201, Location header
PATCH /media/<ID> Change alternative text and tags Media update 200
DELETE /media/<ID> Delete media. Media used in entries cannot be deleted (409) Media delete 204
GET /schema/openapi.json OpenAPI 3.1 built from the space’s content types Any permission 200
GET /schema/types.ts The same, as TypeScript types Any permission 200

Paths continue from the base URL /api/v1.

Parameter List Single entry, single Default Rules
limit ○ 20 0–100
offset ○ 0
order ○ -sys.publishedAt. By relevance if q is given Comma-separated. Prefix with - for descending
where ○ Filter expression
q ○ Full-text search terms. Separated by spaces, matches entries containing all of them
select ○ ○ All Keys to return, comma-separated. Use dots to go inside
include ○ ○ 1 Number of levels to expand references. 0–3
richText ○ ○ json json or html
preview ○ ○ false true returns drafts. Write true or false (1 or 0 returns 400)
  • Adding an unknown parameter returns 400
  • Adding a list-only parameter (limit offset order where q) to a single entry or a single also returns 400

For how to use them, see Filter, sort, and paginate, Use full-text search, Get referenced entries together, and Read drafts (preview).

sys.id sys.createdAt sys.updatedAt sys.publishedAt sys.firstPublishedAt, and text, text area, date and time, and number fields.

  • Strings are compared in byte order, numbers numerically, and dates and times chronologically
  • Entries without a value come last, in both ascending and descending order
What you want How to write it
Equal, not equal category = "tech", category != "tech"
Comparison price < 1000, price <= 1000, price > 0, price >= 0
Contains, does not contain title contains "Rust", title not contains "Rust"
Starts with title startsWith "Rust"
Matches any, matches none sys.id in ("a", "b"), category not in ("pr", "ad")
Has a value, has no value eyecatch exists, eyecatch not exists
Combining and, or, not, parentheses ( )
  • Wrap strings and dates in "…" or '…'. Write quotes inside as \" \', and \ as \\. Do not wrap numbers or true false
  • Write dates and times in RFC 3339, or as a date only (00:00 UTC on that day)
  • Precedence is not → and → or
  • Up to 30 conditions, 5 levels of nested parentheses and not, 2000 characters per expression, and 100 values in in
  • The operators available for each field type are in Field types and value formats
Parameter Default Rules
limit 20 1–100
cursor nextCursor from the previous response. When given, other filters are ignored and the rest is returned with the original conditions
kind image for images only
fileName Partial match on the file name. Case-insensitive
alt Partial match on the alternative text
tags Comma-separated. Media that have all the tags

A list is returned in the following form.

{ "items": [], "total": 42, "limit": 20, "offset": 0 }
Item Contents
items Array of entries
total Number of matches. The number before splitting with limit and offset
limit offset The values used

An entry has sys first, followed by the fields in schema order.

sys item Contents
id Entry ID
contentType Content type ID
createdAt Date and time created
updatedAt Date and time last saved
publishedAt Date and time the published revision was published. null if not published
firstPublishedAt Date and time first published. null if not published
version Revision number of the returned value. Used when writing to check that you do not overwrite someone else’s changes

All dates and times are UTC ISO 8601, with milliseconds (2026-10-08T06:10:00.000Z). Field value formats are in Field types and value formats.

Media are returned in the following form. A media list is { "items", "total", "limit", "nextCursor" }.

{
"sys": {
"id": "k2m9x0a1b2c3",
"createdAt": "2026-10-08T05:00:00.000Z",
"updatedAt": "2026-10-08T05:00:00.000Z"
},
"url": "https://<media host>/media/k2m9x0a1b2c3/hero.jpg",
"fileName": "hero.jpg",
"mimeType": "image/jpeg",
"size": 182044,
"kind": "image",
"width": 1600,
"height": 900,
"alt": "トップの写真",
"tags": ["top"]
}
Item Contents
url Delivery URL. On a different host from the admin. You can add transformation parameters (Transform and serve images)
fileName File name. Cannot be changed
mimeType Format detected from the content
size Size (bytes)
kind image (when the width and height are known) or file
width height Images only
alt tags Alternative text and tags

Uploaded media are public as soon as they are uploaded. Anyone who knows the URL can get them, without signing in or an API key.

  • Creating or changing an entry always produces a draft. Publish with publish
  • If you omit the entry ID, an ID is assigned. IDs are 1–50 characters of letters, digits, -, and _
  • Required fields are not checked for drafts. They are checked when you publish
  • PUT removes fields you did not send. PATCH changes only the fields you sent
  • If you add sys.version to the body, the write happens only when the current revision has that number. Otherwise, 409 is returned (PUT, PATCH, publish)
  • The body of publish can contain only sys.version and sys.firstPublishedAt (when you set the first publish date and time)
  • The body of a schedule (schedule) is { "publishAt", "closeAt" }. Omitted values are not changed, and null cancels. Dates and times must be in the future, and if both are given, publishAt comes first
  • Sending a field not in the schema returns 400
Limit When exceeded
URL length: 8 KB 414
Read response: 5 MB 400. Reduce with limit or select
One list: 100 entries limit up to 100

GET /schema/openapi.json returns OpenAPI 3.1 with the entry types for each content type in the space and the paths of the Content API and the media API. With it, you can generate clients and types with the tools for each language.

ターミナルウィンドウ
curl -fsS https://<hostname>.hakocms.net/api/v1/schema/openapi.json \
-H "Authorization: Bearer <API key>" \
-o hakocms-openapi.json
  • Type names are the content type ID in PascalCase (blog-posts becomes BlogPosts. If it starts with a digit, T is added in front)
  • When you change the schema, download it again. The definitions are built from the schema at the time you download them
  • You can also download them from the [API キー](API keys) screen in the admin

Within the same version (/api/v1), operations and items are only added. Items and operations are not removed, made required, or changed in type or meaning. When the format changes, it is announced in the Changelog.

Errors are returned in the form { "error": { "code", "message", "details" } }. Causes and fixes for each code are in Errors.