---
schema_version: "1"
id: cb457eb35ba7ab1fdc3adb8e3812713ac3b619262339897cb52c5daf82c57f12
title: Create an On-Demand Sandbox
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/pwa-kit-managed-runtime/guides/creating-an-on-demand-sandbox.md
canonical_url: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/creating-an-on-demand-sandbox.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7b8142703146a1c0557d5020829b8a9b63a73eefd6dcf5fbd6ce3a4f47a95f83
products:
  - Composable Storefront
  - Salesforce APIs
---
# Create an On-Demand Sandbox

**note:** If you already have a B2C Commerce instance, you can connect to it when you [generate a project](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/quick-start.html#generate-the-project). In that case you can skip the steps below because you don't need an on-demand sandbox.

An on-demand sandbox (ODS) is a special B2C Commerce instance used for development and testing purposes. Although ODS instances are only temporary, they can be made available for up to 90 days.

The code for your PWA Kit storefront doesn’t include info data about catalogs, customers, baskets, etc. To get that critical commerce data, it needs to request it from an ecommerce back end using headless APIs.

Most PWA Kit projects start with at least one on-demand sandbox to serve as a back end while developing the storefront code. Some development teams share a small number of sandboxes while others create many different sandboxes for different purposes.

This guide helps you get started with PWA Kit as quickly as possible without tools or automation. The following steps walk you through creating an on-demand sandbox, importing a demo site, and using demo data. To create an ODS to test your own code and data, see [Get Started with On-Demand Sandboxes](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-get-started-sandboxes.html#create-an-on-demand-sandbox).

## Prerequisites

- An API client ID that you use for creating the ODS. Ask an administrator to create the API client ID using the steps in [Add an API Client in B2C Commerce](https://help.salesforce.com/s/articleView?id=cc.b2c_account_manager_add_api_client_id.htm&type=5). <!-- (Salesforce internal users can get the client ID from [this Concierge article](https://concierge.it.salesforce.com/articles/en_US/Supportforce_Article/Account-Manager-access-and-role-updates).) -->
- The **Sandbox API User** role in Account Manager, with a tenant filter scoped to the sandbox realm.
- The four-character realm ID for your realm. If you don’t know your realm ID, ask your administrator.
- To import data into your ODS, you must have Business Manager administrator permission.

## Create an On-Demand Sandbox with the Sandbox REST API

To create an on-demand sandbox using B2C Commerce Developer Sandbox REST API:

1. Go to the [B2C Commerce Developer Sandbox REST API](https://admin.us01.dx.commercecloud.salesforce.com/). <!-- (Salesforce internal users must use a [different URL](https://admin.dx.commercecloud.salesforce.com/?_ga=2.31494974.1811675384.1719835170-2044223965.1718993109).) -->
2. Click **Authorize**.
3. Enter the API client ID for sandbox creation.
4. Click **Authorize**.
5. Log in with your Account Manager credentials.
6. To dismiss the authorization window and return to the Sandbox API user interface, click **Close**.
7. In the Sandboxes section of the Sandbox API user interface, click to expand the `POST/sandboxes` method.
8. Click **Try it out**.
9. Delete the JSON object in the ProvisioningRequest field.
10. Copy the following JSON object and paste it into the ProvisioningRequest field:

    ```
    {
      "realm": "<your realm id>",
      "ttl": 24,
      "autoScheduled": false,
      "resourceProfile": "medium"
    }
    ```

11. Replace `<your realm id>` with your actual realm ID. Example: `zzdc`.
12. If you want the sandbox to be available for more than 24 hours, replace the `ttl` value with any number of hours up to 2160 (90 days).
13. You can also enter 0 or less for `ttl` to specify that the sandbox lasts until you delete it.
14. Click **Execute**.
15. If the ProvisioningRequest JSON is valid, a server response appears.
16. Copy the response body or click **Download** so that you can refer to it later.

In the next section, you must provide the Business Manager URL for your sandbox. The Business Manager URL can be found in the response body object in `data.links.bm`.

A Business Manager URL looks like this (but with its own unique hostname based on the realm ID and instance ID): `https://zzdc-001.dx.commercecloud.salesforce.com/on/demandware.store/Sites-Site`

More help with on-demand sandboxes is available in the B2C Commerce guide: [Get Started with On-Demand Sandboxes](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-get-started-sandboxes.html).

A more detailed Trailhead module is also available: [Salesforce B2C Commerce On-Demand Sandboxes](https://trailhead.salesforce.com/en/content/learn/modules/b2c-on-demand-sandbox).

## Import Sample Data

We recommend starting your PWA Kit project with a B2C Commerce instance that contains sample data.

Importing site data requires the Business Manager administrator permission. To import sample data into an instance:

1. Go to the Business Manager URL for your instance. (If you just created an ODS, it can take about 10 minutes for Business Manager to be available.)
2. Log in with your Account Manager credentials.
3. Click App Launcher ![App Launcher](https://developer.salesforce.com/docs/media/shared/appLauncher.png) and then select **Administration** > **Site Development** > **Site Import & Export**.
4. Select **Storefront Reference Architecture Demo Sites**.
5. Click **Import**.
6. Select **Storefront Reference Architecture base**.
7. Click **Deploy**.
8. Click **Refresh** to track the progress the deployment.

After the deployment process is complete (about 15 minutes), your instance will contain sample data that can be used while developing with PWA Kit. The sample data import adds two sites: RefArch and RefArchGlobal.

## Rebuild Search Indexes

After your sample data has finished deploying, rebuild your search indexes to reflect the new data.

1. Go to the Business Manager URL for your instance.
2. Log in with your Account Manager credentials.
3. Click App Launcher ![App Launcher](https://developer.salesforce.com/docs/media/shared/appLauncher.png) and then select **Merchant Tools > _Your Site_ > Search > Search Indexes**.
4. Select the site you want to rebuild the indexes for, and select all of the indexes.
5. Click **Rebuild**.

## Set a Default Site

After importing the sample data, you have two sites, RefArch and RefArchGlobal, each for a different currency and locale. Choose a default site based on the desired currency and locale.

The RefArch site uses the US dollar (USD) currency and en-US locale. The RefArchGlobal site uses the British Pound (GBP) currency and en-GB locale. The `config/sites.js` file contains a definition of the sites that you configured in Business Manager. In the `/config/default.js` file, you can set the default site and optionally, map the site IDs with aliases. If no alias is defined for the site, then IDs are used in URLs. This example sets the default site to RefArch and defines an alias.

```
// /config/default.js

defaultSite: 'RefArch',
siteAliases: {
    RefArch: 'us'
},
```

## Troubleshooting

If you see broken catalog images on your PWA Kit storefront shortly after creating a new ODS, wait another 10 minutes or so for the issues to resolve on its own.

## See Also

- [On-Demand Sandboxes](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-developer-sandboxes.html)
- [Develop With Your On-Demand Sandbox](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-develop-with-on-demand-sandbox.html)
