How to rename or move existing headers in a request

Last updated: 1 minute read.

To rename a header, or to move a value from one header to another (for example, moving an authentication token to a secondary place, or copying a value that gets replaced upstream) is easy with context variables. Here is an example where we move the value of X-Custom-Header to a new header called X-New-Custom-Header in all requests.

We do this by setting the following in our API Definition Version section:

"global_headers": {
    "X-New-Custom-Header": "$tyk_context.headers_X_Custom_Header"
"global_headers_remove": ["X-Custom-Header"],

You can test the header with the following command. This assumes your API Authentication mode is set to open(keyless):

curl -X GET \
  https://DOMAIN/LISTEN_PATH/get \
  -H 'content-type: application/json' \
  -H 'x-custom-header: Foo' \

You can also do this via the Dashboard from the Endpoint Designer tab within the API Designer:

rename header