Write and publish entries through the API
With the Content API, you can not only read entries but also create, change, and publish them. Use this to import entries from other systems or to build content submission tools.
Entries you create or change always become drafts. To publish, call the publish operation separately.
Before you begin
Section titled “Before you begin”- An API key with the permissions for the operation. For how to set permissions, see Create API keys and set permissions
| Operation | Required permission |
|---|---|
| Create | [作成](Create) |
| Change, discard a draft | [更新](Update). When you create an entry with PUT, also [作成](Create) |
| Publish, unpublish, schedule | [公開](Publish) |
| Delete | [削除](Delete) |
- Use keys with write permissions only on your site’s server or in your tools. Do not give them to the browser.
In the examples below, replace <hostname> with the hostname of your environment and <API key> with a key that has write permissions. The examples use the content type ID “posts” and the fields “title” (text) and “body” (rich text).
Operations
Section titled “Operations”| Operation | Method and URL | What is returned |
|---|---|---|
| Create | POST /api/v1/content/<content type ID> |
201 and the entry |
| Replace, or create if it does not exist | PUT /api/v1/content/<content type ID>/<entry ID> |
200 or 201 and the entry |
| Change part | PATCH /api/v1/content/<content type ID>/<entry ID> |
200 and the entry |
| Publish | POST /api/v1/content/<content type ID>/<entry ID>/publish |
200 and the entry |
| Unpublish | POST /api/v1/content/<content type ID>/<entry ID>/unpublish |
204 |
| Discard the draft | DELETE /api/v1/content/<content type ID>/<entry ID>/draft |
204 |
| Delete | DELETE /api/v1/content/<content type ID>/<entry ID> |
204 |
| Schedule publishing | PUT /api/v1/content/<content type ID>/<entry ID>/schedule |
200 |
The returned entry has the same values as when you read it with preview=true. References are returned without being expanded.
Create an entry
Section titled “Create an entry”Create an entry with the entry ID “hello” as a draft. You can send the body as HTML.
curl https://<hostname>.hakocms.net/api/v1/content/posts \ -H "Authorization: Bearer <API key>" \ -H "Content-Type: application/json" \ -d '{"sys":{"id":"hello"},"title":"こんにちは","body":"<p>本文</p>"}'You get 201 and the created entry. The Location header has the entry’s URL (/api/v1/content/posts/hello).
{ "sys": { "id": "hello", "contentType": "posts", "createdAt": "2026-10-08T05:00:00.000Z", "updatedAt": "2026-10-08T05:00:00.000Z", "publishedAt": null, "firstPublishedAt": null, "version": 1 }, "title": "こんにちは", "body": { "type": "doc", "content": [ { "type": "paragraph", "content": [{ "type": "text", "text": "本文" }] } ] }}- If you omit
sys.id, an entry ID is assigned automatically. An entry ID can be 1–50 characters of letters, digits,-, and_ - Required fields are not checked for drafts. They are checked when you publish
- You cannot use
POSTfor a single content type. UsePUTorPATCH
Change an entry
Section titled “Change an entry”There are two ways to change an entry.
| Fields you did not send | When the entry does not exist | |
|---|---|---|
PUT |
Removed. Replaced with the values you sent | Creates it (201) |
PATCH |
Kept. Only the fields you sent change | 404. For a single, creates it |
Change only the title.
curl -X PATCH https://<hostname>.hakocms.net/api/v1/content/posts/hello \ -H "Authorization: Bearer <API key>" \ -H "Content-Type: application/json" \ -d '{"title":"直したタイトル"}'You get 200 and the entry after the change.
- If you change a published entry, it becomes “公開中(下書きあり)” (Published (with draft)). The published values do not change until you publish
- You can also save a draft for an unpublished entry
- If you put
sys.idin the body, make it the same as the entry ID in the URL. If it differs, you get400. So that you can send a read response back as is,syskeys such ascontentTypeandcreatedAtare ignored - With
PATCH, an empty body gives400 - For a single, you can send
PUTorPATCHto the URL without an entry ID (/api/v1/content/<content type ID>)
To clear a value with PATCH, send null for that field. For an array, send [] to make it empty.
{ "eyecatch": null, "tags": [] }Do not overwrite other people’s changes (sys.version)
Section titled “Do not overwrite other people’s changes (sys.version)”If you put sys.version in the body, the write happens only when the entry’s current revision has that number. If someone else or the admin changed the entry between your read and your write, you get 409 and nothing is written.
curl -X PATCH https://<hostname>.hakocms.net/api/v1/content/posts/hello \ -H "Authorization: Bearer <API key>" \ -H "Content-Type: application/json" \ -d '{"sys":{"version":3},"title":"直したタイトル"}'The revision number is sys.version when you read with preview=true. It is the draft’s revision if there is a draft, and otherwise the published revision. You can use it with PUT, PATCH, and publish.
If you get 409 with version was changed by someone else, read the entry again, reapply the changes you want, and send again.
Publish
Section titled “Publish”Publish the current draft. If there is no draft, the current published values are published again. You can omit the body.
curl -X POST \ https://<hostname>.hakocms.net/api/v1/content/posts/hello/publish \ -H "Authorization: Bearer <API key>"You get 200 and the published entry.
The body can have sys.version and sys.firstPublishedAt. When you move from another CMS and want to keep the original publish date, put it in sys.firstPublishedAt.
curl https://<hostname>.hakocms.net/api/v1/content/posts/hello/publish \ -H "Authorization: Bearer <API key>" \ -H "Content-Type: application/json" \ -d '{"sys":{"firstPublishedAt":"2020-04-23T14:32:38.163Z"}}'- If the values to publish do not fit the schema, such as a missing required field, you get
400 - If there is nothing to publish, you get
409 - To publish a single, also send it to the
/<entry ID>/publishURL, using itssys.id
Unpublish, discard a draft, delete
Section titled “Unpublish, discard a draft, delete”Unpublish an entry.
curl -X POST \ https://<hostname>.hakocms.net/api/v1/content/posts/hello/unpublish \ -H "Authorization: Bearer <API key>"Discard the draft and go back to the published values.
curl -X DELETE \ https://<hostname>.hakocms.net/api/v1/content/posts/hello/draft \ -H "Authorization: Bearer <API key>"Delete an entry.
curl -X DELETE https://<hostname>.hakocms.net/api/v1/content/posts/hello \ -H "Authorization: Bearer <API key>"Each returns 204 on success. There is no body.
You get 409 in these cases:
- There is no draft to discard
- You tried to unpublish an entry that is not published
- You tried to delete an entry that other entries reference
Schedule publishing
Section titled “Schedule publishing”You can schedule when to publish and when to unpublish.
curl -X PUT \ https://<hostname>.hakocms.net/api/v1/content/posts/hello/schedule \ -H "Authorization: Bearer <API key>" \ -H "Content-Type: application/json" \ -d '{"publishAt":"2026-10-20T09:00:00+09:00","closeAt":null}'You get 200 and the scheduled publishAt and closeAt.
publishAtis when to publish, andcloseAtis when to unpublish- Keys you do not send do not change. Sending
nullcancels that schedule. Sending an unknown key gives422 - Use a time in the future. When you set both, make
publishAtearlier thancloseAt. Otherwise, you get400 - When you set
publishAt, Hako CMS checks at scheduling time whether the current latest values can be published (whether the required fields are filled, and so on). If they cannot be published, you get an error and nothing is scheduled - At the scheduled time, the latest draft at that moment is published. If it cannot be published then, the schedule is removed. If you have set up a webhook, you are notified with the event
entry.schedule_failed
Value formats you send
Section titled “Value formats you send”You can send values back in the same shape as read responses. You can also use the following forms.
| Field type | Value to send |
|---|---|
| Text, text area | A string |
| Rich text | Hako Rich Text v1 JSON, or an HTML string |
| Image, file | { "url": "<URL>" }, or a URL string |
| Multiple images | An array of images |
| Date and time | ISO 8601. Stored in UTC |
| Boolean, number | true or false, a number |
| Select | An array of the values to select |
| Reference | The referenced entry ID, or { "sys": { "id": "<entry ID>" } } |
| Multiple references | An array of references |
| Custom | An object with fieldId |
| Repeater | An array of custom values |
- If you send rich text as HTML, it is converted to a form the editor can handle and saved. For elements it cannot handle, only the text inside is kept, and
<script>and the like are dropped - If you send rich text as JSON, it is checked against the Hako Rich Text v1 rules. If it does not fit, you get
400, anddetails.issuesshows what does not fit (such asbody.content[0].attrs.level) - Images and files can also take external URLs. When you put in a Hako CMS media URL, use media from the same space. Put images in image fields. Width and height (
fileSizefor files) are filled in from the media’s values - Sending a field that is not in the schema gives
400
Check the result
Section titled “Check the result”After writing, read with preview=true to check the draft values (Read drafts). After publishing, read without preview=true to check the published values (Read entries).
If something goes wrong, see the following table.
| What you got | Cause | Fix |
|---|---|---|
403 forbidden (this API key cannot create entries and others) |
The key does not have permission for the operation | On the [API キー](API keys) screen, check the key’s permissions |
400 bad_request |
A value in the body does not fit the schema, there is an unknown field, sys.id differs from the URL, and so on |
Use message and path in details.issues to find which field |
409 conflict |
An entry ID or unique value is duplicated, sys.version differs, or the operation is not possible in the current state |
Look at message and read the entry again |
422 unprocessable_entity |
The shape of the body is wrong (an unknown key, and so on) | Look at message and check the spelling of the keys in the body |
For other errors, see Errors.