Edit and retrieve entries in bulk
With hakocms-cli, you can do in bulk the work that takes a long time when you fix entries one at a time in the admin. The examples on this page use blog as the space and posts as the content type ID.
Prerequisites
Section titled “Prerequisites”- You are logged in with
hakocms-cliand have set the space (hakocms-cli spaces use blog; see Log in with the CLI). If you have not set it, add--space blogto each command - You have a role that can edit and publish entries (owner, admin, or editor)
- Before you run a bulk operation, try it on a small number of entries. Deletions cannot be undone
List with filters
Section titled “List with filters”By default, a list returns 30 entries. Use --all to go through all pages.
hakocms-cli entries list -t posts --all| Filter | Flag | Example |
|---|---|---|
| Status | --status |
--status draft (draft), --status published,closed (entries that match any of them) |
| Words | --query |
--query お知らせ (full-text search) |
| Order | --orders |
--orders -updatedAt (most recently updated first; - means descending) |
| Count | --limit |
--limit 100 |
The status values are draft (draft), published (published), closed (unpublished), and reserved (waiting for scheduled publishing). When a published entry has a draft, the [STATUS] column in the list shows published_with_draft.
Retrieve only the IDs
Section titled “Retrieve only the IDs”With --jq, you can filter JSON with a jq expression. You do not need to install jq separately.
hakocms-cli entries list -t posts --status draft --all --jq '.[].id'The IDs are shown one per line.
wsa5cu2ittq59ngd93ymaerrhfyrv6ip6ol0Publish in bulk
Section titled “Publish in bulk”Publish all draft entries. Pass the IDs you retrieved above to entries publish one at a time.
hakocms-cli entries list -t posts --status draft --all --jq '.[].id' | while read -r id; do hakocms-cli entries publish "$id" -t posts --jq '"\(.id) \(.status)"' doneThe ID and status of each published entry are shown.
wsa5cu2ittq5 published9ngd93ymaerr publishedhfyrv6ip6ol0 publishedIf an entry cannot be published (for example, a required field is empty), the reason is shown on that line and the loop moves on to the next entry. Because --jq is set, the reason is shown as JSON.
{"error":{"status":400,"message":"title: is required"}}In the same way, you can run entries unpublish (unpublish) and entries delete (delete) in bulk. When you delete, the CLI asks for confirmation for each entry. It cannot ask outside a terminal (in a pipe or a script), so add --force.
Change values in bulk
Section titled “Change values in bulk”entries update layers the --set values over the current values and saves the result as a draft. Fields you do not specify stay as they are.
hakocms-cli entries update <entry ID> -t posts --set body=書き換えた本文- A
--setvalue is sent as JSON if it can be read as JSON, and as a string otherwise.--set count=3is a number,--set featured=trueis a boolean,--set tags='["news","tech"]'is an array, and--set title=hellois a string - To set the string
3ortrue, write it as a JSON string (--set code='"3"') - When you change a published entry, the published revision stays as it is, and a draft is created (the status is
published_with_draft). To publish right away, add--publish
This example appends the same sentence to the end of body in every entry.
hakocms-cli entries list -t posts --all --jq '.[].id' | while read -r id; do body=$(hakocms-cli entries get "$id" -t posts \ --jq '(.draft // .published).body // ""') hakocms-cli entries update "$id" -t posts \ --set "body=${body}(この記事は 2026 年 10 月に更新しました)" --jq .id done(.draft // .published) uses the draft’s values if there is a draft, and the published revision’s values otherwise.
Retrieve as JSON
Section titled “Retrieve as JSON”You can retrieve entries as JSON and pass them to other tools. --json outputs the Admin API response as it is (for a list, an array of entries).
hakocms-cli entries list -t posts --all --json > posts.jsonTo output only the items you need, as one JSON object per line, use tojson.
hakocms-cli entries list -t posts --all \ --jq '.[] | {id, title: .published.title} | tojson'{"id":"hfyrv6ip6ol0","title":"お知らせ 1"}{"id":"9ngd93ymaerr","title":"お知らせ 2"}{"id":"wsa5cu2ittq5","title":"お知らせ 3"}To retrieve entries in the form you show on your site (with references expanded and so on), use the Content API instead of the CLI (Read entries). To copy a whole space to another environment, use hakocms-cli exports create and imports create (CLI command reference: exports).
Create from files
Section titled “Create from files”Write the values in a JSON file and pass it with --data @<file>. To pass them on standard input, use --data -.
{ "title": "ファイルから", "body": "JSON で渡しました" }hakocms-cli entries create -t posts --data @post.json --publishWith --publish, the entry is published instead of saved as a draft. Without it, the entry is a draft.
When you move from another CMS, split the data into one file per entry, then pass each file to entries create in a loop.
for f in export/*.json; do hakocms-cli entries create -t posts --data "@$f" --jq .iddoneThe shapes of field values (images, references, rich text, and so on) are in Field types and value formats and Rich text format. Upload images first, then put their URL in the value in the form {"url": "<URL>"} (Upload media with the CLI).
Edit in an editor
Section titled “Edit in an editor”entries edit writes the entry’s values to a JSON file and opens it in an editor. When you save and close it, the values are saved as a draft.
hakocms-cli entries edit <entry ID> -t postsThe editor is chosen by the environment variable VISUAL, or EDITOR if VISUAL is not set (export EDITOR=vim).
Set scheduled publishing
Section titled “Set scheduled publishing”hakocms-cli entries schedule <entry ID> -t posts --publish-at 2026-11-01T09:00:00+09:00-
Write the date and time in RFC 3339 format with a time zone offset (
+09:00for Japan time) -
The date and time to unpublish is
--close-at. Both must be within 1 year from now -
To cancel a schedule, pass
nullwith--dataターミナルウィンドウ hakocms-cli entries schedule <entry ID> -t posts --data '{"closeAt":null}'
Verify
Section titled “Verify”In the admin, open the list of entries for the content type, and check that the statuses and values have changed. From the CLI, list the entries with the same filters and count them.
hakocms-cli entries list -t posts --status draft --all --jq 'length'