Match Request and Response Codes with Correlation IDs

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 from the ability to search 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. You can 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 you can query for the user-provided correlation ID, the SCAPI-generated correlation ID, or the combined string.

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

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.