Applies to: Storefront Next and Composable Storefront
Automate Storefront Administration with APIs
Perform automated storefront administration and development tasks to streamline your storefront development lifecycle and CI/CD. Using the API, create a storefront, update, edit, and delete storefronts. Create and manage environments, environment variables, access control headers, and redirects. Use one of two APIs: B2C Commerce (SCAPI) or Managed Runtime (MRT) API. We recommend you use SCAPI for automation based on a bot user. Also, use SCAPI to create and edit storefronts, and edit environment settings, which are not available in the MRT API.
Creating a storefront is currently available for Storefront Next only and isn’t supported for Composable Storefront.
SCAPI offers ease of setup because you use the same Account Manager API authorization as other SCAPI endpoints that you’re already familiar with for other API administration tasks. You don’t need to create a separate Managed Runtime API key. The authorization mechanism used in SCAPI enables using a bot user for full automation.
These API families are available for managing the storefront resources.
Accessing each storefront API family requires OAuth2 authorization and setting up specific scopes in Account Manager.
- Create an Account Manager API client with the scopes required to access the storefront APIs. See Authorization for SCAPI Admin APIs. Add these scopes for all API families in the allowed scopes section. By default, each scope grants read-only access if you don’t specify
.rwin the scope name. Append.rwto grant read and write access.sfcc.storefront.storefronts[.rw]: Access to storefronts. Grant write access for creating, editing, and deleting a storefront.sfcc.storefront.environments[.rw]: Access to environments and environment variables. Grant write access for creating and deleting environments, editing environment settings, and creating, editing, and deleting environment variables.sfcc.storefront.deployments[.rw]: Access to deployments. Grant write access for uploading bundles and deploying them.
- Request an access token to use for OAuth2 authorization. Insert the access token in the
$SCAPI_TOKENvalue in the header of each HTTP request.
Here are examples of common tasks. Configure the correct scope in Account Manager for each API family. See SCAPI Authorization. For all API requests that you can make, see the API reference.
For a walkthrough of creating Storefront Next and deploying it to an environment, see Create Storefront Next with SCAPI.
These examples use the curl tool to send API requests. For more information, see Curl.
For a full description, see createStorefront.
For a full description, see createEnvironmentForStorefront.
The endpoint for creating an environment variable is common for updating and deleting environment variables. All use the PATCH method.
For a full description, see updateEnvironmentVariables.
Use the Managed Runtime API to automate the administration tasks in your app. The API offers similar capabilities to SCAPI but requires a different authorization mechanism and doesn’t support creating storefronts. It precedes SCAPI and is based on Runtime Admin resources. Managed Runtime API is available for Storefront Next and Composable Storefront. To learn more, see Managed Runtime API.
During planned maintenance windows, the Managed Runtime API rejects write requests (POST, PUT, PATCH, and DELETE) with an HTTP 503 Service Unavailable response and error code service_read_only. Read requests (GET) continue to work normally. Retry write requests after the maintenance window concludes.