Skip to main content
Feedback

Transform Headers policy

The transformheaders policy overrides incoming request HTTP headers or outbound response HTTP headers. You can override these HTTP headers by:

  • Adding or updating list of headers
  • Removing headers individually
  • Defining an allow list

Timing

On RequestOn ResponseOn Request ContentOn Response Content
XXXX

Example

On request

Add a header from the request payload:

"transform-headers": {
"addHeaders": [
{
"name": "X-Company-Request-Id",
"value": "{#request.id}"
}
],
"removeHeaders": [
"X-Company-TransactionId"
],
"whitelistHeaders": [
"Content-Type",
"Content-Length"
],
"scope": "REQUEST"
}

On response

Add the header for the response phase:

{
"scope": "RESPONSE",
"addHeaders": [
{
"name": "X-Company-Response-Id",
"value": "{#response.id}"
},
{
"name": "test-header",
"value": "test"
}
],
"removeHeaders": [
"Remove-Header"
],
"whitelistHeaders": [
"content-type"
]
}

On request content

Add a header from the request payload:

"transform-headers": {
"addHeaders": [
{
"name": "X-Product-Id",
"value": "{#jsonPath(#request.content, '$.product.id')}"
}
]
"scope": "REQUEST_CONTENT"
}

On response content

Add a header from the response phase for on response content:

{
"scope": "RESPONSE_CONTENT",
"addHeaders": [
{
"name": "X-product-id",
"value": "{#jsonPath(#response.content, '$.product.id')}"
},
{
"name": "test-header",
"value": "test"
}
],
"removeHeaders": [
"Remove-Header"
],
"whitelistHeaders": [
"content-type"
]
}
On this Page