Course contentsShow
← Software Engineering
Lesson 757 of 1,93324. REST API DesignFree lesson

Statelessness in REST

Each request must contain all information needed; the server stores no client context between requests.

Statelessness in REST

You'll learn why every REST API request must stand alone, with no session memory on the server.

What Does Stateless Mean?

In REST, statelessness means the server doesn't remember anything about previous requests from a client. Each request must carry all the information needed to understand and process it—authentication credentials, context, parameters, everything. The server treats every request as if it's the first time it's ever heard from that client.

Think of it like ordering at a busy coffee shop where the barista has no memory. Every time you approach the counter, you must say: "I'm Jane, I'm a rewards member (here's my card), and I'd like a medium latte." You can't just say "another one, please" because the barista has already forgotten you exist.

Why Statelessness Matters

Without server-side session storage, REST APIs gain powerful advantages:

  • Scalability: Any server in a cluster can handle any request—no need to route clients to "their" server
  • Reliability: If a server crashes, clients just retry with another server; nothing is lost
  • Simplicity: No session cleanup, no synchronization between servers, no stale state bugs
  • Transparency: Everything needed to understand a request is visible in that request

The Trade-Off

The client must send more data with each request (like authentication tokens), and the client bears responsibility for maintaining application state between interactions. But this cost is worth the architectural benefits.

Key Takeaway: Statelessness means each REST request is self-contained with all necessary information; the server stores no client context between requests, enabling simple, scalable, and reliable API architectures.