---
schema_version: "1"
id: bead70b3f4bbd5d47c1c3004011f8f4da846210c7affbd5e44a27dafce3e2361
title: Header Injection Policy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-gateway/policies-included-header-injection.md
canonical_url: https://docs.mulesoft.com/mule-gateway/policies-included-header-injection
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e64687662462d4cbffa28ff0f2c60eb0b1ddd3bf8a06df1ca3f5b994969ddaf6
description: MuleSoft Documentation Site
latest: true
---
---
product: Mule Gateway
keywords: header injection, api gateway, mule gateway, gateway, policy
---

# Header Injection 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 Injection</p></td></tr><tr><td><p><strong>Summary</strong></p></td><td><p>Adds headers to 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 Mule version available</strong></p></td><td><p>v4.1.0</p></td></tr><tr><td rowspan="3"><p><strong>Returned Status Codes</strong></p></td><td></td></tr><tr><td><p>500 - The configuration includes an expression that was not evaluated.</p></td></tr></tbody></table>

## Summary

The Header Injection policy adds HTTP headers to the request or response of a message. When you
configure this policy for your API, you must specify an inbound and outbound map of the headers that
you want to add in the message processing in the form of 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/mule-gateway/_images/header-inject-remove-diagram.png)

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

`“#[attributes.requestPath]”`

If the injected header already exists in the message attributes, the policy creates a new header
without overriding the value of the existing one.

> [!NOTE] Only certain headers are restricted to support multiple values, and they will be
> overwritten using configured values. These headers are: `access-control-allow-origin`,
> `content-type`, `content-length`, `transfer-encoding`.
>
> To overwrite any other existing message header, remove it before adding your header. See the
> [Header Removal](https://docs.mulesoft.com/mule-gateway/policies-included-header-removal) policy.

## Configuring Policy Parameters

### Mule Gateway

When you apply the policy to your API 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 headers to be injected at the beginning of the message processing.</p></div></div></td></tr><tr><td><div><div><p>Inbound Header Key</p></div></div></td><td><div><div><p>String or Dataweave expression to be used as header name at the beginning of the message.</p></div></div></td></tr><tr><td><div><div><p>Inbound Header Value</p></div></div></td><td><div><div><p>String or Dataweave expression to be used as header value at the beginning of the message.</p></div></div></td></tr><tr><td><div><div><p>Outbound Header Map</p></div></div></td><td><div><div><p>List of headers to be injected at the end of the message processing.</p></div></div></td></tr><tr><td><div><div><p>Outbound Header Key</p></div></div></td><td><div><div><p>String or Dataweave expression to be used as header name at the end of the message processing.</p></div></div></td></tr><tr><td><div><div><p>Outbound Header Value</p></div></div></td><td><div><div><p>String or Dataweave expression to be used as header value at the end of the message processing.</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>

> [!NOTE] Header keys should be compliance with
> [HTTP 1.1](https://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2) standard.

To use single quotes directly in a String value (for example
`"default-src 'none'; frame-ancestors 'none';"`), use a DataWeave expression:

#\["default-src 'none'; frame-ancestors 'none';"\]
