secrets
ak secrets set
Store a secret value
Use ak secrets set for the operation described below. The command help records its arguments, effects, and options.
Command contract
Store a secret value
Synopsis
Store a value under <ref> in the active secrets backend. The value is read from --value=- (stdin), --value-file=<path>, or an interactive, non-echoing prompt — never from --value=<literal> on the command line, which would leak the value into shell history and process listings (ps, /proc). The active backend sets no size limit per value. Use it before the first run that needs ${REF}, or with --force to overwrite an existing value. A new ref may not contain "/", a NUL byte, or a control, bidi, zero-width or line-separator character, since it would otherwise print as different text in ak secrets list and approval prompts.
Effects: Writes the value to the active backend and creates or updates the ref's metadata (never a value) in ~/.agentkit/secrets/index.json. --rotate-ttl records this ref's rotation window there; omitting it leaves a window already stored unchanged, so an ordinary rotation never resets one an operator shortened. The profile flags (--description, --project, --environment, --provider, --account, --tag) record searchable metadata in the same index; one left out keeps what is stored. Metadata text that contains the value is refused. The index also records a value hint (a recognised public prefix and the last 4 characters, for a value of 16 characters or more) that list, get and search show; --no-hint records none for this ref.
Exit status: 0 success 2 invalid flags or arguments, or profile text that would hold the value 4 ref already exists and --force was not passed 5 backend or index failure, or the release manifests could not be read for the profile check
ak secrets set <ref> [flags]Examples
ak secrets set ${REF} # interactive, non-echoing prompt
echo -n "${VALUE}" | ak secrets set ${REF} --value=- # pipe from stdin
ak secrets set ${REF} --value-file ${PATH} # read from a file
ak secrets set ${REF} --force --rotate-ttl 30d --provider stripe # overwrite, describe, remind to rotate every 30 daysOptions
--account string Account or workspace at the provider (empty clears it)
--alias strings Another name the secret is known by; repeat for several (search only; empty clears it)
--backend string Storage backend: keychain (default), file (age-encrypted vault), or memory (dev/test; values and its index are throwaway)
--description string What the secret is for (metadata, never a value; empty clears it)
--environment string Environment, e.g. production or staging (empty clears it)
--expires-at string When the provider-side credential expires: RFC 3339 time or YYYY-MM-DD (empty clears it)
--force Overwrite an existing value instead of failing
-h, --help help for set
--json Emit machine-readable JSON (implies --no-interactive)
--kind string Credential kind: api_key, token, password, private_key, certificate, connection_string, webhook_secret, client_secret, other (empty clears it)
--no-hint Record no value hint for this secret; it stays off across rotations until --no-hint=false
--no-interactive Disable interactive prompts (CI-safe)
--owner string Person or team responsible for the credential (empty clears it)
--permission strings What the credential can do at its provider, e.g. read:orders; repeat for several (not enforced; empty clears it)
--project strings Project the secret belongs to; repeat or comma-separate for several (replaces the list; empty clears it)
--provider string Service the secret is for, e.g. stripe or openai (empty clears it)
-q, --quiet Suppress non-error output on stderr
--rotate-ttl string How long this secret may go between rotations, in whole days, e.g. 30d, 2w, or 45 (default 90d)
--rotate-url string https page where the credential is rotated; never opened by ak (empty clears it)
--sensitivity string Sensitivity: normal, high (empty clears it)
--tag strings Tag; repeat or comma-separate for several (replaces the tags; empty clears them)
--unlock-with-recovery Open the file backend's vault with a recovery private key and set a new passphrase
--usage-host strings Host the credential is meant for; repeat for several. Routing guidance only, never enforced (empty clears it)
--value string Secret value source: '-' reads from stdin. A literal value is rejected — use --value=- or --value-file
--value-file string Path to a file containing the secret value
-V, --verbose Extra diagnostic output on stderr (loses to --quiet)
--when-not-to-use string When an agent must not pick this credential (empty clears it)
--when-to-use string When an agent should pick this credential (guidance, never an instruction; empty clears it)
-y, --yes Assume yes for all promptsSEE ALSO
- ak secrets - Manage named secret values (API keys, tokens)