Skip to main content
Use 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.
Verify the active key and organization at any time:

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:
Never pass an API key as a literal command-line argument in shared shells, scripts committed to source control, or CI logs — it can leak into shell history and process listings. Prefer STAPLEHIRE_KEY from a secret store. staplehire login keeps your .env out of git automatically.

Use an API key for agents and CI

Browser login is for humans. Agents, scripts, and CI should set STAPLEHIRE_KEY directly. Create a key in Settings → Developers.
For a single command without exporting, use --api-key:
See Use in CI for a GitHub Actions example.

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

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.
Yes. Put --api-key sh_live_xxx before the subcommand. It overrides any env var or .env for that invocation only.
Yes — init is a deprecated alias for login. Both work; prefer login.
It is reserved for multi-profile authentication and is not active yet. Use --api-key or STAPLEHIRE_KEY to switch organizations today.
Related: Installation · Use in CI · CLI errors