Skip to main content
Save an API key to the config file. The key is required for all authenticated commands. Use --stdin when an agent provides the key or when you want to pipe it yourself; otherwise the command prompts for the key on a TTY.
clay login [--stdin]
The key is validated against Clay before it is persisted — if validation fails, the config file is not written. The key is stored under the default profile; any other profiles already present in the file are preserved.

Flags

FlagDescription
--stdinRead the API key from standard input as a single line. Useful for agents and for keeping the key out of shell history.

Output

{
  "ok": true,
  "configPath": "/Users/you/.config/clay/config.json"
}
FieldTypeDescription
oktrueAlways true on success.
configPathstringAbsolute path to the config file that was written (0600).

Errors

CodeExitNotes
tty_required2Ran without --stdin in a non-interactive environment. Pipe the key on stdin instead.
validation_error2Input was empty after trimming.
auth_invalid3Clay rejected the key during the pre-write probe. Nothing was written.
aborted1Interactive prompt was cancelled (Ctrl-C, Esc).

Examples

Non-interactive, preferred for agents:
echo "$CLAY_API_KEY" | clay login --stdin
Interactive, masked TTY prompt:
clay login