Authentication
NexSpace supports three authentication methods. Choose based on your use case.API Keys
API keys are the simplest way to authenticate. Each key has scopes that control what it can access.Key Prefixes
Sandbox keys share the production database but only see
is_sandbox rows, skip real notifications and outbound platform webhooks, and are omitted from usage analytics totals. See Sandbox (test API keys) for isolation rules, TTL, and scope limits.
Scopes
Scopes follow the patternresource:action. Wildcard resource:* grants all
actions on a resource.
Key Rotation
Rotate keys with zero downtime — the old key remains valid for 24 hours:OAuth 2.1 + PKCE
For apps where users grant access through a browser flow.Discovery
Dynamic Client Registration (RFC 7591)
Clients can self-register without operator intervention:Authorization Flow
- Redirect user to
/oauth/authorizewith PKCEcode_challenge(S256) - User logs in and grants scopes
- Exchange
code+code_verifierat/oauth/token - Receive
access_token+refresh_token
Device Code Flow (RFC 8628)
For CLI tools and environments without a browser.nexspace login runs the
device-code flow by default (opening your browser); pass --token nex_pat_… to
store a personal access token instead:
~/.nexspace/config.json (mode 0600). The CLI refreshes the OAuth access
token automatically as it nears expiry, rotating the stored refresh token.
Verify identity
GET /api/auth/me returns the identity a credential authenticates as. It
accepts any supported credential — API key (nex_live_/nex_test_),
personal access token (nex_pat_), OAuth 2.1 access token, or first-party
session — so it’s the canonical “who am I” probe for SDKs, MCP clients, and the
CLI (nexspace whoami).
401.
Token Introspection (RFC 7662)
Resource servers can check whether a token is active and inspect its metadata. The caller authenticates as the client that owns the token — public clients (PKCE: CLIs, SPAs) presentclient_id alone; confidential clients also present
client_secret. Works for both access tokens (JWT) and refresh tokens.
{ "active": false } (never an error):
Token Revocation (RFC 7009)
Revoke a token when a session ends or a credential is compromised. Revoking a refresh token invalidates it and its entire rotation chain; revoking an access token invalidates the associated refresh chain so it can’t be renewed (the stateless access JWT itself remains valid until its short 1-hourexp).
Per RFC 7009 the response is always 200 with an empty body.
nexspace logout clears stored credentials locally (keychain + config file).
Rate Limits
Every API response includes rate-limit headers:
Default: 60 requests/minute per API key. Configurable per key up to 6,000/min.

