Create Sandbox

Create a new Salesforce sandbox org.

This command creates a new sandbox org from a source org (production or another sandbox). You can specify the sandbox configuration using command-line options or a definition file.

Usage

$ sfp sandbox:create -v <string> -n <string> -s <string> [flags]
$ sfp org:create:sandbox -v <string> -n <string> -s <string> [flags]

Flags

FlagRequiredDescription
-v, --targetdevhubusername=<value>YesUsername or alias of the production org
-n, --name=<value>Yes (if no definition file)Name of the sandbox to create
-s, --sourcesandbox=<value>NoName of the source sandbox to clone
-f, --definition-file=<value>NoPath to a sandbox definition file
-d, --description=<value>NoDescription of the sandbox
--activation-user-group=<value>NoName of the public group whose members are activated (able to log in) in the new sandbox
--license-type=<value>NoDeveloper, Developer_Pro, Partial or Full, case-insensitive. Defaults to Developer. Ignored when cloning
--template-id=<value>NoId of the sandbox template, for Partial and Full sandboxes
--history-days=<value>NoDays of object history to copy, for Full sandboxes: -1 (all), 0, 10, 20, 30, 60, 90, 120, 150 or 180
--apex-class-id=<value>NoId of the Apex class Salesforce runs after the copy completes
--[no-]auto-activateNoSets AutoActivate on the new sandbox
--jsonNoFormat output as JSON
--loglevel=<option>NoLogging level for this command invocation

--license-type, --template-id, --history-days, --apex-class-id, --auto-activate, --description and --activation-user-group take precedence over the same field in a definition file. Apart from the license type, a field that is set in neither is not sent to Salesforce.

An unknown license type fails the command before a sandbox is requested. A historyDays of 0 is not sent.

Examples

$ sfp sandbox:create -v MyDevHub -n MySandbox1 -s SourceSandbox
$ sfp sandbox:create -v MyDevHub -n MySandbox2 --license-type Developer_Pro --activation-user-group "Sandbox Access"
$ sfp sandbox:create -v MyDevHub -n MyFullSbx --license-type Full --template-id 1ps000000000000001 --history-days 30

Cloning a sandbox

With --sourcesandbox, or sourceSandboxName in a definition file, the new sandbox is cloned from that sandbox. No license type is sent, so the new sandbox has the source's license, and the source's features are copied.

If the source sandbox is not found in the production org, the command fails with Source sandbox '<name>' not found in the production org and no sandbox is created. It does not fall back to creating the sandbox from production.

Sandbox definition file

A definition file is a JSON file passed with --definition-file. It sets either sourceSandboxName (clone) or licenseType (create from production), not both:

{
  "sandboxName": ["MySandbox"],
  "description": "My sandbox description",
  "licenseType": "Partial",
  "templateId": "1ps000000000000001",
  "activationUserGroupName": "Sandbox Access",
  "apexClassId": "01p000000000000001",
  "autoActivate": true,
  "copyChatter": true,
  "historyDays": 0
}

In a definition file, licenseType is one of Developer, Developer_Pro, Partial or Full, and historyDays is one of the values listed for --history-days. The file is validated before any sandbox is requested.

--name and --definition-file cannot be used together, and --sourcesandbox requires --name.

On this page