Docs / Agents, CLI and API

CLI

Run Datum commands with JSON output, dry runs, and documented exit codes.

Overview

ocmgr is Datum’s command-line interface. The app image also contains the CLI. App capabilities have corresponding commands, except browser sign-in.

The CLI connects directly to Postgres. It requires the container or another machine with database access. Remote clients without database access can use REST or MCP.

Configure

Inside Docker

Run commands through the app container from the installation directory:

docker compose -f deploy/docker-compose.yml exec -T app ocmgr doctor --json

ocmgr is the image’s entry point. The container reads database settings from deploy/.env.

From a checkout

The CLI has no npm release yet.

Install dependencies. Build the CLI. Run its entry point:

pnpm install
pnpm -r --filter '@ocmgr/cli...' build
node packages/cli/dist/bin.js --help

The CLI needs these settings:

Setting Purpose
DATABASE_URL Identifies Postgres, such as postgres://user:pass@host:5432/ocmgr.
OCMGR_ACTOR Labels terminal changes in History. Defaults to the OS username; --actor <label> overrides it for one command.
OCMGR_WORKSPACE Selects a workspace ID. --workspace <id> can select it per command instead.
export DATABASE_URL=postgres://user:pass@host:5432/ocmgr
ocmgr workspace create --name "My community" --json
export OCMGR_WORKSPACE=<workspace id>

Recover a workspace ID with ocmgr workspace list --json. This operator command lists the instance’s workspaces without a selection. An unknown --workspace or OCMGR_WORKSPACE returns NOT_FOUND (exit 3), including in dry runs.

Basics

Identify terminal changes

Terminal changes record an operator label, shown as Sam (terminal) in History and notes. This label identifies a database operator, not a signed-in account. On a shared container, set OCMGR_ACTOR or pass --actor to distinguish operators who share its OS user. Use the same label to edit or delete a note you added.

ocmgr notes add member <memberId> --body "Follow up next week" --actor Sam --json
ocmgr notes update <noteId> --body "Follow up on Friday" --actor Sam --json
ocmgr notes delete <noteId> --actor Sam --json

Notes generate a request ID when you omit it. Supply --request-id with a stable value when your script retries the same note.

JSON output

Every command accepts --json. Results use stdout. Progress uses stderr.

Pipe JSON results to tools such as jq:

ocmgr members search ada --json | jq .

Dry runs

Commands that change data accept --dry-run. Most perform the work inside a transaction and roll it back. This produces realistic counts without retaining changes.

External operations need different handling. sink verify, sink test, sink backfill, and judgment eval report planned actions without contacting external systems. avatars hash skips writes. Destination commands report the intended request.

Errors and exit codes

With --json, failures write one error object to stderr:

{ "error": { "code": "NOT_FOUND", "message": "…", "hint": "…" } }

Read the hint for the corrective action. Scripts can also use the exit code.

Code Exit Meaning
FORBIDDEN 2 The caller lacks permission, such as note authorship or write scope.
USAGE / CONFIG 2 A flag, configuration value, database setting, workspace, or import checkpoint is invalid.
NOT_FOUND 3 The requested connection, workspace, or member does not exist in scope.
DATABASE 4 Postgres is unavailable, migrations are missing, or matching keys need rebuilding.
CONNECTOR 5 A source rejected the request, timed out, or returned invalid data.
CONFLICT 6 The request conflicts with existing state, such as an existing name, erased member, separation decision, or account limit.
INTERNAL 1 Datum encountered a bug.

Correct an invalid call before you retry it. To restart an old import checkpoint, use --cursor null.

For rebuilding keys, wait until ocmgr jobs status reports current keys. Retry connector failures after correcting credentials or resolving temporary source problems.

Follow the hint for conflicts; retries alone cannot resolve them. Report internal errors with their messages instead of retrying.

Manage workspace access

Operators with database access can manage users without an app session. Select a workspace first. These commands support --dry-run and record changes in History:

ocmgr admin user create --email [email protected] --json
ocmgr admin user list --json
ocmgr admin user invite --email [email protected] --role member --json
ocmgr admin user cancel-invite <invitationId> --json
ocmgr admin user role --email [email protected] --role owner --json
ocmgr admin user remove --email [email protected] --json

Invitations need an existing owner, and they expire after two days. When email is not available, invite returns the invitation link. Recipients accept in a browser. Datum refuses to remove or demote the last owner.

The invite, cancel-invite, role and remove commands have no equivalent for API keys or hosted MCP. On a hosted instance, use Settings → Members. Listing users is also available through list_workspace_users and GET /v1/workspace-users. See Team and roles.

Find a command

Use --help with any command. The tool reference lists commands beside their MCP tools and REST routes.

ocmgr --help
ocmgr sink --help
ocmgr sink create --help

FAQ

Can I point the CLI at my hosted workspace?

No. Hosted workspaces do not expose their database. Use REST or MCP with an API key.

Do I need the app running to use the CLI?

No. The CLI operates directly against the database. Commands that queue jobs require a worker to process them.

Run ocmgr worker for queue processing. Docker installations include a worker in the app.

Is there a command for everything in the app?

Browser sign-in is the exception. Run ocmgr admin user create --email [email protected] --json to create a user and receive a sign-in link.