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
| Argument | Required | Description |
|---|---|---|
[pairs...] | Optional | One or more secret assignments formatted as KEY=VALUE pairs (e.g. API_KEY=secret_val). |
Flags & Options
| Flag / Option | Type | Description |
|---|---|---|
-p, --project <id_or_name> | string | Target project ID or slug to link or query, bypassing interactive selection |
-e, --env <name>(--environment <name>) | string | Target environment name (e.g. development, staging, production) to read or modify |
-s, --scope <path> | string | Subdirectory path or workspace scope to target instead of auto-detecting from the working directory (e.g. apps/web or packages/backend) |
-f, --file <path> | string | Path to the source or destination .env file (defaults to .env in current directory) |
--overwrite | boolean | Force overwrite of existing secrets or local files without interactive confirmation prompts |
-o, --override | boolean | Save or update secrets as personal developer overrides without modifying shared team values |
--sync-local | boolean | Synchronize the updated secret value into the corresponding local .env file on disk |
--dry-run | boolean | Simulate command execution and preview changes without modifying remote vault or local filesystem |
-q, --quiet | boolean | Silence banners, progress spinners, and status output; only print process output and critical errors |
--ci | boolean | Optimize execution for headless CI/CD runners (disables spinners, prompts, colors, and update checks) |
--reveal | boolean | Display plaintext secret values in the terminal table instead of masking characters |
--json | boolean | Format 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_1232. 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 staging3. Save secret as personal developer override
Creates a developer override visible only to your authenticated identity, leaving team values untouched.
ray set DEBUG=true --override4. 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-local5. Preview modifications without writing to vault
Simulates setting secrets without modifying remote storage or local disk files.
ray set FEATURE_FLAGS=all --dry-runExit Codes
| Code | Meaning | Recommended Action |
|---|---|---|
| 0 | Success. The command completed with no errors. | None required. |
| 1 | Runtime or execution failure. A child process returned non-zero status or a general error occurred. | Inspect process output or run with --verbose. |
| 2 | Authentication failed. Token is missing, expired, or invalid. | Run `ray login` or update `RAY_TOKEN`. |
| 3 | Configuration or binding error. Project or environment context was not found. | Run `ray init` or specify `--project` and `--env`. |
| 4 | Network 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.