Skip to main content
The CLI is designed for a variety of secret management applications ranging from local development to CI/CD and production scenarios.
The steps below authenticate the CLI with your own account, link a codebase to an Infisical project, and inject the secrets you have access to into your local development process as environment variables.
If you prefer to learn by watching, follow along with our step-by-step video tutorial.

Step 1: Log in to Infisical

Authenticate the CLI with your Infisical account.
The prompt asks which instance you want to use. Select Infisical Cloud (US), Infisical Cloud (EU), or Self-hosted, then finish signing in through your browser.
On a machine with no browser, such as a remote SSH session, WSL 2, or Codespaces, run infisical login -i to log in from the terminal instead.
Go to the directory of the codebase you’re working on and link it to your Infisical project.
Select your organization and project when prompted. This creates an .infisical.json file with your local project settings, so the commands you run next don’t need a project ID.
.infisical.json holds no secret values, so you can safely commit it to version control. Everyone who clones the repository is then pointed at the same project.

Step 3: Start your application with secrets injected

Run your usual start command through infisical run, placing it after the -- separator.
The CLI fetches the secrets you have access to and passes them to your application as environment variables. Your application reads them the same way it always has, through process.env in Node.js or os.environ in Python, so you don’t need to change any application code.
By default, infisical run only injects the secrets sitting at the root of the environment, so anything inside a folder is skipped. If your secrets live in folders, you can specify a folder to include using --path:
If you also need the secrets in that folder’s subfolders, add --recursive:
Add --watch while you work to restart your application automatically whenever one of its secrets changes in Infisical.
A start command that is a shell function or an alias can’t be called directly after --, because it only exists inside your shell. Use the --command flag to run it in a shell instead.For example, if custom.sh defines a yd function that runs yarn dev:
Source the file and call the function in a single command:
The --command flag is also how you chain commands together, as in --command="npm run migrate && npm run dev".
For every available option, see the infisical run reference.For installation instructions, troubleshooting, and related local workflows such as personal overrides and secret scanning, see the local development guide.
Starting with CLI version v0.4.0, you can now choose to log in via Infisical Cloud (US/EU) or your own self-hosted instance by simply running infisical login and following the on-screen instructions — no need to manually set the INFISICAL_API_URL environment variable.For versions prior to v0.4.0, the CLI defaults to US Cloud. To connect to EU Cloud or a self-hosted instance, set the INFISICAL_API_URL environment variable to https://eu.infisical.com or your custom URL.

Domain configuration

Important: If you’re not using interactive login, you must configure the domain for all CLI commands.The CLI defaults to US Cloud (https://app.infisical.com). To connect to EU Cloud (https://eu.infisical.com) or a self-hosted instance, you must configure the domain in one of the following ways:
  • Use the INFISICAL_DOMAIN environment variable
  • Use the --domain flag on every command
  • Set the domain field in your project’s .infisical.json
When more than one is set, the CLI uses this order of precedence: --domain flag, then INFISICAL_DOMAIN, then the domain field in .infisical.json, then the default. The legacy INFISICAL_API_URL environment variable is still honored, but INFISICAL_DOMAIN takes precedence when both are set.

Custom request headers

The Infisical CLI supports custom HTTP headers for requests to servers protected by authentication services such as Cloudflare Access. Configure these headers using the INFISICAL_CUSTOM_HEADERS environment variable:
This functionality enables secure interaction with Infisical instances that require specific authentication headers.

History

Your terminal keeps a history with the commands you run. When you create Infisical secrets directly from your terminal, they’ll stay there for a while. For security and privacy concerns, we recommend you to configure your terminal to ignore those specific Infisical commands.
$HOME/.profile is pretty common but, you could place it under $HOME/.profile.d/infisical.sh or any profile file run at login

FAQ

Yes. The CLI is set to connect to Infisical US Cloud by default, but if you’re using EU Cloud or a self-hosted instance you can configure the domain for all CLI commands.

Method 1: Use the updated CLI (v0.4.0+)

Beginning with CLI version V0.4.0, you can choose between logging in through Infisical US Cloud, EU Cloud, or your own self-hosted instance. Simply execute the infisical login command and follow the on-screen instructions.

Method 2: Export environment variable

You can point the CLI to the self-hosted Infisical instance by exporting the environment variable INFISICAL_DOMAIN in your terminal. (The legacy INFISICAL_API_URL variable still works.)

Method 3: Set manually on every command

If you prefer not to use an environment variable, you must include the --domain flag on every CLI command you run:
Best Practice: Use INFISICAL_DOMAIN environment variable (Method 2) to avoid having to remember the --domain flag on every command. This is especially important in CI/CD pipelines and automation scripts.
To use Infisical for non local development scenarios, please create a service token. The service token will allow you to authenticate and interact with Infisical. Once you have created a service token with the required permissions, you’ll need to feed the token to the CLI.

Pass via shell environment variable

The CLI is configured to look for an environment variable named INFISICAL_TOKEN. If set, it’ll attempt to use it for authentication.