---
schema_version: "1"
id: 92e4fea9c09be89005504918277627dd2e663d44faba6850e305a231a9452f4c
title: JWT
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-rsa-functions-jwt.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-rsa-functions-jwt
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0f6f802c62cd542ed5a75044cf1a5569b95660206b97477956fbca24f436965a
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# JWT

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## JWT(header: Object, payload: Object, signingKey: String, algorithm: String): String

Generate JWT with header, payload, and signature by specific algorithm.

_Introduced in DataWeave version 2.6.0._

### Parameters

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>header</code></p></td><td><p><code>Object</code></p></td><td><p>JWT header.</p></td></tr><tr><td><p><code>payload</code></p></td><td><p><code>Object</code></p></td><td><p>JWT payload.</p></td></tr><tr><td><p><code>signingKey</code></p></td><td><p><code>String</code></p></td><td><p>RSA private key in PEM format.</p></td></tr><tr><td><p><code>algorithm</code></p></td><td><p><code>String</code></p></td><td><p>RSA algorithm, such as <code>Sha384withRSA</code>.</p></td></tr></tbody></table>

### Example

Supply `key` as a JSON string containing an unencrypted RSA private key with a modulus of at least
2048 bits. This example signs with RS384.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::jwt::RSA
output application/json
input key application/json
---
JWT({kid: "example"}, {sub: "test"}, key, "Sha384withRSA")
```

#### Output

The exact signature depends on `key`.

```Json
"<base64url-header>.<base64url-payload>.<base64url-signature>"
```

## JWT(payload: Object, signingKey: String): String

Generate JWT with a payload, automatically generated header, and key signed with RS256.

_Introduced in DataWeave version 2.6.0._

### Parameters

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>payload</code></p></td><td><p><code>Object</code></p></td><td><p>JWT payload.</p></td></tr><tr><td><p><code>signingKey</code></p></td><td><p><code>String</code></p></td><td><p>RSA private key in PEM format.</p></td></tr></tbody></table>

### Example

Supply `key` as a JSON string containing an unencrypted RSA private key with a modulus of at least
2048 bits. This example signs with RS256.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::jwt::RSA
output application/json
input key application/json
---
JWT({sub: "test"}, key)
```

#### Output

The exact signature depends on `key`.

```Json
"<base64url-header>.<base64url-payload>.<base64url-signature>"
```
