Skip to main content

Create and Monitor an On-Demand Sandbox

Learning Objectives

After completing this unit, you’ll be able to:

  • Authorize the Sandbox API to issue calls.
  • Create a sandbox with specific resource profiles.
  • Configure an operation scheduler to automate uptime.
  • Monitor the status of your sandbox instances.
  • Run lifecycle operations including Start, Stop, Reset, and Restart.

Take Control of Your Environment with the Commerce for B2C Sandbox API

The Commerce for B2C Sandbox API is a powerful way to develop and test Agentforce Commerce for B2C solutions in a controlled environment. You use the API to create, manage, and configure and interact with sandbox instances programmatically. The API helps you test integrations, customizations, and new features without affecting your live production systems. Use the Commerce for B2C Sandbox API for direct interaction, automation, continuous integration (CI) and continuous delivery (CD) processes, and precise resource management.

Access and Authorize the API

Before you can issue commands, you establish a secure connection by authorizing your access.

  1. Go to B2C Commerce Developer Sandbox REST API.
  2. Click Authorize to initiate the login process.
  3. Enter the API Client ID configured in Account Manager.
  4. Click Authorize and then Close to dismiss the window.

After you authorize your connection, you can issue calls directly from the interface.

Create an On-Demand Sandbox

Use the POST/sandboxes method to create an on-demand sandbox to these specifications:

  • emails: email@salesforce.com
  • TTL: 0
  • autoScheduled: True
  • Tags: environment development, team engineering, project ecommerceProj
  • Start and Stop Scheduler: Weekdays Mon - Fri
  • Start time: 08:00:00+03:00
  • Stop time: 19:00:00Z
  • analyticesEnabled: false
  • Resource profile: Medium
  • Settings OCAPI: Specify resources for products and categories respectively.
  • Settings webdav: Specify directory paths for cartridges and impex.

Commerce for B2C On-Demand Sandbox REST API Swagger interface for POST/sandboxes Create sandbox.

Here’s how you create an on-demand sandbox with thePOST/sandboxes method.

  1. From the Commerce for B2C Developer Sandbox REST API, locate and expand the POST/Sandbox method.
  2. Expand the POST/sandboxes method in the Sandboxes section.
  3. Complete the request body as per the sandbox specifications. Some properties are optional.

Property

Value Type

Description

Sample Value

Realm

string

The realm property is a unique identifier that specifies the associated sandbox realm for an Agentforce Commerce for B2C instance.

"abcd1234"

Emails

string

Time to Live (TTL)

integer

Time to live (TTL), expressed in hours, determines the sandbox's lifespan, efficiently managing resources by automatically terminating the environment after the set time.

"ttl": 160

autoScheduled

boolean

The autoScheduled property dictates if sandbox creation is scheduled automatically (true) or triggered manually (false).

"autoScheduled": true

tags

object (key-value pair) where:

  • The key is a string representing the tag name.
  • The value is a string representing the tag value.

The tags property adds descriptive metadata to sandboxes for organizing, filtering, or identifying them based on custom attributes.

{
 "tags": {
   "environment": "development",
   "team": "engineering",
   "project": "ecommerceProj"
 }
}

analyticsEnabled

boolean

The analyticsEnabled property dictates if analytics are enabled (true) or turned off (false) for the new sandbox.

{
"analyticsEnabled": true
}

startScheduler

  • weekdays
  • time

object

array of strings

string

The startScheduler property controls automated sandbox scheduling, automating when processes start at specified times on designated weekdays.

  • weekdays: Specifies the days of the week when the scheduler starts.
  • time: Indicates the time of day when the scheduler starts. The format includes the time and time zone offset. For example, 08:00:00+03:00.
"startScheduler": {
    "weekdays": [
      "MONDAY",
      "TUESDAY",
     "WEDNESDAY",
      "THURSDAY",
      "FRIDAY"
    ],
    "time": "08:00:00+03:00"
  },

stopScheduler

  • weekdays
  • time

object

array of strings

string

The stopScheduler property controls automated sandbox scheduling, automating when processes stop at specified times on designated weekdays.

Specifies the days of the week when the scheduler stops.

Indicates the time of day when the scheduler stops. The format includes the time and time zone offset. For example, 19:00:00Z.

"stopScheduler": {
    "weekdays": [
      "MONDAY",
      "TUESDAY",
     "WEDNESDAY",
      "THURSDAY",
      "FRIDAY"
    ],
    "time": "19:00:00Z"
  },

resourceProfile

string

The resourceProfile property sets the allocated resources (CPU, memory) for the sandbox. Select a profile that matches your development or testing requirements.

  • medium: (Default) 1 CPU, 10-GB storage. Good for standard development.
  • large: 2 CPUs, 20-GB storage. Use for larger datasets.
  • xlarge or xxlarge: Up to 8 CPUs and 100-GB storage. Use for performance-intensive tasks.

medium

Settings

  • ocapi
  • client_id
  • resources
  • resources_id
  • methods
  • read_attributes
  • write_attributes
  • webdav
  • client_id
  • permissions
  • path
  • operations

object

array of objects

string

array of objects

string

array of strings

string

string

array of objects

string

array of objects

string

array of strings

Configuration settings for the sandbox environment, including ocapi and webdav configurations. This structure ensures secure and controlled access to resources and directories within the Commerce for B2C sandbox environment.

Defines the Open Commerce API (OCAPI) settings, including client access and resource permissions.

Represents the client identifier used to authenticate API requests.

Specifies the resources accessible via OCAPI and their associated permissions.

Identifies the resource path. The value "/*"indicates access to all resources.

Lists the HTTP methods available for the resource. Possible values include"get", "post","put", "patch", and "delete".

Specifies the attributes that can be read. The value"(*)" indicates that all attributes are readable.

Specifies the attributes that can be written. An empty string indicates that no attributes are writable.

Defines WebDAV settings for file operations, such as managing cartridges, and importing and exporting files.

Represents the client identifier used to authenticate WebDAV requests.

Specifies the directories and operations that are accessible via WebDAV.

Indicates the directory path. Examples include "/cartridges" and "/impex".

Lists the operations permitted on the specified path. Possible values include "read_write".

json
{
"settings": {
"ocapi": [
{
"client_id": "sample-client-id-12345",
"resources": [
{
"resource_id": "/s/-/dw/data/v20_10/products",
"methods": [
"get",
"post",
"put",
"patch",
"delete"
],
"read_attributes": "(**)",
"write_attributes": "(**)"
},
{
"resource_id": "/s/-/dw/data/v20_10/categories",
"methods": [
"get",
"post",
"put",
"patch",
"delete"
],
"read_attributes": "(**)",
"write_attributes": "(**)"
}
]
}
]
}
}
{
 "settings": {
   "webdav": [
     {
       "client_id": "sample-client-id-12345",
       "permissions": [
         {
           "path": "/cartridges",
           "operations": [
             "read_write"
           ]
         },
         {
           "path": "/impex",
           "operations": [
             "read_write"
           ]
         }
       ]
     }
   ]
 }
}

Commerce for B2C On-Demand Sandbox REST API Swagger interface for POST/sandboxes Create sandbox. Enter property values and click Execute.

  1. Click Execute to create the instance.

Manage an On-Demand Sandbox

To effectively manage a Commerce for B2C on-demand sandbox (ODS), you need to perform several key operations to ensure efficient development and testing environments, efficient use of credits, and accurate troubleshooting.

Check the Status of a Sandbox

You can check the status of a sandbox by using the GET/sandboxes/{sandboxId}method, which returns the current state (started, stopped, or upgrading). You use this verification to avoid wasting time trying to access a loading system after a sandbox creation or restart.

For start, stop, reset, and restart operations, use the POST/sandboxes/{sandboxId}/operationsmethod.

  • Stop: Pauses work and conserves credits without deleting the instance.
  • Start: Starts work and resumes consuming credits.
  • Reset: Clears the database (DBINIT) for a fresh test dataset or data recovery.
  • Restart: Reboots the instance and resolves stuck processes or applies configuration changes.

You define the action in the request body. After you perform any of these actions, always check the sandbox status to confirm the state change.

Commerce for B2C On-Demand Sandbox REST API Swagger interface for POST/sandboxes/{sandboxId

Delete an On-Demand Sandbox

To lower cost and keep your realm organized, delete obsolete sandbox environments, like those that remain after a feature branch merge or a completed testing cycle, by using the DELETE/sandboxes/{sandboxId} API method. This action permanently removes the sandbox, stops credit consumption, and deletes all associated data. If you frequently need the same sandbox setup, consider automating the creation and data import process with APIs so you can quickly recreate the environment after deletion.

Commerce for B2C On-Demand Sandbox REST API Swagger interface for DELETE/sandboxes/{sandboxId} Delete sandbox.

Check On-Demand Sandbox Credits

Project managers and admins monitor resource consumption to ensure budget compliance. Tracking credit usage helps you identify high-consumption sandboxes or unexpected spikes in realm activity over specific periods.

You can verify usage at the realm level by using the GET/realm/{realm}/usagemethod, where you specify the realm ID and the begin and end date for the report.

Commerce for B2C On-Demand Sandbox REST API Swagger interface for GET/realms/{realm}/usage Show usage information for realm.

Alternatively, to isolate consumption for a single instance, use the GET/sandboxes/{sandboxId}/usagemethod, providing the sandbox ID and the begin and end date.

Commerce for B2C On-Demand Sandbox REST API Swagger interface for GET/sandboxes/{sandboxId}/usage Show sandbox usage.

Access On-Demand Sandbox Logs Directly Through Control Center

To diagnose performance issues or code failures quickly, access ODS logs directly through Control Center. With Control Center, you can filter and search server events without needing separate URLs or login credentials for each sandbox.

Don’t Forget Storefront Code and Data

A new ODS doesn't contain storefront data. You can’t directly migrate code and data from a POD-based sandbox to an ODS. You can export data and code from a POD sandbox and then use the ODS API to import the data and code into an ODS.

Resources

Salesforce Developer Guide: On-Demand Sandboxes

在 Salesforce 帮助中分享 Trailhead 反馈

我们很想听听您使用 Trailhead 的经验——您现在可以随时从 Salesforce 帮助网站访问新的反馈表单。

了解更多 继续分享反馈