Skip to main content

CLI Authentication

The CLI authenticates with either a browser OAuth session (device-code flow) or a stored API key / PAT. Either way, nexspace login saves the credential to your OS keychain when available (macOS Keychain, Linux Secret Service, Windows Credential Manager), falling back to ~/.nexspace/config.json (mode 0600).

Device Code Login (Interactive)

Best for personal use on your workstation:
This opens a browser where you log in and approve the CLI. The CLI refreshes the OAuth access token automatically as it nears expiry.

Scopes

The CLI never holds an unscoped credential. An OAuth login gets exactly the scopes you ask for with --scope (space-separated); without --scope it gets the read-only default bundle: every *:read scope and no write scope (no agents:*). A read scope never covers a request that changes data (see below). Ask for what the commands you run need:
An API key carries the scopes it was created with (in the dashboard), so the same table applies to nexspace login --token. A scope never gives you more than your account’s role allows (scope and role). Some surfaces are human-only whatever the scope and refuse every API key and OAuth token with 403 (DELEGATED_CREDENTIAL_NOT_ALLOWED on most of them): API-key management, sandbox reset, impersonation, platform admin, your own profile, password, devices and notification preferences, linking or unlinking connected accounts, the in-app AI assistants (including Studio app runs), uploading your own credential documents, accepting terms or giving SMS / voice consent, and creating, changing or removing facility logins (including sending invitations). Use the dashboard for those. A read scope never writes. A request that can change data (POST, PUT, PATCH, DELETE) needs a write-class scope for each permission the route checks, even where that permission is a read one: many write routes are guarded by staff.view or shifts.view, and there staff:read / shifts:read answer 403 INSUFFICIENT_SCOPE (the suggestion names the scope to add, e.g. staff:write). A read permission is covered on a write by <resource>:write, <resource>:* or *; on a GET it still needs <resource>:read (or a wildcard). This applies to routes that check a permission; a few self-service routes check only that you are signed in (marking your own notifications read, for example), so the default bundle is not a guarantee that nothing can change. These answer 403 DELEGATED_CREDENTIAL_NOT_ALLOWED to every API key and OAuth token, whatever its scopes or role:
  • connected accounts: GET /api/integrations/hub/connect/:provider, POST /api/integrations/hub/disconnect/:provider, POST /api/integrations/composio/connect/:toolkit, DELETE /api/integrations/composio/connections/:id (and, as before, POST /api/calendar-sync/ical/enable, GET /api/calendar-sync/google/auth);
  • AI: POST /api/studio/run/:id/actions/:actionId/execute, POST /api/studio/run/:id/ai, POST /api/agent/chat, POST /api/agent/proposals/:id/approve (and the /api/ai/... assistant routes);
  • your account: POST /api/user/credentials/upload, PUT /api/notifications/preferences (and your profile, password and devices);
  • terms and consent: POST /api/legal/accept (Terms, BAA, DPA, SMS terms and the SMS / voice consents sent with them), and POST /api/voice/elevenlabs/prod/call when the body attests call-recording consent (customerAttestedSeparateConsent or customerAttestationId);
  • facility logins, which only a signed-in person manages: creating one (POST /api/facility-users), changing it (PATCH /api/facility-users/:id: password, email, names, role, permissions, deactivating or reactivating), removing it (DELETE /api/facility-users/:id), worker mode (PATCH /api/facility-users/:id/worker-settings, POST /api/facility-users/:id/enable-worker, DELETE /api/facility-users/:id/disable-worker), and sending an invitation, whose acceptance creates one (POST /api/invitations, POST /api/invitations/:id/resend). Reading them (GET /api/facility-users, GET /api/facility-users/:id, GET /api/facility-users/:id/worker-status) is unchanged: an API key with users:read and the role (no OAuth scope covers it).
A credential never carries platform-wide (all-facilities) authority, even when its account is a super admin and it holds the route’s scope. These answer 403 DELEGATED_CREDENTIAL_NOT_ALLOWED to any API key or OAuth token of a platform operator (anyone else gets the same 403 as before):
  • facility lifecycle: DELETE /api/facilities/:id, POST /api/facilities/:id/status, GET /api/facilities/:id/lifecycle-preflight (and POST /api/facilities);
  • platform system settings: GET / PATCH /api/system-settings;
  • placements: GET /api/placements/unplaced-applicants, GET /api/placements/facilities-for-matching, GET /api/placements/job-postings/:facilityId, POST /api/placements/propose, GET /api/placements/proposals, GET /api/placements/stats;
  • platform billing, Stripe admin and token pricing: the /api/billing/..., /api/admin/billing/..., /api/stripe/sync-plans, /api/stripe/credits/grant, /api/token-actions, /api/plans/:planId/token-limits, /api/admin/token-usage/overview and /api/org/:orgId/{action-pricing,enforcement} routes that need a platform operator;
  • payroll administration (/api/payroll/company/..., /api/payroll/employee/..., /api/payroll/runs...), integration configs (/api/integrations/{configs,config/:id,export/:providerId,sync-logs,health}), scheduled tasks (/api/scheduled-tasks...) and agreements (POST /api/agreements, PATCH /api/agreements/:id, POST /api/agreements/:id/send).
approvals approve / reject (POST /api/ai/admin/approvals/:id/approve|reject, POST /api/ai/actions/:id/approve|reject) resolve only an approval one of your own agent runs raised, the same rule as agents approvals; anything else answers 403 DELEGATED_CREDENTIAL_NOT_ALLOWED, whatever your role. A command whose scope is missing exits 2 with SCOPE_DENIED; its next hint names the scope to add when the server reported one.

API Key / PAT (Headless)

Best for CI/CD, scripts, and automation. Create the key in the dashboard (Settings → API keys) with the scopes from the table above; keys cannot be created or managed from the CLI. Store the key once with nexspace login --token — it also reads the NEXSPACE_API_KEY environment variable as a fallback for the token value:
Once stored, every command reuses the credential automatically:

Verify Authentication

Prints the identity the stored credential authenticates as, backed by GET /api/auth/me.

Logout

Removes stored credentials from the keychain and ~/.nexspace/config.json.