Building JWT claims

Which claims should the tokens you issue contain? It depends on who verifies them and what they authorize. Here is a practical guide for issuers — no claim is mandatory for every JWT.

The registered claims

ClaimSet it toWhy
issYour issuer URL, identical on every tokenLets verifiers reject tokens from other issuers
subA stable, unique, non-reassignable IDIdentifies the user or service; avoid emails
audThe API(s) that should accept the tokenPrevents a token for one service being replayed at another
expNow + a short lifetimeLimits the damage of a leaked token
nbfUsually now, or omitDelays validity for scheduled access
iatNowUseful for auditing and max-age checks
jtiA random UUIDEnables replay detection and revocation lists

Claims by token type

API access token (RFC 9068 style)

{ "iss": "https://auth.example.com/", "sub": "user-8127", "aud": "api.example.com",
  "client_id": "web-app", "scope": "read:orders write:orders",
  "iat": 1790602800, "exp": 1790603700, "jti": "7c0f…" }

Service-to-service token

{ "iss": "billing-service", "sub": "billing-service", "aud": "ledger-service",
  "iat": 1790602800, "exp": 1790603100 }

One-time action token (email verification)

{ "sub": "user-8127", "aud": "email-verification", "email": "[email protected]",
  "jti": "a4e3…", "iat": 1790602800, "exp": 1790689200 }

These are examples, not universal security recommendations. Follow the profile your verifier or identity provider documents.

Designing custom claims

Add standard and custom claims with typed values — string, number, boolean, array, object or null — and switch to raw JSON at any time.

Open the claims builder

Validate claims after issuing with negative test tokens.