Custom HTTP header naming conventions (and why to drop the X- prefix)
Codemia Knowledge Hub ·
Name new custom HTTP headers without the X- prefix. Use clear, stable, hyphen-separated names such as Request-Id, reuse a standard header when one already fits, add an organization or product prefix when you need a namespace, and document what each header means. The old X- convention (X-Request-ID) fell out of favour in RFC guidance because "experimental" headers kept becoming permanent.
Good header names help interoperability across proxies, gateways, clients and observability tools.
Avoid X- for new headers
The modern style:
Before inventing a header, check whether a standard one (Authorization, Content-Type, Traceparent) already does the job. Using deprecated X- names in new long-term API designs is a common mistake.
Naming style
- Use descriptive nouns (
Request-Id,Client-Version). - Keep names short and stable.
- Separate tokens with hyphens.
- Avoid ambiguous abbreviations.
Prefixing organization-specific headers
Names that are too generic can collide with other systems. If you need a namespace, use an organization or product prefix:
This lowers the risk of collisions in large ecosystems.
Header names are case-insensitive
HTTP header field names are case-insensitive:
Still, keep one canonical casing in your documentation for readability.
Keep secrets and personal data out of headers
Do not put secrets in custom headers unless it is required and encrypted transport is guaranteed:
Gateways and intermediaries often log headers.
Document each header as a contract
For every custom header, define:
- purpose
- allowed values or format
- required or optional
- propagation rules across services
A written contract, including the header's lifecycle, prevents teams from drifting into inconsistent usage. New contributors can then learn the rules without reverse-engineering them from scattered call sites.
Testing and operating custom headers
Test the contract at service boundaries, not only in happy-path unit tests. Cover the accepted input forms, normalization rules and edge cases such as missing values and malformed input, and use representative fixtures from production logs so tests reflect real traffic. This catches compatibility problems early when dependencies, framework versions or infrastructure defaults change.
When several services share the same headers, centralize the helper logic and validate compatibility in CI before rollout. Emit structured diagnostics with stable field names around the code that reads headers, keep sensitive values redacted, and turn each incident's root cause into a regression test. Treat headers as observable infrastructure data with security implications.
Related reading
- Data validation across different microservices
- DCCP support for mio in Rust
- Dealing with CORS using the Contour Kubernetes Ingress
- Dealing with high number of real-time calls to partner API in Rails
- Debugging DNS resolutions in kubernetes
- denied the request rejecting admission review because the request does not contains an Ingress resource but networking.k8s.io/v1
- Deprecated k8s API
- Design of asynchronous socket classes in C
System design interview problems on this topic
- Design a Load Balancer: solution and walkthrough
- Design a Domain Name System: solution and walkthrough
- Design a Global Content Distribution Network: solution and walkthrough
- Design an API Rate Limiter: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.