---
title: "sign · RUAL Documentation"
description: "Creates and signs a new json web token."
canonical: https://docs.rual.nl/block-types/json%20web%20token/function_jwt_sign
language: en
---

[Cluster](https://docs.rual.nl/cluster)

[Blocks](https://docs.rual.nl/block-types)

[Interfaces](https://docs.rual.nl/interfaces)

[Blueprints](https://docs.rual.nl/blueprints)

[Tutorials](https://docs.rual.nl/tutorials)

[Home automation](https://docs.rual.nl/home-automation)

[Examples](https://docs.rual.nl/examples)

[Reference](https://docs.rual.nl/reference)

[Architecture](https://docs.rual.nl/architecture)

[Troubleshooting](https://docs.rual.nl/troubleshooting)

Other

# sign

This block is part of the [`json web token`](https://docs.rual.nl/block-types/json%20web%20token) group and was last modified in core [`v10.4.28`](https://docs.rual.nl/core-versions/100428).

Creates and signs a new json web token.

- flow `flow`

- payload required `object` the payload to add to the jwt

- secret required `value` the secret or private key to sign the jwt with

- expires required `date` when the jwt should expire

Default `4 hours`

- flow `flow`

- success `condition`

- error `value`

- token `value`

HS256-signs the payload with the secret and outputs the token. The payload must be an object without its own exp key : string, number, or boolean payloads fail with typed INVALID_EXPIRES_IN_FOR_* errors, an existing exp with INVALID_EXPIRES_IN. The token gets iat (now, unless the payload supplies a numeric one; a non-numeric iat fails with INVALID_IAT) and exp set to iat PLUS the expires value, which defaults to now-plus-4-hours as a unix number; an expires value at or before now fails with INVALID_EXPIRY_IN_PAST.

| `jwt` |
| --- |

A typical wiring for [sign](https://docs.rual.nl/block-types/json%2520web%2520token/function_jwt_sign): a [function trigger](https://docs.rual.nl/block-types/globals/trigger_custom_function) starts the flow; [new object](https://docs.rual.nl/block-types/object/object_new_fields) feeds the `payload` pin; [value](https://docs.rual.nl/block-types/value/value_default) feeds the `secret` pin; [date now](https://docs.rual.nl/block-types/date/date_currentdate) feeds the `expiresin` pin; the `flow` out pin feeds [debug](https://docs.rual.nl/block-types/state%2520ui/state_debug).

[![Studio canvas example for the sign block: typical wiring for sign.](https://docs.rual.nl/canvas-examples/function_jwt_sign.png)](https://docs.rual.nl/canvas-examples/function_jwt_sign.png?v=3)

## Version history

Introduced in [`v10.4.28`](https://docs.rual.nl/core-versions/100428).

- [Back to `json web token`](https://docs.rual.nl/block-types/json%20web%20token): Return to the main group to view all sub-groups

- [Back to `json web token`](https://docs.rual.nl/block-types/json%20web%20token?group=json%20web%20token): Return to the group to view all blocks within this group

Was this page helpful? [Tell us what to improve](https://docs.rual.nl/support) · RUAL Docs is an integral component of the [RUAL ecosystem](https://rual.nl)
