staplehire login for local development, or set STAPLEHIRE_KEY for agents, scripts, and CI. Every command authenticates the same way: by resolving an API key.
Log in with your browser
staplehire login runs a secure PKCE OAuth flow:
1
A local callback server starts
The CLI opens a loopback server on
127.0.0.1 and your default browser to app.staplehire.com. Log in or create an account if needed.2
You authorize CLI access
Approve the
hire:write scope for “Staplehire CLI”. The browser redirects back to the local callback with an authorization code.3
The key is exchanged and saved
The CLI exchanges the code (plus the PKCE verifier) with the API gateway, then writes
STAPLEHIRE_KEY to a .env file in your current directory and adds .env to .gitignore if one exists.staplehire login always authenticates against the production gateway and dashboard. Override with --app-url / --api-url (or STAPLEHIRE_APP_URL / STAPLEHIRE_API_URL) only when testing against a non-production environment.How the API key is resolved
The CLI looks for an API key in this order and uses the first one it finds:
Keys are prefixed
sh_live_… (production) or sh_test_… (test). staplehire doctor shows which source the active key came from:
Use an API key for agents and CI
Browser login is for humans. Agents, scripts, and CI should setSTAPLEHIRE_KEY directly. Create a key in Settings → Developers.
--api-key:
Log out
logout removes STAPLEHIRE_KEY from the .env in your current directory and clears it from the current process environment.
Common errors
See CLI errors for the full exit-code contract.
FAQ
Where does `staplehire login` store credentials?
Where does `staplehire login` store credentials?
It writes
STAPLEHIRE_KEY to a .env file in the directory you ran it from, and ensures .env is in .gitignore when a .gitignore exists.Can I authenticate just one command?
Can I authenticate just one command?
Yes. Put
--api-key sh_live_xxx before the subcommand. It overrides any env var or .env for that invocation only.Is `staplehire init` still supported?
Is `staplehire init` still supported?
Yes —
init is a deprecated alias for login. Both work; prefer login.What does the `--profile` flag do?
What does the `--profile` flag do?
It is reserved for multi-profile authentication and is not active yet. Use
--api-key or STAPLEHIRE_KEY to switch organizations today.