HTTP Headers
Web Development
Programming
Naming Conventions
Custom Headers

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:

http
Request-Id: 123e4567-e89b-12d3-a456-426614174000
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00

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.
text
good: Client-Version
bad: CV

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:

http
Acme-Feature-Flag: beta-on
Acme-Tenant-Id: t_001

This lowers the risk of collisions in large ecosystems.

Header names are case-insensitive

HTTP header field names are case-insensitive:

bash
curl -H 'request-id: abc' https://api.example.com

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:

http
# avoid sending raw PII in headers

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
yaml
header: Acme-Tenant-Id
required: true
format: string

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.


Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design