---
schema_version: "1"
id: c7ecc4287488d11e3fd4db7bbf2257fb8e91dc46ff8ba678b4803fd3ffebcec7
title: Create a Package Version Based on a Scratch Org Snapshot
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform-pkg-exchange/managed_packaging/guides/second-generation/dev2gp-so-pkg-snapshot.md
canonical_url: https://developer.salesforce.com/docs/platform/pkg2-dev/guide/dev2gp-so-pkg-snapshot.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1ad2de9289d6ecbed3a84f57918b3c571b4f3aa365804f6fb18a8ac5bb7f12da
products:
  - Second-Generation Managed Packaging Developer Guide
  - merged-docs
---

# Create a Package Version Based on a Scratch Org Snapshot

If the dependent package your base package requires is stable, you can reduce the end-to-end package version creation time by creating a scratch org snapshot.

## Before You Begin

If you haven’t reviewed [When to Use Scratch Org Snapshots in Package Development](https://developer.salesforce.com/docs/platform/pkg2-dev/guide/dev2gp-so-when-use-snapshot.md), review that topic before continuing.

There’s more than one workflow you can follow when creating a package version based on a scratch org snapshot. You can start by creating a scratch org, you can build your own scratch org definition file, or you can choose to use org shape to create a new scratch org. Whichever path you choose, after the scratch org is created, you install all the dependent packages into it, and then take a snapshot of the scratch org.

Sample Workflow

This workflow uses an org shape to create the initial scratch org where you’ll install the stable dependent packages, and then create a scratch org snapshot to create a package version.

1.  Create the org shape.

    ```nolang
    sf org create shape --target-org source-org1
    ```

2.  Create a scratch org definition file that indicates the shape’s source org.

    ```nolang
    {
      "orgName": "Salesforce",
      "sourceOrg": "00DB1230400Ifx5"
    }

    ```

3.  Create a scratch org using the org shape.

    ```nolang
    sf org create scratch --duration-days 30 --no-namespace --no-ancestors --definition-file config/scratch-def-with-shape-id.json --alias dev1-with-shape
    ```

    If your default Dev Hub org isn’t the one that owns the org shape, indicate it on the command line.

4.  Install the dependent packages.

    ```nolang
    sf package install --package 04txx --target-org dev1-with-shape
    ```

5.  Create a snapshot of the scratch org.

    ```nolang
    sf org create snapshot --name dhsnapshot --source-org dev1-with-shape --target-dev-hub dev-hub
    ```

6.  Create a new scratch org definition file and specify the snapshot name, then save the file.

    ```nolang
    {
      "orgName": "Salesforce",
      "snapshot": "dhsnapshot"
    }

    ```

7.  Create a package version using the org snapshot. This command is specifying the scratch org definition file that contains the snapshot information in it.

    ```nolang
    sf package version create --package hc-ext1 --code-coverage --installation-key-bypass --async-validation --definition-file
    scratch-def-with-snapshot-id.json

    ```

**See Also**

- [When to Use Scratch Org Snapshots in Package Development](https://developer.salesforce.com/docs/platform/pkg2-dev/guide/dev2gp-so-when-use-snapshot.md)
- [_Salesforce DX Developer Guide_: Create Org Shapes](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_create.htm)
