When to use
- First-time environment setup
- When deploy or project commands fail with “API key is required”
- To check current identity or switch between organizations
- When the user needs to authenticate with a different org
Prerequisites
- Node.js 22+ installed
- npm available
Install the CLI
login
Save an API key and create a named profile. Alias forconfig set.
Options
| Option | Description |
|---|---|
--api-key <key> | API key (skips interactive prompt) |
--base-url <url> | Base URL override (defaults to production) |
--name <name> | Custom profile name (auto-derived from org name if omitted) |
--skip-verify | Save without verifying the key against the API |
Behavior
- Prompts for API key (masked input) unless
--api-keyis provided - Validates the key against the Codika platform API (unless
--skip-verify) - Stores profile metadata: org ID, org name, key name, scopes, creation date, expiry date
- Sets the new profile as active
Examples
whoami
Show the current authenticated identity.Options
| Option | Description |
|---|---|
--json | Output as JSON |
Behavior
Validates against the platform API for fresh data. Falls back to cached profile data if the network call fails.Output
use
Switch the active profile or list all profiles.Arguments
| Argument | Description |
|---|---|
[name] | Profile name to switch to (optional — lists profiles if omitted) |
Options
| Option | Description |
|---|---|
--json | Output machine-readable JSON with profile details |
Behavior
- No argument: Lists all profiles with an active marker (bullet)
- With argument: Switches the active profile
Output (list mode)
JSON output
When called with--json, outputs an array of profile objects — useful for agents to match project.json organizationId to the correct profile:
Examples
logout
Remove a profile.Arguments
| Argument | Description |
|---|---|
[name] | Profile name to remove (defaults to active profile) |
Behavior
Removes the specified profile. If it was the active profile, switches to the next available profile.config set
Save API key and base URL. Same aslogin.
login.
config show
Display all stored profiles.Output
config clear
Remove configuration.Options
| Option | Description |
|---|---|
--profile <name> | Remove only this profile (clears all if omitted) |
Examples
Configuration storage
| Item | Location |
|---|---|
| Config file | ~/.config/codika/config.json |
| Permissions | 0o600 (owner read/write only) |
| Format | Multi-profile JSON with active profile pointer |
API key resolution priority
--api-key/--api-urlflag on any commandCODIKA_API_KEY/CODIKA_BASE_URLenvironment variable- Active profile in config file
- Production default (base URL only)
Organization-aware profile selection
Whenproject.json in a use case folder contains an organizationId, the CLI automatically selects the matching profile for deployment commands — even if a different profile is currently active.
Error reference
| Error | Cause | Fix |
|---|---|---|
| ”API key is required” | No key provided or found | Run codika login |
| ”Invalid API key” | Key is wrong or expired | Check with codika whoami, re-login |
| ”EACCES” on npm install | Permission denied | Use sudo npm install -g or fix npm permissions |
| Wrong org on deploy | Active profile doesn’t match project | Use codika use <correct-profile> |