env Commands

Commands to manage your environments, such as orgs.

env compute collaborator add

Add a Heroku user as a collaborator on this Functions account, allowing them to attach Heroku add-ons to compute environments.

Examples for env compute collaborator add

Add a Heroku user as a collaborator on this Functions account.

1sf env compute collaborator add --heroku-user example@heroku.com

Usage

sf env compute collaborator add
-h HEROKU-USER

Flags

-h | --heroku-user HEROKU-USER
Required

Email address of the Heroku user you're adding as a collaborator.

Type: option

env create compute

Create a compute environment for use with Salesforce Functions.

Description for env create compute

Compute environments must be connected to a Salesforce org. By default the command uses your local environment's connected org. Use the '--connected-org' flag to specify a specific org. Run 'sf env list' to see a list of environments.

Examples for env create compute

Create a compute environment to run Salesforce Functions:

1sf env create compute

Connect the environment to a specific org:

1sf env create compute --connected-org=org-alias

Create an alias for the compute environment:

1sf env create compute --alias environment-alias

Usage

sf env create compute
[-o CONNECTED-ORG]
[-a ALIAS]

Flags

-o | --connected-org CONNECTED-ORG
Optional

Username or alias for the org that the compute environment should be connected to.

Type: option
-a | --alias ALIAS
Optional

Alias for the created environment.

Type: option

env delete

Delete an environment.

Description for env delete

You must include the name of the environment to delete using '--target-compute'. Run 'sf env list' to see a list of environments.

Running this command will prompt a confirmation. If you want to skip this confirmation, use the '--confirm' flag and the environment alias to skip confirmation.

Examples for env delete

Delete a compute environment:

1sf env delete --target-compute environment-alias

Delete without a confirmation step:

1sf env delete --target-compute environment-alias --confirm environment-alias

Usage

sf env delete
[-e TARGET-COMPUTE]
[--confirm CONFIRM]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Environment name.

Type: option
--confirm CONFIRM
Optional

Confirmation name.

Type: option

env display

Display details about an environment.

Description for env display

Specify an environment with either the username you used when you logged into the environment with "sf login", or the alias you gave the environment when you created it. Run "sf env list" to view all your environments and their aliases.

Output depends on the type of environment. For example, scratch org details include the access token, alias, username of the associated Dev Hub, the creation and expiration date, the generated scratch org username, and more. Compute environment details include the alias, connected orgs, creation date, project name, and more.

Examples for env display

Display details about a scratch org with alias my-scratch-org:

1sf env display --target-env=my-scratch-org

Specify a username instead of an alias:

1sf env display --target-env=test-123456-abcdefg@example.com

Specify JSON format and redirect output into a file:

1sf env display --target-env=my-scratch-org --json > tmp/MyOrdDesc.json

Usage

sf env display
[--json]
[-e TARGET-ENV]

Flags

--json
Optional

Format output as json.

Type: boolean
-e | --target-env TARGET-ENV
Optional

Environment alias or login user.

Type: option

env list

List the environments you’ve created or logged into.

Description for env list

By default, the command displays active environments. For orgs, active means unexpired scratch orgs and orgs you’re currently logged into.

Output is displayed in multiple tables, one for each environment type. For example, the Salesforce Orgs table lists the non-scratch orgs you’re logged into, such as sandboxes, Dev Hubs, production orgs, and so on. Scratch orgs and compute environments get their own tables.

The two org tables show similar information, such as aliases, information about the org, and how you authorized (logged into) it, such as with a web browser or JWT. The scratch org table also shows the expiration date. For non-scratch orgs, the Username column refers to the user you logged into the org with. For scratch orgs it refers to the username that was generated for you when you created the scratch org. Your default scratch org or Dev Hub org is indicated with the "target-org" or "target-dev-hub" configuration variable, respectively, in the Config column.

The compute environment table shows the alias, information about the connected orgs, the project name, and more.

Use the table manipulation flags, such as --filter and --sort, to change how the data is displayed.

Run "sf env display" to view details about a specific environment.

Examples for env list

List all active environments:

1sf env list

List both active and inactive environments:

1sf env list --all

Filter the output to list only orgs you authorized using a web browser; "Auth Method" is the name of a column:

1sf env list --filter "Auth Method=web"

Display only the Aliases column and sort the aliases in descending order:

1sf env list --sort "-Aliases" --columns "Aliases"

Don't truncate the displayed output and instead wrap text that's wider than your terminal:

1sf env list --no-truncate

Display only the table data, not the headers, in comma-separated value (csv) format:

1sf env list --csv --no-header

Usage

sf env list
[--json]
[-a]
[--columns COLUMNS]
[--csv]
[--filter FILTER]
[--no-header]
[--no-truncate]
[--output OUTPUT]
[--sort SORT]

Flags

--json
Optional

Format output as json.

Type: boolean
-a | --all
Optional

Show all environments, even inactive ones.

Type: boolean
--columns COLUMNS
Optional

List of columns to display.

Type: option
--csv
Optional

Output in csv format [alias: --output=csv]

Type: boolean
--filter FILTER
Optional

Filter property by partial string matching.

Type: option
--no-header
Optional

Hide table header from output.

Type: boolean
--no-truncate
Optional

Don't truncate output to fit screen.

Type: boolean
--output OUTPUT
Optional

Format in which to display the output.

Type: option
Permissible values are: csv, json, yaml
--sort SORT
Optional

Column to sort by (prepend '-' for descending).

Type: option

env log tail

Stream log output for an environment.

Examples for env log tail

Stream log output:

1sf env log tail --target-compute environment-alias

Usage

sf env log tail
[-e TARGET-COMPUTE]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Compute environment name to retrieve logs.

Type: option

env logdrain add

Add log drain to a specified environment.

Description for env logdrain add

Both '--target-compute' and '--url' are required flags. '--url' should be a HTTP or HTTPS URL that can receive the log drain messages.

Examples for env logdrain add

Add a log drain:

1sf env logdrain add --target-compute environment-name --url https://path/to/logdrain

Usage

sf env logdrain add
[-e TARGET-COMPUTE]
[-l DRAIN-URL]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Environment name.

Type: option
-l | --drain-url DRAIN-URL
Optional

Endpoint that will receive sent logs.

Type: option

env logdrain list

List log drains connected to a specified environment.

Examples for env logdrain list

List log drains:

1sf env logdrain list --target-compute environment-alias

List log drains as json:

1sf env logdrain list --target-compute environment-alias --json

Usage

sf env logdrain list
[-e TARGET-COMPUTE]
[-j]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Environment name.

Type: option
-j | --json
Optional

Output list in JSON format.

Type: boolean

env logdrain remove

Remove log drain from a specified environment.

Description for env logdrain remove

Both '--target-compute' and '--drain-url' are required flags.

Examples for env logdrain remove

Remove a logdrain:

1sf env logdrain remove --target-compute environment-alias --url https://path/to/logdrain

Usage

sf env logdrain remove
[-e TARGET-COMPUTE]
[-l DRAIN-URL]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Environment name.

Type: option
-l | --drain-url DRAIN-URL
Optional

Log drain url to remove.

Type: option

env open

Open an environment in a web browser.

Description for env open

You can open the following types of environments in a web browser: scratch orgs, sandboxes, Dev Hubs, and production orgs. Run "sf env list" to view your environments and their aliases and login usernames.

Each of your environments is associated with an instance URL, such as https://login.salesforce.com. To open a specific web page, specify the portion of the URL after "<URL>/" with the --path flag, such as /apex/YourPage to open a Visualforce page.

Examples for env open

Open the Visualforce page /apex/StartHere in a scratch org with alias test-org:

1sf env open --target-env test-org --path /apex/StartHere

View the URL but don't launch it in a browser:

1sf env open --target-env test-org --path /apex/StartHere --url-only

Open the environment in the Google Chrome browser:

1sf env open --target-env test-org --path /apex/StartHere --browser chrome

Usage

sf env open
[--json]
[-p PATH]
[-r]
[-e TARGET-ENV]
[--browser BROWSER]

Flags

--json
Optional

Format output as json.

Type: boolean
-p | --path PATH
Optional

Path to append to the end of the login URL.

Type: option
-r | --url-only
Optional

Display the URL, but don’t launch it in a browser.

Type: boolean
-e | --target-env TARGET-ENV
Optional

Login user or alias of the environment to open.

Specify the login user or alias that’s associated with the environment. For scratch orgs, the login user is generated by the command that created the scratch org. You can also set an alias for the scratch org when you create it.

For Dev Hubs, sandboxes, and production orgs, specify the alias you set when you logged into the org with "sf login".

Type: option
--browser BROWSER
Optional

Browser in which to open the environment.

You can specify that the environment open in one of the following browsers: Firefox, Safari, Google Chrome, or Windows Edge. If you don’t specify --browser, the environment opens in your default browser. The exact names of the browser applications differ depending on the operating system you're on; check your documentation for details.

Type: option

env var get

Display a single config variable for an environment.

Description for env var get

You must provide the '--target-compute' flag and the key to retrieve.

Examples for env var get

Get a config variable:

1sf env var get [KEY] --target-compute environment-alias

Usage

sf env var get
[-e TARGET-COMPUTE]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Environment name.

Type: option

env var list

List your environment's config vars in a table.

Description for env var list

Use the '--json' flag to return config vars in JSON format.

Examples for env var list

List config vars:

1sf env var list --target-compute environment-alias

List in JSON format:

1sf env var list --target-compute environment-alias --json

Usage

sf env var list
[-e TARGET-COMPUTE]
[-j]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Environment name.

Type: option
-j | --json
Optional

Output list in JSON format.

Type: boolean

env var set

Set a single config value for an environment.

Examples for env var set

Set a config value:

1sf env var set [KEY]=[VALUE] --target-compute environment-alias

Usage

sf env var set
[-e TARGET-COMPUTE]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Environment name.

Type: option

env var unset

Unset a single config value for an environment.

Description for env var unset

Run 'sf env var list' to see a list of config values that can be unset.

Examples for env var unset

Unset a value:

1sf env var unset --target-compute environment-alias

Usage

sf env var unset
[-e TARGET-COMPUTE]

Flags

-e | --target-compute TARGET-COMPUTE
Optional

Environment name.

Type: option