Skip to main content

Logging and Request IDs

Last reviewed: 2026-05-13
Maintained by: Engineering

The API attaches a request ID to inbound traffic and carries that ID through logs and JSON responses.

Current behavior

  • x-request-id is accepted from the client when present
  • otherwise the API generates a UUID
  • the response echoes x-request-id
  • JSON payloads include requestId when the payload is an object
  • request completion logs include method, path, status code, duration, and request ID

Key implementation areas

  • request context middleware: apps/api/src/middlewares/request-context.ts
  • request logging middleware: apps/api/src/middlewares/request-logger.ts
  • logger implementation: apps/api/src/lib/logger.ts
  • response envelope helpers: apps/api/src/lib/response-envelope.ts