org Commands

Use the org commands to manage the orgs you use with Salesforce CLI. Create and delete scratch orgs, list your created and authorized orgs, and open orgs in your browser.

org:create

Creates a scratch org using values specified in a configuration file or key=value pairs that you specify on the command line. Values specified on the command line override values in the configuration file.

Command Syntax

sfdx force:org:create
[--json]
[--loglevel LOGLEVEL]
[-v TARGETDEVHUBUSERNAME]
[--apiversion APIVERSION]
[-f DEFINITIONFILE]
[-n]
[-c]
[-i CLIENTID]
[-s]
[-a SETALIAS]
[-w WAIT]
[-d DURATIONDAYS]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-f | --definitionfile DEFINITIONFILE
Optional

Path to a scratch org definition file. Either --definitionfile or a vararg value for edition (for example, edition=Developer) is required. Varargs override the values in the scratch org definition file.

Type: filepath
-n | --nonamespace
Optional

Creates the scratch org with no namespace. Useful when using a scratch org to test installations of packages with namespaces.

Type: boolean
-c | --noancestors
Optional

Do not include second-generation package ancestors in the scratch org.

Type: boolean
-i | --clientid CLIENTID
Optional

Connected app consumer key, as configured in your Dev Hub.

Type: string
-s | --setdefaultusername
Optional

Sets the created org as the default username.

Type: boolean
-a | --setalias SETALIAS
Optional

Sets an alias for for the created scratch org.

Type: string
-w | --wait WAIT
Optional

Sets the streaming client socket timeout, in minutes. If the streaming client socket has no contact from the server for a number of minutes, the client exits. Specify a longer wait time if timeouts occur frequently.

Type: minutes
Default value: 6
-d | --durationdays DURATIONDAYS
Optional

Sets the duration of the scratch org, in days. Valid values are from 1-30. The default is 7 days.

Type: number

Help for org:create

To set up a connected app for your new scratch org, specify the value that was returned when you created a connected app in your Dev Hub org as --clientid.

Examples:

1$ sfdx force:org:create -f config/enterprise-scratch-def.json -a TestOrg1
1$ sfdx force:org:create -a MyDevOrg -s -v me@myhub.org edition=Developer
1$ sfdx force:org:create -f config/enterprise-scratch-def.json -a OrgWithOverrides username=testuser1@mycompany.org

org:delete

Marks a scratch org for deletion.

Command Syntax

sfdx force:org:delete
[--json]
[--loglevel LOGLEVEL]
[-v TARGETDEVHUBUSERNAME]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
[-p]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-p | --noprompt
Optional

No prompt to confirm deletion.

Type: boolean

Help for org:delete

To mark the org for deletion without being prompted to confirm, specify --noprompt.

Examples:

1$ sfdx force:org:delete -u me@my.org
1$ sfdx force:org:delete -u MyOrgAlias -p

org:display

Gets the description for the current or target org.

Command Syntax

sfdx force:org:display
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
[--verbose]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
--verbose
Optional

Emit additional command output to stdout.

Type: boolean

Help for org:display

Output includes your access token, client ID, connected status, org ID, instance URL, username, and alias, if applicable.

Use --verbose to include the SFDX auth URL. Including --verbose displays the sfdxAuthUrl property only if you authenticated to the org using force:auth:web:login (not force:auth:jwt:grant).

Examples:

1$ sfdx force:org:display
1$ sfdx force:org:display -u me@my.org
1$ sfdx force:org:display -u TestOrg1 --json
1$ sfdx force:org:display -u TestOrg1 --json > tmp/MyOrgDesc.json

org:list

Lists all orgs that the Salesforce CLI has created or authenticated to.

Command Syntax

sfdx force:org:list
[--json]
[--loglevel LOGLEVEL]
[--verbose]
[--all]
[--clean]
[-p]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
--verbose
Optional

Lists more information about each org.

Type: boolean
--all
Optional

Lists all authenticated orgs, including expired, deleted, and unknown-status scratch orgs.

Type: boolean
--clean
Optional

Remove all local org authorizations for deleted or expired orgs.

Type: boolean
-p | --noprompt
Optional

Do not prompt for confirmation.

Type: boolean

Help for org:list

Examples:

1$ sfdx force:org:list
1$ sfdx force:org:list --verbose --json
1$ sfdx force:org:list --verbose --json > tmp/MyOrgList.json

org:open

Opens an org in your browser.

Command Syntax

sfdx force:org:open
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
[-p PATH]
[-r]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-p | --path PATH
Optional

Navigation URL path (not including domain).

Type: string
-r | --urlonly
Optional

Displays a navigation URL, but doesn’t launch your browser.

Type: boolean

Help for org:open

Opens your default scratch org, or another org that you specify.

To open a specific page, specify the portion of the URL after "yourInstance.salesforce.com/" as --path.

For example, specify "--path lightning" to open Lightning Experience, or specify "--path /apex/YourPage" to open a Visualforce page.

To generate a URL but not launch your browser, specify --urlonly.

Examples:

1$ sfdx force:org:open
1$ sfdx force:org:open -u me@my.org
1$ sfdx force:org:open -u MyTestOrg1
1$ sfdx force:org:open -r -p lightning

org:shape:create (Pilot)

Creates a snapshot of org edition, features, and licenses to use for scratch org creation, allowing your scratch org to look like another org for testing.

We provide the org:shape:create command to selected customers through an invitation-only pilot program that requires agreement to specific terms and conditions. Pilot programs are subject to change, and we can’t guarantee acceptance. The org:shape:create command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the org:shape:create command in the W19 Pilot: Org Shape for Scratch Orgs group in the Trailblazer Community.

Note

Command Syntax

sfdx force:org:shape:create
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string

Help for org:shape:create

Examples:

1$ sfdx force:org:shape:create -u me@my.org
1$ sfdx force:org:shape:create -u me@my.org --json --loglevel debug

org:shape:delete (Pilot)

Deletes all org shapes that you’ve created for an org using the Salesforce CLI.

We provide the org:shape:delete command to selected customers through an invitation-only pilot program that requires agreement to specific terms and conditions. Pilot programs are subject to change, and we can’t guarantee acceptance. The org:shape:delete command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the org:shape:delete command in the W19 Pilot: Org Shape for Scratch Orgs group in the Trailblazer Community.

Note

Command Syntax

sfdx force:org:shape:delete
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
[-p]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-p | --noprompt
Optional

Do not prompt for confirmation.

Type: boolean

Help for org:shape:delete

Examples:

1$ sfdx force:org:shape:delete -u me@my.org
1$ sfdx force:org:shape:delete -u MyOrgAlias -p
1$ sfdx force:org:shape:delete -u me@my.org --json
1$ sfdx force:org:shape:delete -u me@my.org -p --json > tmp/MyOrgShapeDelete.json

org:shape:list (Pilot)

Lists all org shapes that you’ve created using the Salesforce CLI.

We provide the org:shape:list command to selected customers through an invitation-only pilot program that requires agreement to specific terms and conditions. Pilot programs are subject to change, and we can’t guarantee acceptance. The org:shape:list command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the org:shape:list command in the W19 Pilot: Org Shape for Scratch Orgs group in the Trailblazer Community.

Note

Command Syntax

sfdx force:org:shape:list
[--json]
[--loglevel LOGLEVEL]
[--verbose]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
--verbose
Optional

Lists more information about each org shape.

Type: boolean

Help for org:shape:list

Examples:

1$ sfdx force:org:shape:list
1$ sfdx force:org:shape:list --json
1$ sfdx force:org:shape:list --json > tmp/MyOrgShapeList.json

org:snapshot:create (Pilot)

Creates a snapshot of a scratch org.

We provide the org:snapshot:create command to selected customers through an invitation-only pilot program that requires agreement to specific terms and conditions. Pilot programs are subject to change, and we can’t guarantee acceptance. The org:snapshot:create command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the org:snapshot:create command in the W19 Pilot: Scratch Org Snapshots group in the Trailblazer Community.

Note

Command Syntax

sfdx force:org:snapshot:create
[--json]
[--loglevel LOGLEVEL]
[-v TARGETDEVHUBUSERNAME]
[--apiversion APIVERSION]
-o SOURCEORG
-n SNAPSHOTNAME
[-d DESCRIPTION]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-o | --sourceorg SOURCEORG
Required

The org ID, or a locally authenticated username or alias, of the scratch org to snapshot.

Type: string
-n | --snapshotname SNAPSHOTNAME
Required

The unique name of the snapshot. Use this name to create scratch orgs from the snapshot.

Type: string
-d | --description DESCRIPTION
Optional

A description of the snapshot. Use this description to document the contents of the snapshot. We suggest that you include a reference point, such as a version control system tag or commit ID.

Type: string

Help for org:snapshot:create

A snapshot is a point-in-time export of a scratch org. The export is stored in Salesforce and referenced by its unique name in a scratch definition file.

Use "sfdx force:org:snapshot:get" to get details, including status, about a snapshot creation request.

With "snapshot" in your scratch org definition file, use "sfdx force:org:create" to create a scratch org from a snapshot.

Examples:

1$ sfdx force:org:snapshot:create --sourceorg 00Dxx0000000000 --snapshotname Dependencies --description "Contains PackageA v1.1.0"
1$ sfdx force:org:snapshot:create -o myuser@myorg -n NightlyBranch -d "Contains PkgA v2.1.0 and PkgB 3.3.0"

org:snapshot:delete (Pilot)

Deletes a scratch org snapshot.

We provide the org:snapshot:delete command to selected customers through an invitation-only pilot program that requires agreement to specific terms and conditions. Pilot programs are subject to change, and we can’t guarantee acceptance. The org:snapshot:delete command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the org:snapshot:delete command in the W19 Pilot: Scratch Org Snapshots group in the Trailblazer Community.

Note

Command Syntax

sfdx force:org:snapshot:delete
[--json]
[--loglevel LOGLEVEL]
[-v TARGETDEVHUBUSERNAME]
[--apiversion APIVERSION]
-s SNAPSHOT

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-s | --snapshot SNAPSHOT
Required

The name or ID (starts with 0Oo) of the snapshot to delete.

Type: string

Help for org:snapshot:delete

Examples:

1$ sfdx force:org:snapshot:delete --snapshot 0Oo...
1$ sfdx force:org:snapshot:delete -s BaseSnapshot

org:snapshot:get (Pilot)

Retrieves details about a scratch org snapshot.

We provide the org:snapshot:get command to selected customers through an invitation-only pilot program that requires agreement to specific terms and conditions. Pilot programs are subject to change, and we can’t guarantee acceptance. The org:snapshot:get command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the org:snapshot:get command in the W19 Pilot: Scratch Org Snapshots group in the Trailblazer Community.

Note

Command Syntax

sfdx force:org:snapshot:get
[--json]
[--loglevel LOGLEVEL]
[-v TARGETDEVHUBUSERNAME]
[--apiversion APIVERSION]
-s SNAPSHOT

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-s | --snapshot SNAPSHOT
Required

The name or ID (starts with 0Oo) of the snapshot to retrieve.

Type: string

Help for org:snapshot:get

Use "sfdx force:org:snapshot:create" to create a snapshot.

Use "sfdx force:org:snapshot:list" to retrieve all snapshots.

Examples:

1$ sfdx force:org:snapshot:get --snapshot 0Oo...
1$ sfdx force:org:snapshot:get -s Dependencies

org:snapshot:list (Pilot)

Lists scratch org snapshots for your Dev Hub.

We provide the org:snapshot:list command to selected customers through an invitation-only pilot program that requires agreement to specific terms and conditions. Pilot programs are subject to change, and we can’t guarantee acceptance. The org:snapshot:list command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the org:snapshot:list command in the W19 Pilot: Scratch Org Snapshots group in the Trailblazer Community.

Note

Command Syntax

sfdx force:org:snapshot:list
[--json]
[--loglevel LOGLEVEL]
[-v TARGETDEVHUBUSERNAME]
[--apiversion APIVERSION]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: warn
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string

Help for org:snapshot:list

Use "sfdx force:org:snapshot:get" to get details about a snapshot request.

Use "sfdx force:org:snapshot:create" to create a snapshot.

Examples:

1$ sfdx force:org:snapshot:list
1$ sfdx force:org:snapshot:list -v OtherDevHub@example.com