HTTP Status Codes
HTTP status codes for APIs: choosing the code that tells a client what happened and what to do next.
Every response an API sends starts with a three-digit number, and most of the software that handles the response reads nothing else. Retry libraries, caches, monitoring dashboards and the client's own error handling all branch on that number before anyone looks at the body. A wrong code is not a cosmetic slip; it sends every one of them down the wrong branch.
The topic opens on the five classes, which say whose problem a response is. Then it takes the classes an API sends one at a time, success, client errors, server errors and redirects, and gives each code a scenario and the client's next step. One comparison separates 401 from 403, and a gotcha shows what happens when an error travels inside a 200.
The method that produced the request is the previous topic's subject. The body of an error response, the part a person reads, has its own topic later in this subject.
By the end you can name the class of any code and who is at fault, choose the code for a scenario, tell 401 from 403 and a gateway's 5xx from an application's, and pick the redirect that keeps the method.
Contents
9 cardsnot started