Generally the only rule I manage to remember off by heart is the difference between a 4xx and a 5xx.
If the request is and will never be correct in its current form it’s a 4xx, if the user can send that same request without alteration at a later date and expect the server to respond correctly, it’s a 5xx.
Working with developers I encourage them to use more specific error status codes and have found things have improved over the years, everything is no longer a 200
But generally for a simple API most implementations are
200 - all good
404 - couldn’t find it
500 - service down etc.
My preference is for granularity
If a post created data then return a 201.
e.g. create new user
If the server has successfully fulfilled the request and that there is no content to send in the response payload body, then return a 204.
e.g. save document and allow user to continue editing.
HTTP 100: “Hold the vision, trust the process.”
HTTP 200: “This is the beginning of anything you want. If you can dream it, you can achieve it!”
HTTP 300: " As I look back on my life, I realize that every time I thought I was being rejected from something good, I was actually being re-directed to something better."
HTTP 400: “When someone does something wrong, don’t forget all the things they did right.”
HTTP 500: “I’ve always loved the idea of not being what people expect me to be” / Server
definitely agree on this one - much better than everything getting a 200 and then having some kind of message in the response about what actually happened.
It makes it more user friendly, and usable for other APIs to pick up without having to do special handling