Send Custom Headers

Send an HTTP request with custom headers and inspect them in the response.

Code

Utilities
const response = await fetch('https://httpbin.org/headers', {
  headers: {
    'X-Custom-Header': 'my-value',
    'X-Request-Id': '12345',
    'Accept-Language': 'en-US'
  }
});
await response.json();
Browser·fetch() may be limited by CORS

Common Headers

HeaderPurpose
AuthorizationAuth tokens
X-API-KeyAPI authentication
X-Request-IdRequest tracing
Accept-LanguagePreferred language
Cache-ControlCaching directives

More JavaScript Snippets