---
schema_version: "1"
id: e2e25255adbce457d8408f3ef3c64f24dfba0e838b34ef076a0452a9054d33a2
title: Get Started with On-Demand Sandboxes
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/b2c-commerce/guides/sandboxes/b2c-get-started-sandboxes.md
canonical_url: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/b2c-get-started-sandboxes.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: e59babc5b1efc080fcba21347b923652a9f6a2b08237c7268711299564ac7546
products:
  - Composable Storefront
  - Salesforce APIs
---
# Get Started with On-Demand Sandboxes

To access on-demand sandboxes, you must purchase sandbox credits, set up user roles, configure an API client key, and obtain your realm ID. Then provision and manage on-demand sandboxes as a self-service feature using the Sandbox API.

## Purchase On-Demand Sandbox Credits

To use on-demand sandboxes, you must purchase sandbox credits. Contact your Account Executive for more information.

When you issue a Sandbox API call to create a new on-demand sandbox, the system checks to make sure that your license has remaining credits. A user assigned to the Sandbox API User role controls how the credits are consumed. Monitor credit usage on a sandbox or on the realm using the Sandbox API.

## Set Up User Roles for On-Demand Sandboxes

An administrator uses Account Manager to assign appropriate roles to on-demand sandbox users. For each role, configure a scope filter and set it to either All Sandboxes or one or more individual sandboxes in the realm. A user with scope filter of All Sandboxes has access to all sandboxes as well as realm level operations, including realm level usage, creating and deleting a sandbox in the realm. A user with scope filter of individual sandboxes has access to only those individual sandboxes and the APIs of the sandboxes; the user doesn't have access to realm level operations or creating a new sandbox in the realm.

To assign roles to new or existing users, use the [Create a User Account in B2C Commerce](https://help.salesforce.com/s/articleView?id=cc.b2c_account_manager_create_user.htm) or [Edit a User Account in B2C Commerce](https://help.salesforce.com/s/articleView?id=cc.b2c_account_manager_edit_user.htm) procedures.

| Role                           | Purpose                                                                                                                                                           | Persona                                     | Scope Filter  |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------- |
| Sandbox API User               | Create, manage, and operate on-demand sandboxes. Users assigned to the Sandbox API User role can create on-demand sandboxes and consume credits and affect costs. | Administrator or Developer (optional)       | All Sandboxes |
| Business Manager Administrator | Access the on-demand sandbox using Business Manager, maintain data and use administrative functionality of on-demand sandboxes from Business Manager.             | Business Manager Administrator or Developer | All Sandboxes |
| Log Center User                | View log files for on-demand sandboxes in Logcenter.                                                                                                              | Administrator or Developer                  | All Sandboxes |
| OCAPI Explorer Debug User      | View debug information for OCAPI REST calls to the on-demand sandboxes.                                                                                           | Developer                                   | All Sandboxes |

## Configure an API Client ID

To allow users access to the Sandbox API, the administrator uses Account Manager to create an API client ID. If you plan to use scripts to automate API calls, the API Client ID requires the password for authentication.

To add an API client ID for the Sandbox API, use the [Add an API Client in B2C Commerce](https://help.salesforce.com/s/articleView?id=cc.b2c_account_manager_add_api_client_id.htm) procedure.

| Setting                    | Value                                                                                                                                    |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Default Scopes             | <ul><li>roles</li> <li>tenantFilter</li> <li>profile</li></ul>                                                                           |
| Redirect URLs              | [https://admin.dx.commercecloud.salesforce.com/oauth2-redirect.html](https://admin.dx.commercecloud.salesforce.com/oauth2-redirect.html) |
| Token Endpoint Auth Method | `client_secret_post`                                                                                                                     |
| Access Token Format        | `JWT`                                                                                                                                    |

## Get Your Realm ID

To create and manage sandboxes, you must know the ID of your realm.

A realm contains your Primary Instance Group (PIG) and Secondary Instance Group (SIG). The SIG contains the sandboxes. Each realm has a unique four-character ID that you can get from your Account Executive (AE) or Customer Success Manager (CSM).

## Create an On-Demand Sandbox

### Automate Sandbox Management with the B2C Commerce CLI

You can skip manual API calls and manage your ODS lifecycle directly from your terminal. First, see [Agentic B2C Developer Toolkit](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/b2c-developer-tooling.md) to install the tool and authenticate.

**note:** To manage sandboxes via the CLI, your Account Manager user (or API Client) must be assigned the Sandbox API User role with a scope filter set to "All Sandboxes" for your specific realm. See [On-Demand Sandboxes for B2C Commerce Partners](https://help.salesforce.com/s/articleView?id=000388949&type=1) for detailed instructions.

Once configured, use the CLI to create, start, or stop sandboxes programmatically:

```Bash
b2c sandbox create --realm <id>
```

For a complete list of Sandbox CLI commands, see [Sandbox Commands](https://salesforcecommercecloud.github.io/b2c-developer-tooling/cli/sandbox.html).

### Set Up Your Sandox Using the Sandbox API

Use the `POST/sandboxes` method of the Sandbox API to create an on-demand sandbox.

1.  To open the Sandbox API user interface, go to [B2C Commerce Sandbox API](https://admin.dx.commercecloud.salesforce.com/).

2.  Click **Authorize**.

3.  Enter the API client ID for the Sandbox API.

4.  To dismiss the authorization window and return to the Sandbox API user interface, click **Close**.

5.  In the Sandboxes section of the Sandbox API user interface, click to expand the `POST/sandboxes` method.

6.  Click **Try it out**.

7.  In the request body, replace `<your realm id>` with the appropriate value.

8.  If you don't want to use 24 hours for the Time-to-Live value for the sandbox, replace the **ttl** value of 24 with any number of hours up to 2160. Enter 0 or less for **ttl** to specify that the sandbox lasts until you delete it.

9.  Enter values for OCAPI or WebDAV settings if applicable, or delete those sections of the request body. To upload and deploy your code, and import site data, provision your ODS with the correct API client ID <link to correct info> By provisioning your sandbox with a [WebDAV](https://help.salesforce.com/s/articleView?id=cc.b2c_web_dav_client_permissions.htm&type=5) and [OCAPI](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-commerce-ocapi/ocapisettings.html) configuration, use tools such as [sfcc-ci](https://github.com/SalesforceCommerceCloud/sfcc-ci) to further bootstrap your sandbox.

10. Click **Execute**.

    ![Request Body Contents](https://developer.salesforce.com/media/b2c-commerce/b2c_sandboxes_create_sandbox_minimum.png)

## Access Business Manager for On-Demand Sandboxes

You access Business Manager for on-demand sandboxes with a unified cluster-agnostic host name, so you don't have to remember the cluster that your sandbox belongs to.

To access Business Manager use a hostname that matches the pattern `<realm>-<instanceId>.dx.commercecloud.salesforce.com, for example, zzzz-001.dx.commercecloud.salesforce.com.` It also matches the domain name of the B2C centralized admin API server, [https://admin.dx.commercecloud.salesforce.com/](https://admin.dx.commercecloud.salesforce.com/).
