Quickstart

Quickstart: Log requests with the request id

The request_id on every response is your thread back to a specific call — log it structured, on success and failure alike. This recipe shows the exact code, uses only the unauthenticated public ring, and links out to the endpoints and the application flow so the reader always has a next step.

2 min read

request_idOn every response
X-Request-IdAlso in the header
structuredLog key/value, not text

Log it structured

const res = await fetch(url, init);
const reqId = res.headers.get('X-Request-Id');
logger.info('credicorp.call', {
  url, status: res.status, request_id: reqId,
});

Emit key/value fields, not a concatenated string, so you can filter by request_id or status later.

Use it with support

When something looks wrong, quote the request_id in your ticket. It lets the team pull your exact request and response, which turns a vague report into a five-minute fix.

Frequently asked questions

Where is the request id?

In the JSON body as request_id and in the X-Request-Id response header. They match. Log whichever is convenient.

Should I log request bodies?

Log metadata, not full bodies with personal data. The request_id is enough to correlate with the server side without storing PII.

Funding for UK limited companies

Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.