Tyk v2.2 Documentation Components

  1. Home
  2. Tyk v2.2 Documentation Components
  3. Request Headers: Meta Data

Request Headers: Meta Data

It is possible to inject information that is carried within the user session object into the header space as well. Each token or key has an attached session object which contains a meta_data field, this is a key/value map that allows for dynamic middleware and other components to intelligently act on identity information from the inbound request without exposing it.

To use this data in your header transform simply access the special $tyk_meta namespace, here is a working example.

Say in your session object you have included the following metadata:

"meta_data": {
    "uid": 12345,
    "username": "norman_bates"

To use this in your header transform, your API definition path would be:

"transform_headers": [
        "delete_headers": [],
        "add_headers": {"user-id": "$tyk_meta.uid", "user-name": "$tyk_meta.username"},
        "path": "widgets/{id}",
        "method": "GET"

Meta data in the dashboard

The variable names ($tyk_meta) are also available in the Dashboard fields and will work the same way.