---
schema_version: "1"
id: b887e3c83a4bae305237033c7ed7c1ec64089d341e5d6b554fc844fcc0450c27
title: Header Removal Policy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/gateway/1.12/policies-included-header-removal.md
canonical_url: https://docs.mulesoft.com/gateway/1.12/policies-included-header-removal
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e5d4117af05389b34b40e395b0cf86becfb9ab7a3e969b2b816a7b879689bd03
description: MuleSoft Documentation Site
release: "1.12"
latest: false
---
---
product: Omni Gateway
version: 1.12
keywords: header removal, api gateway, flex gateway, gateway, policy
---

# Header Removal Policy

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

<table><colgroup><col> <col></colgroup><tbody><tr><td><p><strong>Policy name</strong></p></td><td><p>Header Removal</p></td></tr><tr><td><p><strong>Summary</strong></p></td><td><p>Removes headers from a request or a response</p></td></tr><tr><td><p><strong>Category</strong></p></td><td><p>Transformation</p></td></tr><tr><td><p><strong>First Flex Gateway version available</strong></p></td><td><p>v1.0.0</p></td></tr><tr><td><p><strong>Returned Status Codes</strong></p></td><td><p>500 - The configuration includes an expression that was not evaluated.</p></td></tr></tbody></table>

## Summary

The Header Removal policy removes all listed headers from a request or a response of a message when
you specify an inbound and outbound map of the headers that you want to remove with a key-value
pair.

![A flow chart illustrating the process of setting header injection and removal policies for clients accessing an API through a proxy](/mulesoft/current/en-us/gateway/1.12/_images/header-inject-remove-diagram.png)

You can optionally include DataWeave expressions in the value of the header. For example, all
headers matching the following configured expression are injected to the message:

`“#[attributes.requestPath]”`

> [!NOTE] The following headers may not be removed: accept, host, content-type, content-length,
> date, transfer-encoding, connection,

## Configuring Policy Parameters

### Flex Gateway Local Mode

When you apply the policy via declarative configuration files, Refer to the following policy
definition and table of parameters:

\- policyRef: name: header-removal-flex config: inboundHeaders: <array> // OPTIONAL, default: \[\]
outboundHeaders: <array> // OPTIONAL, default: \[\]

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Required or Optional</th><th>Default Value</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>inboundHeaders</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Empty array</p></div></div></td><td><div><div><p>Map of header names or regular expressions to be removed at the beginning of the message processing, for example, <code>Cache-Control, Access-Control.*</code></p></div></div></td></tr><tr><td><div><div><p><code>outboundHeaders</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Empty array</p></div></div></td><td><div><div><p>Map of header names or regular expressions to be removed at the end of the message processing, for example, <code>Access-Control-Allow-Credentials</code></p></div><div><div data-type="NOTE"><div><p><code>inboundHeaders</code> and <code>outboundHeaders</code> can not both be empty.</p></div></div></div></div></td></tr></tbody></table>

#### Resource Configuration Example

\- policyRef: name: header-removal-flex config: inboundHeaders: - "Cache-Control" -
"Access-Control.\*" outboundHeaders: - "Access-Control-Allow-Credentials"

### Managed Flex Gateway and Flex Gateway Connected Mode

When you apply the policy from the UI, the following parameters are displayed:

<table><colgroup><col> <col></colgroup><thead><tr><th><strong>Parameter</strong></th><th><strong>Description</strong></th></tr></thead><tbody><tr><td><div><div><p>Inbound Header Map</p></div></div></td><td><div><div><p>List of header names or regular expressions (comma separated) to be removed at the beginning of the message processing, for example, <code>Cache-Control, Access-Control.*</code></p></div></div></td></tr><tr><td><div><div><p>Outbound Header Map</p></div></div></td><td><div><div><p>List of header names or regular expressions (comma separated) to be removed at the end of the message processing, for example, <code>Access-Control-Allow-Credentials</code></p></div></div></td></tr><tr><td><div><div><p>Method &amp; Resource conditions</p></div></div></td><td><div><div><p>The option to add configurations to only a select few or all methods and resources of the API</p></div></div></td></tr></tbody></table>

## How This Policy Works

Because every header that matches a Header Removal policy parameter is removed from the message, you
must be careful about how you configure that parameter.

For example, the following parameter configuration removes any header starting with the word
`Access-Control`, such as the `Access-Control-Allow-Credentials` and `Access-Control-Allow-Origin`
headers from a message. The configuration also removes the `Cache-Control` header:

![Removed headers at the start of message processing](/mulesoft/current/en-us/gateway/1.12/_images/remove-inbound-header.png)

Figure 1. Inbound Header
