Configuration and authentication

Before running resource commands, configure the Product API endpoint and a personal access token, then discover and select a workspace with read-only commands. moi-cli saves these values in ~/.moi-cli.json; config show masks the token.

Configure connection information

These steps apply to the 0.1.0 package on the download page. A personal access token is a secret you create that lets the CLI authenticate as you. Create one under Access credentials, then replace the placeholder below with its value. Protect it like a password.

moi-cli config set-endpoint "https://api.moi.matrixorigin.cn/v5"
moi-cli config set-api-key "<personal-access-token>"

Use https://api.moi.matrixorigin.cn/v5 as the Product API Base URL. The CLI does not add a service address automatically. Pass the personal access token as its raw value: do not add a Bearer prefix or write the token to scripts, shell history, or source control.

List the workspaces visible to the current identity, then save the ID of the workspace to operate on:

moi-cli -o workspace list
moi-cli config set-workspace "<workspace-id-from-list>"

Verify the saved configuration:

moi-cli config show

The output shows the endpoint and workspace ID and masks api_key. Listing workspaces does not require a saved workspace ID; other workspace-scoped commands require all necessary configuration values.

Provide configuration for one command

You can supply the endpoint, token, or workspace for the current command without changing saved configuration:

moi-cli \
  -endpoint "https://api.moi.matrixorigin.cn/v5" \
  -api-key "<personal-access-token>" \
  -workspace-id "<workspace-id>" \
  workspace-member current-principal

Pass a token this way only in a secure execution environment. Shared terminals, CI logs, and process lists can expose command-line arguments; prefer protected configuration files or deployment-managed secret injection.

Configure a workspace role

To select the current role for a workspace, save the workspace and role relationship:

moi-cli config set-role "<workspace-id>" "<role-id>"

Use moi-cli config unset-role <workspace-id> to remove the saved role for that workspace. Role configuration affects only the specified workspace; when switching workspaces, confirm the role and permissions again.

Last updated on