# Custom headers

The Trusted Twin platform allows you to use optional custom HTTP headers in requests to the Trusted Twin API.

# X-TrustedTwin

The X-TrustedTwin header enhances the rule functionality through using variables passed by the User in the request to the Trusted Twin API. These variables are accessed via the DICT rule variable.

# About

The DICT rule variable in the request header follows the standard object description structure. The DICT variable must be encoded to be passed safely within the header.

# Encoding

If you are using the Trusted Twin official Python library, you only need to provide the tt_dict as a dictionary:

In case you need to generate the value, you can use the Python function below:

For other programming languages, use the same technique consisting of the following steps:

  • convert DICT into its JSON representation encoded in UTF-8,
  • encode the string using base64 standard encoding.

# Example

Let's assume you want to pass the following dictionary in the header:

After encoding, the header will look as follows:

# Example usage scenario

To explore example scenario of X-TrustedTwin header usage, please go to Working with custom headers guide.