Correlation IDs

While a successful 2xx HTTP response is what most clients should look for, additional metadata is usually included in the HTTP response. For instance, a correlation ID can be provided.

A correlation ID is useful in identifying a request. It is commonly used where the initial API endpoint (usually a load balancer or a request router) creates an ID, and then the ID is propagated throughout the service's systems (e.g. when calling downstream internal services). Logs and metrics can use the correlation ID as part of their context, so it is easy to lookup related logs/metrics using the correlation ID. In effect, the correlation ID can be used to trace a request's execution path across service boundaries. The correlation ID may be propagated to the initial client as part of the HTTP response.

If you are operating a client to a third party service, it is generally beneficial to store correlation IDs for a period of time. When there are issues with processing a request, giving the correlation ID can save time for you and the support team.

Another tip is that you may want to keep correlation IDs for both failed requests and successful ones. There may be times when "successful" requests need to be investigated.

Correlation IDs are also commonly called request IDs, trace IDs, and debug IDs. While there are possible subtle distinctions, in the end, they are useful in isolating relevant data when communicating to a support or development team.