Skip to main content

Commands Reference

Global Flags

Authenticate once with nexspace login (see CLI Authentication); commands reuse the stored credential automatically.

Agent loop

Errors return { "error", "code", "next" } with exit 2 (auth) or 3 (input).

Environment


Auth

nexspace login

Authenticate. Defaults to the browser device-code OAuth flow; pass --token to store an API key/PAT instead. Credentials are saved to the OS keychain when available (falling back to ~/.nexspace/config.json).

nexspace login-device

Explicit alias for the OAuth device-code login flow.

nexspace logout

Remove stored credentials.

nexspace whoami

Print the identity the current credential authenticates as.

Discovery

nexspace search <query>

Rank MCP tools by natural-language intent.

nexspace mcp tools

List available MCP tools.

nexspace mcp schema <toolName>

Print inputSchema (and outputSchema when present) for a tool.

nexspace mcp call <toolName>

Invoke an MCP tool by name. Under --dry-run the named tool is never called, read-only or not. Where a preview sibling exists (runPayrollpreviewPayrollRun) the CLI calls that instead and returns its result under result; otherwise it returns { dryRun: true, valid: true, mutating } with nothing executed.

Context

nexspace context use

Pin a facility so shifts, staff, and payroll commands default to it instead of repeating --facility-id on every call.
There is no --org-id. Org scope is derived from the credential you logged in with and cannot be overridden per-request; the few super-admin REST routes that accept a narrowing override take it explicitly as nexspace api GET /api/crm/... -q orgUnitId=N.

Facilities

nexspace facilities list / get


Staff

nexspace staff search / get / find-credentialed / credentials-expiring


Shifts

nexspace shifts list / get / fill / propose / swap / coverage

Use --dry-run on mutating verbs before the real call.

Credentials

nexspace credentials verify


Payroll

nexspace payroll preview / run

Always preview (or --dry-run on run) before committing.

CRM

nexspace crm leads-search / leads-qualify


Notify

nexspace notify shift-swap

This verb sends real SMS and push notifications, so it validates strictly rather than notifying a subset: a non-numeric entry in --staff-ids or an unrecognized --channels value exits 3 (VALIDATION_FAILED) and sends nothing.

API Keys

nexspace api-keys list / create / revoke


Webhooks & events

nexspace webhooks list / create / delete / test

nexspace events listen

Local receiver + temporary subscription. Verifies X-NexSpace-Signature when the create response includes signingSecret. Cloud API hosts cannot reach 127.0.0.1 — pass --forward-url (ngrok / cloudflared).

nexspace events trigger

Fire a test delivery against an existing subscription.
See also Webhooks.

Approvals, audit & logs

Admin-gated AI action surfaces (same APIs as Admin → AI Config → Approvals). These are not the same as nexspace agents approvals (headless run resolution under agents:approve).

nexspace approvals list / approve / reject

nexspace audit list

nexspace logs tail

Polls GET /api/ai/audit as JSONL (there is no general HTTP request-log API).

Agents

Headless agent runs (distinct from admin AI approvals above). Requires agents:run / agents:approve / agents.manage as noted. See also Agent runs.

nexspace agents run <agentId>

Start a headless agent run and stream its events to completion. Backed by POST /api/agents/{id}/runs + the run SSE stream (GET /api/agents/{id}/runs/{runId}/stream); requires the agents:run scope. In stream-json mode each event is emitted as one JSON object per line — ideal for agents/CI that consume the run incrementally. A run_started line is emitted first, then one line per status / assistant / tool_call / result / done event. The command exits non-zero if the run ends in error or rejected.

nexspace agents runs <list|get|cancel|approvals>

Inspect and control runs after they start. All require the agents:run scope and only operate on runs owned by the credential’s user.

nexspace agents approvals <approve|reject> <approvalId>

Resolve a pending_approval action raised by one of your runs. Requires the agents:approve scope. Approving executes the deferred tool and resumes the run once all its approvals are terminal; rejecting terminates the run as rejected.

nexspace agents triggers <list|create|update|delete|toggle|run-now>

Manage automation triggers that fire an agent on a cron schedule or business event through the durable headless-run path. Requires the agents.manage permission and the ai suite. create/update accept: --type, --cron, --timezone, --event-type, --event-filters (JSON), --run-as-user-id, --facility-id, --seed-message, --no-activate (create only). Schedule triggers need --cron; event triggers need --event-type.

Fixtures & conformance

nexspace fixtures

Sandbox / webhook helpers for agent demos.
See Sandbox.

nexspace conformance run

Runs the Governance Conformance Suite (Vitest) from a NexSpace checkout.
Exits non-zero when the suite fails, in every output mode — safe to use as a CI gate. The JSON payload also reports coverage, because a green suite is not the same as a fully enforced one: Gate on fullyEnforced rather than the exit code alone if you need every clause actually enforced; the exit code ignores pending clauses.

Agent helpers

nexspace skill install

Install the nexspace-operations skill for Cursor and/or Claude Code.

nexspace agent playbook

Print the short search → schema → dry-run → call reminder.

nexspace run

Inline agent scripting with injected execute, search, api, and schema. Useful for fan-out; not a production runtime SLA — prefer MCP/REST for stable integrations.
--dry-run matches mcp call --dry-run: every execute() returns a { dryRun: true, skipped: true } envelope instead of running the tool — including read-only tools, so a mis-classified verb can’t slip through. The injected api() helper still performs GETs (discovery stays useful) but short-circuits POST / PUT / PATCH / DELETE the same way. search() and schema() are unaffected.

Escape hatch

nexspace api <METHOD> <PATH>

Authenticated passthrough to any API endpoint.
Paths are resolved against the base URL you logged in with. You may pass an absolute URL, but it must share that origin — the CLI refuses to attach your bearer token to a foreign host rather than leaking the credential:

nexspace update

Update a standalone (Homebrew/curl) install to the latest release. npm installs update with npm i -g @nexspace/cli; Homebrew with brew upgrade nexspace.