View SCAPI Logs and Track Requests

Log Center provides comprehensive logging and monitoring capabilities for B2C Commerce API (SCAPI) operations. Use Log Center to troubleshoot issues, monitor performance, and analyze API behavior across your B2C Commerce instances.

You can use the B2C Commerce CLI to interface with B2C logging systems to tail logs or fetch specific request IDs. First, see B2C CLI, MCP and Tooling SDK to install the tool and authenticate.

Once configured, use the CLI to retrieve log information:

For a complete list of logging CLI commands, see Logs Commands.

  1. Log in to Business Manager.
  2. Click App Launcher App Launcher and then select Administration > Site Development > Development Setup. If you built your site using Progressive Web App (PWA) Kit, first complete the prerequisites described in Debug Using Log Center.

For general information on Log Center, see Centralized Log Center.

In Log Center, navigate to Logs > Search.

SCAPI logs appear in Log Center with a delay of up to 5 minutes.

You can use correlation IDs to match a particular request to a particular response, making it easier to troubleshoot unexpected issues, such as internal server errors.

If a correlation-id header is provided in a request to a SCAPI endpoint, the response contains an correlation-id header that contains the value of correlation-id. The API also generates its own correlation ID for each response. This generated ID is provided in the sfdc_correlation_id response header.

Example headers:

The value of correlation-id must only contain word characters, hyphens (-), and commas (,). Other characters may prevent you from searching for that correlation ID string in Log Center.

For most Commerce API endpoints, the correlation-id can be automatically added to log messages with a hook. Query these messages in Log Center with an LCQL (Log Center Query Language) expression that filters messages based on the externalID field. The externalID field contains the value of the correlation-id response header, so query for the user-provided correlation ID, the SCAPI-generated correlation ID, or the combined string.

If you can reproduce an issue, you might be able to identify the problem either by attaching your own correlation ID or by observing the automatically generated correlation ID in the response.

Use this correlation ID to trace specific requests:

  1. In Log Center search, enter the correlation ID in the search field or use a Log Center Query Language (LCQL) expression on the externalID field, for example: externalID:(9527f1869f95a32d).
  2. Filter by relevant service types for more focused results, which is only recommended if the result set is very large.

Some groups of Commerce API endpoints are not used exclusively with B2C Commerce and therefore can’t log requests and responses to Log Center. These API groups include CDN Zones, Inventory Availability, Inventory Impex, Inventory Reservation, Shopper Context, and Shopper Login.

You can also use the SCAPI logs in Log Center to investigate patterns of frequent errors:

  1. Select the SCAPI category or categories from the dropdown menu.
    • Select scapi-http to identify requests with specific error response codes.
    • Select scapi to find error messages about how the SCAPI requests are processed, for example: incorrect requests, failing authentication, or routing issues.
  2. Execute a search to identify error status types that occur.
  3. To dig deeper into a specific error, obtain one or multiple correlation IDs from the results and search for further entries with the same correlation ID. For details, see Investigating By Correlation ID.

Use SCAPI verbose logging to investigate errors, long latencies, hook execution errors, and remote service call errors within a single request context. Enable verbose logging in two ways:

  • Automatic setup - Configure conditions that automatically trigger verbose logging (recommended for production environments where code changes are difficult).
  • Request header - Add the sfdc_verbose header to individual requests (recommended for development environments where flexibility is needed).

The header method always takes precedence over automatic settings.

With B2C Commerce version 24.7, generate a JSON document that contains comprehensive information about the request. This JSON document is beneficial for troubleshooting, because it provides detailed information that is not included with standard logging, such as request authorization, hook execution, request query parameters, headers, and body.

To mitigate potential performance issues, the usage of the header is subject to rate limiting. Headers should only be used for individual test requests when a detailed investigation is necessary.

To enable this feature, include the following header in your request:

  • Header: sfdc_verbose: true

Upon the completion of the request, a JSON document is created and logged within the INFO log associated with the correlation ID of that request.

Additionally, a request with the sfdc_verbose header creates scapi-http log entries in Log Center for all responses, while only error logs are available for non-verbose requests.

In combination with the correlation-id, the sfdc_verbose header can be used to generate and find verbose log output in the Log Center.

With B2C Commerce version 26.6, verbose logging has been enhanced to always track verbose logs automatically for a selected set of conditions.

Verbose logging automatically captures logs when:

This feature is enabled via a feature toggle from SFCC during rollout and remains enabled.

  • SCAPI requests that call 3rd parties via remote service calls which return errors
  • SCAPI requests ending with 4xx/5xx responses caused by hook execution errors

This feature is enabled via a feature toggle from SFCC during rollout and remains enabled.

Once a condition described above is met, a JSON document is created and logged within the INFO log associated with the correlation ID of that request.

  1. Log in to Log Center as described in Start Log Center.
  2. Use the correlation ID or the category scapi.verbose in combination with the Log Center Search to find the corresponding log entry.

The following example shows the objects (auth, request, response, customApi, hooks, services) that can be present in a verbose log entry:

You can view SCAPI and SCAPI hook metrics in the Metrics Dashboard. To view the metrics, click Metrics in Log Center, and then click SCAPI or SCAPI Hooks. See Metrics Dashboard.

Additional SCAPI metrics are provided in the CCAC SCAPI Dashboard

For additional details, see Log Center Metrics Documentation.