What does HTTP status code 101 mean?
The 101 Switching Protocols status code indicates that the server is agreeing to switch protocols as requested by the client via the Upgrade header.
When to use it in APIs
This is the standard response returned during a WebSocket handshake. A client makes an HTTP request with Upgrade: websocket and the server responds with 101 to transition the TCP connection into a bi-directional WebSocket stream.
How it compares to other codes
- 100 Continue: Handles body transfer coordination, whereas 101 handles connection protocol upgrades.