# org create sandbox

Create a sandbox org.

## Description for org create sandbox

There are two ways to create a sandbox org: specify a definition file that contains the sandbox options or use the --name and --license-type flags to specify the two required options. If you want to set an option other than name or license type, such as apexClassId, you must use a definition file.

You can also use this command to clone an existing sandbox. Use the --source-sandbox-name flag to specify the existing sandbox name and the --name flag to the name of the new sandbox.

## Aliases for org create sandbox

`env:create:sandbox`

## Flags

| Flag Name (Long)        | Flag Name (Short) | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ----------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--alias`               | `-a`              | **Type:** Value<br><br>Alias for the sandbox org.<br><br>When you create a sandbox, the generated usernames are based on the usernames present in the production org. To ensure uniqueness, the new usernames are appended with the name of the sandbox. For example, the username "<user@example.com>" in the production org results in the username "<user@example.com.mysandbox>" in a sandbox named "mysandbox". When you set an alias for a sandbox org, it's assigned to the resulting username of the user running this command.                                                                                                                                                                                                                                                                                                                            |
| `--async`               | N/A               | **Type:** Boolean<br><br>Request the sandbox creation, but don't wait for it to complete.<br><br>The command immediately displays the job ID and returns control of the terminal to you. This way, you can continue to use the CLI. To check the status of the sandbox creation, run "sf org resume sandbox".                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `--definition-file`     | `-f`              | **Type:** Value<br><br>Path to a sandbox definition file.<br><br>The sandbox definition file is a blueprint for the sandbox. You can create different definition files for each sandbox type that you use in the development process. See <<https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_sandbox_definition.htm>> for all the options you can specify in the definition file.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `--flags-dir`           | N/A               | **Type:** Value<br><br>Import flag values from a directory.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `--json`                | N/A               | **Type:** Boolean<br><br>Format output as json.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `--license-type`        | `-l`              | **Type:** Value<br>**Valid Values:** `Developer`, `Developer_Pro`, `Partial`, `Full`<br><br>Type of sandbox license.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `--name`                | `-n`              | **Type:** Value<br><br>Name of the sandbox org.<br><br>The name must be a unique alphanumeric string (10 or fewer characters) to identify the sandbox. You can’t reuse a name while a sandbox is in the process of being deleted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `--no-prompt`           | N/A               | **Type:** Boolean<br><br>Don't prompt for confirmation about the sandbox configuration.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `--no-track-source`     | N/A               | **Type:** Boolean<br><br>Do not use source tracking for this sandbox.<br><br>We recommend you enable source tracking in Developer and Developer Pro sandbox, which is why it's the default behavior. Source tracking allows you to track the changes you make to your metadata, both in your local project and in the sandbox, and to detect any conflicts between the two.<br><br>To disable source tracking in the new sandbox, specify the --no-track-source flag. The main reason to disable source tracking is for performance. For example, while you probably want to deploy metadata and run Apex tests in your CI/CD jobs, you probably don't want to incur the costs of source tracking (checking for conflicts, polling the SourceMember object, various file system operations.) This is a good use case for disabling source tracking in the sandbox. |
| `--poll-interval`       | `-i`              | **Type:** Value<br>**Default value:** `30 seconds`<br><br>Number of seconds to wait between retries.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `--set-default`         | `-s`              | **Type:** Boolean<br><br>Set the sandbox org as your default org.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `--source-id`           | N/A               | **Type:** Value<br><br>ID of the sandbox org to clone.<br><br>The value of --source-id must be an existing sandbox (SandboxInfo.Id). The existing sandbox, and the new sandbox specified with the --name flag, must both be associated with the production org (--target-org) that contains the sandbox licenses.<br><br>You can specify either --source-sandbox-name or --source-id when cloning an existing sandbox, but not both.                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `--source-sandbox-name` | N/A               | **Type:** Value<br><br>Name of the sandbox org to clone.<br><br>The value of --source-sandbox-name must be an existing sandbox. The existing sandbox, and the new sandbox specified with the --name flag, must both be associated with the production org (--target-org) that contains the sandbox licenses.<br><br>You can specify either --source-sandbox-name or --source-id when cloning an existing sandbox, but not both.                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `--target-org`          | `-o`              | **Type:** Value<br>**Required**<br><br>Username or alias of the production org that contains the sandbox license.<br><br>When it creates the sandbox org, Salesforce copies the metadata, and optionally data, from your production org to the new sandbox org.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `--wait`                | `-w`              | **Type:** Value<br>**Default value:** `30 minutes`<br><br>Number of minutes to wait for the sandbox org to be ready.<br><br>If the command continues to run after the wait period, the CLI returns control of the terminal to you and displays the "sf org resume sandbox" command you run to check the status of the create. The displayed command includes the job ID for the running sandbox creation.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

## Examples for org create sandbox

Create a sandbox org using a definition file and give it the alias "MyDevSandbox". The production org that contains the sandbox license has the alias "prodOrg".

```shell
sf org create sandbox --definition-file config/dev-sandbox-def.json --alias MyDevSandbox --target-org prodOrg
```

Create a sandbox org by directly specifying its name and type of license (Developer) instead of using a definition file. Set the sandbox org as your default.

```shell
sf org create sandbox --name mysandbox --license-type Developer --alias MyDevSandbox --target-org prodOrg --set-default
```

Clone the existing sandbox with name "ExistingSandbox" and name the new sandbox "NewClonedSandbox". Set the new sandbox as your default org. Wait for 30 minutes for the sandbox creation to complete.

```shell
sf org create sandbox --source-sandbox-name ExistingSandbox --name NewClonedSandbox --target-org prodOrg --alias MyDevSandbox --set-default --wait 30
```

Clone the existing sandbox with ID "0GQB0000000TVobOAG" and do not wait.

```shell
sf org create sandbox --source-id 0GQB0000000TVobOAG --name SbxClone --target-org prodOrg --async
```
