The request hits your API. The token proves nothing. Without real authentication, the system is exposed.
JWT-based authentication fixes that. In a REST API, JSON Web Tokens carry verified identity and permission data in a compact, signed format. They travel in HTTP headers. They do not require session storage. The server can trust them because each token has a signature generated using a secret or public/private key pair.
A REST API JWT-based authentication flow starts with a login endpoint. The client sends credentials over HTTPS. The server verifies them, then returns a JWT. This token includes claims: user ID, roles, and an expiration time. The server signs the token. From then on, the client sends the token with every request, usually in the Authorization header as Bearer <token>.
On each request, the server validates the signature and the claims. A failed check blocks the request. An expired token triggers a 401 response. Security depends on strong signing keys, short token lifetimes, and secure transport over TLS. Use refresh tokens to keep sessions alive without exposing credentials. Blacklist compromised tokens when needed.