Skip to content

Your first CLI session

On this page, you walk step by step through logging in to Hako CMS with hakocms-cli, then editing one entry and publishing it. It takes about 15 minutes.

  • Install hakocms-cli (Install the CLI)
  • Have a Hako CMS environment and a space that contains entries. If you do not have them yet, create a space, a content type, and an entry with the Quickstart. As in the Quickstart, this page uses blog as the space slug and posts as the content type ID
  • Be a member of that space with a role that can edit and publish entries (owner, admin, or editor)

The IDs, dates and times, and field values on this page are examples. Your environment shows different values.

In a terminal, run the following command. Replace <hostname> with the hostname of your environment. The hostname is the <hostname> part of the admin address https://<hostname>.hakocms.net/admin.

ターミナルウィンドウ
hakocms-cli auth login --host https://<hostname>.hakocms.net

A confirmation code and a URL are shown as follows, and a browser opens.

First check this code in the browser: DCHP-QPXW
Approve the login at:
https://<hostname>.hakocms.net/admin/cli-login?code=DCHP-QPXW
Waiting for approval…

The browser shows the [CLI のログイン](CLI login) screen. If you are not logged in to the admin, log in first.

  1. Check that the code on the screen matches the code shown in the terminal (DCHP-QPXW in this example)
  2. Press [許可する](Allow). “許可しました。端末に戻ってください” (Approved. Return to your terminal.) is shown

When you go back to the terminal, it shows the following.

✓ Logged in to <hostname>.hakocms.net (https://<hostname>.hakocms.net) as you@example.com

If a browser does not open, open the URL shown in the terminal in a browser on your computer. The confirmation code expires in 10 minutes.

List the spaces in the environment you logged in to.

ターミナルウィンドウ
hakocms-cli spaces list

The spaces you are a member of are shown.

ID SLUG NAME ROLE CREATED AT
sdbm329n7t7o blog ブログ owner 2026-10-23T04:17:48.862Z

Set the space you will use. Once you set it, you do not need to add --space blog to every command.

ターミナルウィンドウ
hakocms-cli spaces use blog
✓ Using the space blog on <hostname>.hakocms.net

List the content types in the space.

ターミナルウィンドウ
hakocms-cli content-types list
ID ENDPOINT NAME KIND UPDATED AT CREATED AT
k4xst7lr0ikx posts 記事 collection 2026-10-23T04:18:29.560Z 2026-10-23T04:18:29.560Z

The [ENDPOINT] column is the content type ID. List the entries in posts. Specify the content type with --type (short form -t).

ターミナルウィンドウ
hakocms-cli entries list -t posts
ID STATUS UPDATED AT CREATED AT
iazte4ghzm55 draft 2026-10-23T04:18:29.640Z 2026-10-23T04:18:29.640Z

The [ID] on the left is the entry ID. You use it in the next step.

Look at the entry’s values. Replace <entry ID> with the ID shown in step 3.

ターミナルウィンドウ
hakocms-cli entries get <entry ID> -t posts
id: iazte4ghzm55
contentTypeId: k4xst7lr0ikx
status: draft
published:
draft: {"title":"はじめての記事","body":"CLIから書きました"}
createdAt: 2026-10-23T04:18:29.640Z
updatedAt: 2026-10-23T04:18:29.640Z
publishedAt:
revisedAt:
reservation: {"publishAt":null,"closeAt":null,"error":null,"failedAt":null}

Change the title. Pass a field ID and a value joined with = to --set.

ターミナルウィンドウ
hakocms-cli entries update <entry ID> -t posts --set title=はじめての記事(直した)

The output shows that title in the draft value changed. The field you did not specify (body) stays as it was.

status: draft
draft: {"title":"はじめての記事(直した)","body":"CLIから書きました"}

At this point, the change is only saved as a draft. Like [保存](Save) in the admin, it does not appear on your site yet.

ターミナルウィンドウ
hakocms-cli entries publish <entry ID> -t posts

status becomes published, and published holds the current values.

status: published
published: {"title":"はじめての記事(直した)","body":"CLIから書きました"}
draft:
publishedAt: 2026-10-23T04:18:42.148Z

In the admin, open the entry in [記事](Articles) in blog. The title is now “はじめての記事(直した)”, and the entry is published.

You can also retrieve it from the Content API (Read entries).

ターミナルウィンドウ
curl https://<hostname>.hakocms.net/api/v1/content/posts/<entry ID> \
-H "Authorization: Bearer <API key>"