Skip to content

Invite members and set roles with the CLI

Invite people to a space, and set what they can do with roles. You can do with commands what you can do in [メンバー](Members) in the admin. How roles work and how the built-in roles differ are explained in Invite members and choose roles.

  • You are logged in with hakocms-cli and have set the space (Log in with the CLI)
  • You have the [メンバーとロールの管理](Manage members and roles) permission in the space. Among the built-in roles, [オーナー](Owner) and [管理者](Admin) have it
  • You cannot invite someone with a role stronger than your own, or change someone whose role is stronger than yours
  1. Look up the IDs of the space’s roles.

    ターミナルウィンドウ
    hakocms-cli roles list
    ID NAME
    hpwlxw82lyzo owner
    l1flnze8uq8y admin
    xzread23pccy editor
    4coq44vlhdh2 viewer

    owner is owner, admin is admin, editor is editor, and viewer is viewer.

  2. Create an invitation by passing an email address and a role ID. Replace <role ID> with the ID you looked up in step 1.

    ターミナルウィンドウ
    hakocms-cli invitations create --email writer@example.com --role-id <role ID>
    id: 03ddcn6ai83d
    email: writer@example.com
    role: {"id":"xzread23pccy","name":"editor"}
    expiresAt: 2026-10-30T04:19:30.401Z
    url: https://<hostname>.hakocms.net/admin/invitations/hinv_Ab3dE7kQx2mP9sT4vW8yZc1fH6jL0nR5uX7bD3gK2qM
    emailSent: false
  3. When emailSent is false, give the acceptance link in url to the person yourself. When it is true, an email has reached the person.

  • The acceptance link is shown only this once. If you forget to note it, cancel the invitation and create it again
  • Invitations expire in 7 days
  • Only the person with the invited email address can accept the invitation

To invite many people at once, create invitations from a file (emails.txt) with one email address per line.

ターミナルウィンドウ
while read -r email; do
hakocms-cli invitations create --email "$email" --role-id <role ID> \
--jq '"\(.email) \(.url)"'
done < emails.txt

Each email address and its acceptance link are shown, one per line.

List the invitations that have not been accepted yet.

ターミナルウィンドウ
hakocms-cli invitations list
ID EMAIL ROLE NAME EXPIRES AT CREATED AT
03ddcn6ai83d writer@example.com editor 2026-10-30T04:19:30.401Z 2026-10-23T04:19:30.401Z

When you cancel an invitation, its acceptance link stops working.

ターミナルウィンドウ
hakocms-cli invitations delete <invitation ID>

Change a member’s role or remove a member

Section titled “Change a member’s role or remove a member”
ターミナルウィンドウ
hakocms-cli members list
USER ID USER EMAIL ROLE NAME JOINED AT
datlmiw39a7z you@example.com owner 2026-10-23T04:17:48.865Z

Change the role. <user ID> is the [USER ID] in the list.

ターミナルウィンドウ
hakocms-cli members update <user ID> --role-id <role ID>

Remove the member from the space. A removed person can no longer access the space, effective immediately.

ターミナルウィンドウ
hakocms-cli members remove <user ID>

You cannot change your own role or remove yourself. To leave a space yourself, use hakocms-cli members leave.

When the built-in roles are not enough, you can create a role that sets the allowed operations for each content type. The shape of the permissions is the same as on the [ロール](Roles) screen in the admin.

Check the values you can pass with the following command before you create one.

ターミナルウィンドウ
hakocms-cli roles create --help

The shape is explained in Invite members and choose roles and Admin API reference: roles.

In [メンバー](Members) in the admin, check that the invitations and member roles have changed.