Introduction
We use different status codes to tell the user or client what happened with their request. It helps them understand if it worked, failed, or needs more action.
When you want to confirm a successful request with a 200 OK status.
When a requested resource is not found and you want to send a 404 Not Found.
When a client sends bad data and you want to respond with 400 Bad Request.
When a new resource is created and you want to send 201 Created.
When the user is not authorized and you want to send 401 Unauthorized.