docs/cli/commands/secrets.mdx
infisical secrets
This command enables you to perform CRUD (create, read, update, delete) operations on secrets within your Infisical project. With it, you can view, create, update, and delete secrets in your environment.
$ infisical secrets
```bash
# Example
export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<identity-client-id> --client-secret=<identity-client-secret> --silent --plain) # --plain flag will output only the token, so it can be fed to an environment variable. --silent will disable any update messages.
```
<Info>
Alternatively, you may use service tokens.
```bash
# Example
export INFISICAL_TOKEN=<service-token>
```
</Info>
To use, simply export this variable in the terminal before running this command.
```bash
# Example
export INFISICAL_DISABLE_UPDATE_CHECK=true
```
Default value: `true`
```bash
# Example
infisical secrets --projectId=<project-id>
```
Default value: `dev`
```bash
# Example
infisical secrets --path="/" --env=dev
```
```bash
# Example
infisical secrets --plain --silent
```
```bash
# Example
infisical secrets --silent
```
Can be used inline to replace `INFISICAL_DISABLE_UPDATE_CHECK`
$ infisical secrets get <secret-name-a> <secret-name-b> ...
# Example
$ infisical secrets get DOMAIN
$ infisical secrets get DOMAIN PORT
Default value: `dev`
Default value: `false`
```bash
# Example
infisical secrets get FOO --plain
infisical secrets get FOO BAR --plain
# Fetch a single value and assign it to a variable
API_KEY=$(infisical secrets get FOO --plain --silent)
```
<Tip>
When running in CI/CD environments or in a script, set `INFISICAL_DISABLE_UPDATE_CHECK=true` or add the `--silent` flag. This will help hide any CLI info/debug output and only show the secret value.
</Tip>
```bash
# Example
infisical secrets get FOO --plain --silent
```
Can be used inline to replace `INFISICAL_DISABLE_UPDATE_CHECK`
Used to print the plain value of a single requested secret without any table style.
Default value: `false`
Example: `infisical secrets get DOMAIN --raw-value`
<Tip>
When running in CI/CD environments or in a script, set `INFISICAL_DISABLE_UPDATE_CHECK=true` or add the `--silent` flag. This will help hide any CLI info/debug output and only show the secret value.
</Tip>
$ infisical secrets set <key1=value1> <key2=value2> <key3=@/path/to/file>...
## Example
$ infisical secrets set STRIPE_API_KEY=sjdgwkeudyjwe DOMAIN=example.com HASH=jebhfbwe [email protected]
Example:
```bash
# Set a secret with the value loaded from a certificate file
$ secrets set CERTIFICATE=@/path/to/certificate.pem
# Set a secret with the literal value "@example.com"
$ secrets set email="\@example.com"
```
Default value: `dev`
```bash
# Example
infisical secrets set DOMAIN=example.com --path="common/backend"
```
```bash
# Example
infisical secrets set DOMAIN=example.com --type=personal
```
The file should contain secrets in the following formats:
- `key=value` for `.env` files
- `key: value` for YAML files
Comments can be written using `# comment` or `// comment`. Empty lines will be ignored during processing.
```bash
# Example
infisical secrets set --file="./.env"
```
$ infisical secrets delete <keyName1> <keyName2>...
## Example
$ infisical secrets delete STRIPE_API_KEY DOMAIN HASH
Default value: `dev`
```bash
# Example
infisical secrets delete <keyName1> <keyName2>... --path="/"
```
$ infisical secrets folders
Default value: `/`
</Accordion>
<Accordion title="--token">
Fetch folders using a [machine identity](/documentation/platform/identities/machine-identities) access token.
Default value: ``
</Accordion>
Default value: `/`
</Accordion>
<Accordion title="--name">
Name of the folder to be created in selected `--path`
Default value: ``
</Accordion>
Default value: `/`
</Accordion>
<Accordion title="--name">
Name of the folder to be deleted within selected `--path`
Default value: ``
</Accordion>
To place default values in your example .env file, you can simply include the syntax DEFAULT:<value> within your secret's comment in Infisical. This will result in the specified value being extracted and utilized as the default.
$ infisical secrets generate-example-env
## Example
$ infisical secrets generate-example-env > .example-env
Default value: `dev`