# JWT in FastAPI

say it: **“JOT in FAST-AY-PEE-EYE”** **/dʒɒt ɪn ˈfæstˌeɪˌpiˌaɪ/**

A signed token carrying user info, created and checked with a library like PyJWT.

## What is **JWT in FastAPI**?

A **JWT** is a signed token that carries the user's ID and expiry. FastAPI apps usually create and check JWTs with a library such as PyJWT.

```python
token = jwt.encode({'sub': str(user.id), 'exp': expires}, SECRET_KEY, algorithm='HS256')
payload = jwt.decode(token, SECRET_KEY, algorithms=['HS256'])
```

Level: Freelancer · [More FastAPI terms at this level](https://www.ask-codey.com/glossary?category=fastapi&level=4)

Updated: November 17, 2026

Source: https://www.ask-codey.com/glossary/jwt-in-fastapi
