Skip to main content

Logging and Request IDs

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

The ZGRID API attaches a request ID to inbound traffic and carries it through logs and JSON responses so product support and engineering can follow one request across the stack.

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