Back

Salesforce Commerce Cloud API Essential Guide

Aug 9, 20246 minute read

What type of API does Salesforce Commerce Cloud provide?

Salesforce Commerce Cloud offers multiple types of APIs, including REST, SOAP, and GraphQL.

REST APIs

  1. REST API: This is the primary REST API for interacting with Salesforce data. It supports JSON and XML formats.
  2. Connect REST API: Used for integrating with specific Salesforce features like B2B Commerce, CMS managed content, Experience Cloud sites, and Chatter.
  3. Analytics REST API: Focused on accessing Salesforce Analytics data.
  4. User Interface API: Used for building UI components and accessing Salesforce data.
  5. Apex REST API: Allows custom REST endpoints to be created using Apex.

SOAP API

  1. SOAP API: This is the primary SOAP-based API for interacting with Salesforce data.
  2. Apex SOAP API: Allows custom SOAP web services to be created using Apex.

GraphQL API

Salesforce provides a GraphQL API, which is useful for making efficient queries and retrieving precisely the data needed.

Other API Types

  1. Bulk API: A REST-based API optimized for processing large data sets.
  2. Metadata API: A SOAP-based API for managing customizations and metadata.
  3. Pub/Sub API: Uses gRPC and protocol buffers for real-time event streaming.
  4. Tooling API: Available in both REST and SOAP formats, used for development tools.

Does the Salesforce Commerce Cloud API have webhooks?

Webhooks in Salesforce Commerce Cloud

  1. The official Salesforce Commerce Cloud API does support webhooks, but they are primarily used in the context of Data Cloud and Data Actions rather than being a core feature of the Commerce Cloud API itself.

  2. Webhooks in Salesforce Data Cloud are used as a target for Data Actions, allowing near real-time notifications when specific events or data changes occur.

Types of Events You Can Subscribe To

  1. Data changes in CRM sources that match specific conditions defined in Data Actions.

  2. Updates to customer data, such as email address changes.

  3. Near real-time notifications for various business processes.

  4. Data synchronization between systems.

  5. Automation and workflow integration.

Key Considerations

  1. Webhook events in Data Cloud are retained for four days.

  2. For scalability and reliability, it's recommended to build a pipeline to consume and process these webhook events.

  3. Salesforce is planning to support replay of events from a particular timestamp in future releases.

  4. While not specific to Commerce Cloud, Salesforce does support customization through hooks for some Shopper APIs, which allow altering and extending the behavior of existing API resources.

It's important to note that the information provided is primarily about Salesforce Data Cloud and general Salesforce webhooks, rather than being specific to Commerce Cloud. For the most up-to-date and accurate information about webhooks in Salesforce Commerce Cloud API, it would be best to consult the official Salesforce Commerce Cloud documentation or contact Salesforce support directly.

Rate Limits and other limitations

Here are the key points about the API Rate Limits for the Salesforce Commerce Cloud API:

General Rate Limits

  • Rate limits can be adjusted based on specific customer scenarios or use cases. Customers should contact their Customer Success Manager or Account Executive for questions about rate limits.

  • For production instances, there is a limit of 24,000 requests per minute (RPM) per tenant.

  • For non-production instances, there is a limit of 500 RPM per tenant.

  • Some specific endpoints like getJwksUri and getWellknownOpenidConfiguration have a lower limit of 25 RPM.

Load Shedding and Rate Limiting Mechanisms

  • Salesforce Commerce Cloud uses both load shedding and rate limiting techniques to maximize availability:

    • Load shedding: APIs intentionally reject incoming requests to prevent system overload.
    • Rate limiting: Controls the frequency of API requests in a given timeframe.
  • If the system reaches a load threshold, an HTTP 503 status code is returned.

  • When rate limits are reached, the API returns an HTTP 429 Too Many Requests response with a Retry-After header.

API Family-Specific Limits

  1. SLAS (Salesforce Login as a Service):

    • 24,000 RPM per tenant for production instances.
    • 25 RPM for specific endpoints like getJwksUri and getWellknownOpenidConfiguration.
  2. Omnichannel Inventory (OCI):

    • Uses rolling rate limits to prevent denial-of-service attacks.
  3. Streaming API:

    • Limits vary based on Salesforce edition (e.g., Performance, Unlimited, Enterprise, etc.).
    • Includes limits on number of topics, clients per topic, concurrent clients, and events per day.
  4. REST API:

    • Has three types of limits: Concurrent API Request Limit, Total API Request Allocation, and API Timeout Limits.
  5. Bulk API:

    • Allows up to 15,000 batch submissions per 24-hour period.
    • Has specific limits on batch size, number of records, and character limits.

Monitoring and Handling Rate Limits

  • Salesforce provides ways to check API usage through the System Overview in Salesforce Settings.

  • When an organization reaches or exceeds its daily API request limit, all users may have their ability to make further calls temporarily disabled.

  • It's important to conduct regular checks to monitor API usage and avoid exceeding limits.

Best Practices

  1. Implement proper handling for HTTP 429 responses, including respecting the Retry-After header.
  2. Design applications to work within the given rate limits or request limit increases if necessary.
  3. Consider using bulk operations for large data sets to optimize API usage.
  4. Regularly monitor API usage to avoid unexpected disruptions.

By understanding and adhering to these rate limits, developers can ensure their applications interact efficiently with the Salesforce Commerce Cloud API while maintaining system stability and performance.

Latest API Version

Based on the search results provided, the most recent version of the Salesforce Commerce Cloud API (also known as B2C Commerce API or SCAPI) is 24.7. Here are the key points:

Current Release

The current release of the Salesforce B2C Commerce API is version 24.7 [1].

Key Points to Consider

  • The B2C Commerce API is also referred to as Salesforce Commerce API (SCAPI) [3].
  • The API is divided into two main groups: Shopper APIs and Admin APIs [3].
  • Regular updates and improvements are made to the API, as evidenced by the detailed release notes [3].

Recent Updates and Features

Some of the recent updates and features include:

  1. Support for patching variations within product bundles in a single call (introduced in version 24.5) [3].
  2. Addition of the Shopper Custom Objects API for retrieving Custom Objects [3].
  3. Support for additional HTTP methods for Custom APIs [3].
  4. Introduction of the Shopper Context API, which is now generally available [3].

Best Practices

  1. Always refer to the latest documentation for the most up-to-date information on endpoints and features.
  2. Use the provided SDKs and Quick Start guides to get started quickly with the API [3].
  3. Pay attention to rate limits and any changes in API behavior mentioned in the release notes.
  4. Use correlation IDs for better request and response tracking [3].

It's important to note that Salesforce regularly updates its APIs, so developers should always check the official documentation for the most current version and features.

How to get a Salesforce Commerce Cloud developer account and API Keys?

1. Sign up for a Salesforce Developer Account

First, you need to create a Salesforce Developer Account if you don't already have one:

  1. Go to the Salesforce Developer website (developer.salesforce.com).
  2. Click on the "Sign Up" button.
  3. Fill out the registration form with your details.
  4. Verify your email address.

2. Access B2C Commerce

Once you have a Salesforce Developer Account, you'll need to get access to B2C Commerce:

  1. Contact Salesforce sales or your account representative to request access to B2C Commerce.
  2. They will provide you with the necessary credentials and access to a B2C Commerce instance.

3. Set up your B2C Commerce instance

After getting access to B2C Commerce:

  1. Log in to your B2C Commerce Business Manager.
  2. Navigate to Administration > Site Development > Salesforce Commerce API Settings.
  3. Request a short code if you haven't used the B2C Commerce API in your realm before.
  4. Note down your organization ID, realm ID, and instance ID.

4. Create an API Client

To create an API integration, you'll need to set up an API client:

  1. In Business Manager, go to Administration > Site Development > Salesforce Commerce API Settings.
  2. Click on "Create Client" to create a new API client.
  3. Configure the client settings, including the client name, scopes, and redirect URIs.
  4. Save the client ID and client secret securely.

5. Configure SLAS (Shopper Login and API Access Service)

For Shopper APIs, you'll need to configure SLAS:

  1. Follow the SLAS configuration guide in the Salesforce documentation.
  2. Set up the necessary authentication methods and scopes for your API client.

What can you do with the Salesforce Commerce Cloud API?

Here's the markdown text with the trailing list of URLs and citation references removed, and any URLs inside the content formatted correctly for the markdown file format:

Store (WebStore)

  • Represents a website for wholesale and retail transactions
  • Allows configuration of supported currencies, languages, and price books
  • Enables customization of many fields

Cart (WebCart)

  • Represents an online shopping cart in B2B or D2C Commerce
  • Allows management of total amounts for products, shipping, handling, and taxes

Catalog (ProductCatalog)

  • Represents a collection of products for sale
  • Enables organization of products into different categories
  • Supports data import for catalog setup

Category (ProductCategory)

  • Allows organization and grouping of products in catalogs and storefronts
  • Supports customization of layout, including name, catalog, category, and search order

Entitlement Policy (CommerceEntitlementPolicy)

  • Connects buyer groups and products
  • Allows filtering by BuyerGroup membership
  • Enables customization of CanViewPrice and CanViewProduct fields

Product (Product2)

  • Represents items and services for sale
  • Supports customization of various fields (name, family, etc.)
  • Allows data import for product information

Buyer Account (BuyerAccount)

  • Manages buyer's or shopper's financial information
  • Includes credit and order limits (some specific to B2B)
  • Supports self-registration for B2C accounts

Buyer Group (BuyerGroup)

  • Represents groups of buyers with shared entitlement policies, price books, and products
  • Allows customization of name and description
  • Automatically creates one buyer group per store for D2C stores during data import

Buyer Group Member (BuyerGroupMember)

  • Associates individual buyers with buyer groups

Price Book (PriceBook2)

  • Contains price definitions for product groups
  • Supports addition during store setup via data import
  • Allows addition of custom fields

Price Book Entry (PricebookEntry)

  • Represents a product entry in a price book
  • Associates a Pricebook2 with a Product2

Key Points to Consider:

  • The Commerce data model connects various store objects to support a full-featured B2B or B2C store experience
  • Many of these data models allow customization of fields and properties
  • Data import is often used to set up and populate these data models
  • The API supports interactions with these data models for various e-commerce operations, including catalog management, pricing, buyer management, and cart functionality