URL Rewriter: Context Variables

Context Data

As of version 2.2 Tyk allows context variables to be injected into the regex using the $tyk_context. namespace instead of the numeric index.

The context variables that are available are:

request_data: If the inbound request contained any query data or form data, it will be available in this object, for the URL Rewrite, Tyk will format this data as key:value1,value2,valueN;key:value1,value2 etc.

path_parts: The components of the path, split on /, these values are made available in the format of a comma delimited list.

token: The inbound raw token (if bearer tokens are being used) of this user.

path: The path that is being requested.

remote_addr: The IP address of the connecting client.

$jwt_claims_CLAIMNAME – If JWT tokens are being used (not OIDC Middleware), then each claim in the JWT is available in this format to the context processor.

Note: You must have context variables enabled in your API Definition for this to work.

Meta Data

As of v2.3 it is possible to inject meta data from a Tyk Session Object linked to a token into your URL Rewrite commands. In a similar way to the context variables, the values are in a reserved namespace: $tyk_meta.FIELDNAME. This can be especially useful if you wish to incorporate custom query string parameters into a URL structure.

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.