Skip to Content
RcmadeDocs
Ray SecretsReferenceCLI ReferenceSecrets

ray set

Set or update secret key-value pairs in an environment

Set or update secret key-value pairs in an environment

Synopsis

ray set [options] [pairs...]

Positional Arguments

ArgumentRequiredDescription
[pairs...]OptionalOne or more secret assignments formatted as KEY=VALUE pairs (e.g. API_KEY=secret_val).

Flags & Options

Flag / OptionTypeDescription
-p, --project <id_or_name>stringTarget project ID or slug to link or query, bypassing interactive selection
-e, --env <name>(--environment <name>)stringTarget environment name (e.g. development, staging, production) to read or modify
-s, --scope <path>stringSubdirectory path or workspace scope to target instead of auto-detecting from the working directory (e.g. apps/web or packages/backend)
-f, --file <path>stringPath to the source or destination .env file (defaults to .env in current directory)
--overwritebooleanForce overwrite of existing secrets or local files without interactive confirmation prompts
-o, --overridebooleanSave or update secrets as personal developer overrides without modifying shared team values
--sync-localbooleanSynchronize the updated secret value into the corresponding local .env file on disk
--dry-runbooleanSimulate command execution and preview changes without modifying remote vault or local filesystem
-q, --quietbooleanSilence banners, progress spinners, and status output; only print process output and critical errors
--cibooleanOptimize execution for headless CI/CD runners (disables spinners, prompts, colors, and update checks)
--revealbooleanDisplay plaintext secret values in the terminal table instead of masking characters
--jsonbooleanFormat command output as structured JSON for scripting, automation, and piping

Common Examples

1. Set a single secret in the default environment

Encrypts and stores a new key-value secret in the currently linked environment vault.

ray set API_KEY=secret_val_123

2. Set multiple secrets in a target environment

Sets several key-value pairs at once in the specified remote environment.

ray set DATABASE_URL="postgresql://user:pass@localhost:5432/db" PORT=3000 --env staging

3. Save secret as personal developer override

Creates a developer override visible only to your authenticated identity, leaving team values untouched.

ray set DEBUG=true --override

4. Synchronize updated value into local .env file simultaneously

Updates the remote vault and writes the change to the corresponding local .env file on disk.

ray set STRIPE_SECRET=sk_test_123 --sync-local

5. Preview modifications without writing to vault

Simulates setting secrets without modifying remote storage or local disk files.

ray set FEATURE_FLAGS=all --dry-run

Exit Codes

CodeMeaningRecommended Action
0Success. The command completed with no errors.None required.
1Runtime or execution failure. A child process returned non-zero status or a general error occurred.Inspect process output or run with --verbose.
2Authentication failed. Token is missing, expired, or invalid.Run `ray login` or update `RAY_TOKEN`.
3Configuration or binding error. Project or environment context was not found.Run `ray init` or specify `--project` and `--env`.
4Network or API failure. Failed to reach the Ray Secrets vault.Check internet connection or run `ray doctor`.

Ready to eliminate plaintext secrets?

Create a workspace to organize environments, invite your team, and generate scoped Service Tokens for CI/CD.