# jwtencode: Create JWT – Encode and Sign a JSON Web Token

> jwtencode (Create JWT – Encode and Sign a JSON Web Token) is a 1001fx API function in the group Data & JSON: POST https://api.1001fx.com/data/jwtencode, 1 credit per call. It works as a ready-made module in Make or as a plain HTTP call.

Creates a signed JSON Web Token from a JSON payload, with HS256/384/512 (shared secret) or RS256/384/512 (PEM private key). iat is set; exp, iss, sub and aud optionally.

- Group: Data & JSON
- Endpoint: `POST https://api.1001fx.com/data/jwtencode`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 1 credit per call
- Ready-made in: Make
- Docs: https://1001fx.com/functions/jwtencode

## Parameters

- `payload` (object, required) – Payload: Claims as JSON object.
- `secret` (string, required) – Secret or private key: Shared secret for HS*, PEM private key for RS*.
- `algorithm` (enum, optional, one of `HS256`, `HS384`, `HS512`, `RS256`, `RS384`, `RS512`, default `HS256`) – Algorithm: Default HS256.
- `expiresIn` (number, optional) – Expires in (seconds): Sets exp = now + seconds.
- `issuer` (string, optional) – Issuer (iss)
- `subject` (string, optional) – Subject (sub)
- `audience` (string, optional) – Audience (aud)

## Example: Create JWT – Encode and Sign a JSON Web Token

```bash
curl -X POST 'https://api.1001fx.com/data/jwtencode' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"payload":{"userId":42,"role":"editor"},"secret":"my-shared-secret","algorithm":"HS256","expiresIn":3600,"issuer":"my-app"}'
```
