Matching Requests and Responses by Using 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 x-correlation-id header that contains the value of correlation-id. The API also generates its own correlation ID for each response. The string that is provided in the x-correlation-id header is a combination of the user-provided correlation ID and the SCAPI-generated correlation ID with a comma separating the two IDs.

Example headers:

The value of correlation-id must be a universally unique identifier (UUID) and follow version 4 of the UUID standard: 36 characters long, including 3 hyphens. For more details on formatting, see the Universally unique identifier article on Wikipedia.

The SCAPI-generated correlation ID is shorter and doesn’t follow the UUID standard.

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 x-correlation-id header, so you can query for the user-provided correlation ID, the SCAPI-generated correlation ID, or the combined string.

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.