Matching Verbs to Status Codes
What you'll learn: How to pair HTTP methods with the correct status codes to create predictable, well-designed REST APIs.
Understanding the Relationship
Each HTTP verb implies a specific operation, and your API should respond with status codes that accurately reflect what happened. Think of it like a conversation: the client asks something (verb), and the server replies with a specific response (status code) that makes sense for that type of request.
Common Verb-Status Pairings
GET requests typically return:
200 OKwhen the resource exists404 Not Foundwhen it doesn't304 Not Modifiedfor cached responses
POST requests (creating resources) should return:
201 Createdon successful creation400 Bad Requestfor invalid data409 Conflictif the resource already exists
PUT requests (full updates) commonly return:
200 OKwhen updating and returning the resource204 No Contentwhen updating without a response body404 Not Foundif the resource doesn't exist
PATCH requests (partial updates) use:
200 OKwith the updated resource422 Unprocessable Entityfor validation errors
DELETE requests typically return:
204 No Contenton successful deletion404 Not Foundif already deleted or never existed
Why This Matters
Consistent verb-status pairings make your API intuitive. Developers using your API shouldn't receive 200 OK after a POST that failed, or 201 Created from a GET request. Each pairing tells a clear story about what happened, enabling proper error handling and creating a professional developer experience.
Key Takeaway: Match HTTP verbs with semantically appropriate status codes—successful creation returns 201, successful deletion returns 204, missing resources return 404—to build APIs that communicate clearly and behave predictably.