x-request-id header that names that one request. Use it to connect a line in your logs to the request that produced it, and quote it whenever you report a problem: it is the fastest way to find a specific request. This page is for anyone writing a client, a logging wrapper, or a bug report.
How the id is chosen
Allowed characters are ASCII letters, digits,
., _ and -, from 1 to 128 of them. A UUID such as 3f0c1a9b-2e4f-4a8c-8d1e-2f3a4b5c6d7e is valid as it is.
Where the id appears
- The
x-request-idresponse header, on every response. Success, error, preflight, and refusals made before the body is read (such as an oversized body) all carry it. error.request_idin every JSON error body. It is the same value as the header.
- Not in plain-text errors. A few framework-level rejections on the keys, usage and billing routes have a text body instead of JSON: malformed JSON, a missing
Content-Type, an unknown field. An unknown path gets an empty body. Their body has norequest_id, but thex-request-idheader is still there. Read it from the header. See Errors.
Send your own id
Sending your own id lets you search your logs and ours with the same string, and ties an OpenType request to the job, ticket or trace that caused it.Choosing ids
- Make each attempt unique. An id names one HTTP request. When you retry, send a new request id (for example with an attempt suffix), even when you keep the same
Idempotency-Key. - Do not confuse it with
Idempotency-Key. The request id is for tracing and changes nothing about how a request is processed. TheIdempotency-KeyonPOST /v1/runsdecides whether a request is a replay. See Idempotency. - Keep secrets out of it. The id is echoed in response headers and error bodies. Never put a key, a token, or personal data in one.
Quote it when you report a problem
1
Log it on every failure
Log the
x-request-id header next to the status and error.code. Log it from the failing attempt, not from a later retry: each attempt has its own id.2
Collect the context
Note the route, the time in UTC, the status, the
code, and for runs the run_id if you have one.3
Quote the id
Include the request id in your report. One id identifies one request, which is what makes it findable.
What goes wrong
Related
- Errors - where
request_idsits in the error envelope. - Error handling - log, classify and retry failures.
- Idempotency - the header that does change how a run is processed.
- Conventions - every other id format.