This function allows users to create JSON web tokens (JWTs). It uses a key to create a hash of the JWT payload. The hash is included in the JWT content to allow validation. The JWT payload isn’t encrypted.

The difference between GetJWT() and its companion function GetJWTByKeyName() is the first parameter. The GetJWT() first parameter is a key string that the caller supplies directly through their preferred method. For example, the key string is encrypted and stored in a data extension.

1stringRequiredA key string.
2stringRequiredName of a JWT standard hash algorithm from among HS256, HS384, or HS512.
3stringRequiredThe payload, typically a JSON object with name-value pairs. The payload isn't encrypted.

The function returns a JWT string. If syntax for the function is invalid, the parser throws an InvalidFunctionException. If the function call is invalid, for example, as having an invalid parameter value, the parser throws a FunctionExecutionException, including details in an inner exception.

Code Example

Output Example

The output is a JWT that looks like this example.