Skip to main content

Modify Request and Response Headers

Change the headers of requests before they reach your service, and of responses before they reach the caller.

How it works​

The gateway adds, replaces or removes headers on the request before it reaches the service, or on the response before it reaches the client. Typical uses: pass a tenant or a correlation ID to the service, remove internal headers from responses, strip identity headers a caller must not be able to forge.

Add versus set

set replaces any value sent by the caller; add appends to it. For a header the service trusts, use set.

Every parameter and its default: reference.

Use cases​

To pass a fixed value to a service, to hide a header that reveals too much, or to add a security header to every response.

Prerequisites​

Procedure​

  1. In API Manager, open the API instance.
  2. Add the setting HTTP request headers, HTTP response headers, or both.
  3. Fill Add Headers, Set Headers and Remove Headers.
  4. Deploy.

Parameters​

FieldWhat it isDefault
Add HeadersHeaders added, even when one of the same name is already there.—
Set HeadersHeaders set: an existing value is replaced.—
Remove HeadersNames of the headers removed.—

Verification​

See the headers of a response
curl -sI https://orders.example.com/orders

Behavior and limits​

  • Add keeps an existing header and adds another; Set replaces it. Use Set when the value must be the only one.

See also​