---
title: "JWT Sign"
description: "Sign a JSON web token with a secret or PEM private key."
canonical_url: "https://docs.vettero.com/build/workflows/blocks/crypto/jwt-sign"
---
# JWT Sign

> Sign a JSON web token with a secret or PEM private key.

<block-meta block="Yes" channels="Any" folder="crypto" group="Crypto" groupTo="/build/workflows/blocks/crypto" icon="i-lucide-file-key" pipe="Value" scope="Any" tool="Yes" type="crypto.jwt.sign">



</block-meta>

**JWT Sign** builds a compact JSON web token from **Payload** and a signing key. Put **custom claims** in **Payload**. Use **Expires in**, **Audience**, **Issuer**, and the other sign options so registered claims (`exp`, `aud`, `iss`, …) are set correctly — do not put `expiresIn` inside the payload object.

## Configure

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Payload
      </strong>
    </td>
    
    <td>
      Object (or JSON text) of claims (required)
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Key type
      </strong>
    </td>
    
    <td>
      <strong>
        Passphrase (HMAC)
      </strong>
      
       or <strong>
        PEM key
      </strong>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Secret
      </strong>
    </td>
    
    <td>
      HMAC secret when key type is passphrase
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Private key
      </strong>
    </td>
    
    <td>
      PEM private key when key type is PEM
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Algorithm
      </strong>
    </td>
    
    <td>
      <strong>
        HS256
      </strong>
      
       (default) through HS/RS/ES/PS 256, 384, and 512. Algorithm none is not available
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Expires in
      </strong>
    </td>
    
    <td>
      Lifetime such as <code>
        3600
      </code>
      
       (seconds) or <code>
        1h
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Not before
      </strong>
    </td>
    
    <td>
      Delay before the token is valid
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Audience
      </strong>
    </td>
    
    <td>
      <code>
        aud
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Issuer
      </strong>
    </td>
    
    <td>
      <code>
        iss
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Subject
      </strong>
    </td>
    
    <td>
      <code>
        sub
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        JWT ID
      </strong>
    </td>
    
    <td>
      <code>
        jti
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Key ID
      </strong>
    </td>
    
    <td>
      Header <code>
        kid
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Header
      </strong>
    </td>
    
    <td>
      Optional extra header claims (object or JSON)
    </td>
  </tr>
</tbody>
</table>

Passphrase keys work with HS algorithms. PEM keys work with RS, ES, and PS algorithms.

## Handles

<table>
<thead>
  <tr>
    <th>
      Handle
    </th>
    
    <th>
      Role
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        In
      </strong>
      
       (target)
    </td>
    
    <td>
      Incoming connection
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Out
      </strong>
      
       (source)
    </td>
    
    <td>
      Continues after signing
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Error
      </strong>
    </td>
    
    <td>
      Catchable failures: missing secret or private key (<code>
        MISSING_VALUE
      </code>
      
      ), or invalid payload, header, algorithm, or key (<code>
        JWT_INVALID
      </code>
      
      )
    </td>
  </tr>
</tbody>
</table>

Connect [Branch errors](https://docs.vettero.com/build/workflows/blocks/error/branch) to **Error** to split those codes.

## Pipe schema

The next block reads this on the data pipe (`pipe.value`). The value is `text` (the compact token).

## Use case

- Mint a bearer token, then send it on an [API](https://docs.vettero.com/build/workflows/blocks/utility/api) request.
- Issue a short-lived token for a partner callback.

<block-page-nav>



</block-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
