JWT_SIGN
Creates a JSON Web Token from the provided payload, secret/key, and algorithm. Default algorithm is RS256 if not specified. Supports HMAC (HS256/HS384/HS512), RSA (RS256/RS384/RS512), and ECDSA (ES256/ES384/ES512) algorithms. Can include standard JWT claims like exp, nbf, iss, aud, jti, iat, sub and custom header fields like kid, typ. Supports both PEM format keys and JWK (JSON Web Key) format for RSA and ECDSA keys.
Categories: Hashing/Signing
Syntax
JWT_SIGN(claim_set, key, [algorithm], [headers])
Examples
Example 1
Formula
JWT_SIGN({"iss":"Test Company","iat":1676003525,"exp":1707539525,"aud":"www.example.com","sub":"jsmith@example.com"}, CREDENTIAL.jwt_hmac_key, "HS256", {"typ":"JWT"})
Example 2
Input
{}
Formula
JWT_SIGN({"user_id": 123}, "secret", "HS256")
Output
"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxMjN9.FoW4dUPr9HWzOI8S7Ohpe3hGULZEJhNJeouOX8f1sz8"
Example 3: Claims such as exp go in the claim set
Formula
JWT_SIGN({"user_id": 123, "exp": 1767225600}, "secret", "HS256")
Output
"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxMjMsImV4cCI6MTc2NzIyNTYwMH0.sNnl8baHjDvmEbDqThei1d8nQZizYo3S1ckZAyZp-yk"
Example 4: Header fields are passed as an object in the fourth argument
Formula
JWT_SIGN({"sub": "user123"}, "secret", "HS256", {"kid": "key-123"})
Output
"eyJraWQiOiJrZXktMTIzIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIiOiJ1c2VyMTIzIn0.kCoZfzkcqyOpbR6Ma3SfrkbBejKkeyTPTJP9U-OULk0"
Sample actions
Select an action to inspect
You can also click "Copy actions" and paste them in your Tines story to see how they work.