Skip to main content

HTTP Status Codes - Essential Guide for API Testing

A comprehensive reference for HTTP status codes that every developer and tester should know

🎯 Quick Resources

🎯 Quick Resources

Overview

HTTP status codes are three-digit numbers returned by web servers to indicate the outcome of HTTP requests. Whether you're developing APIs, testing web applications, or just browsing the web, understanding these codes is crucial for effective debugging and development.

Interview Tip

HTTP status codes are frequently asked about in technical interviews. Understanding their meanings and categories will help you stand out!

Categories Overview

HTTP status codes are organized into five main categories, each serving a specific purpose:

Memory Aid (Mnemonic)

"I Should Remember Client & Server"1-2-3-4-5

  • 1xx: Informational responses
  • 2xx: Successful operations
  • 3xx: Redirection messages
  • 4xx: Client error responses
  • 5xx: Server error responses

1xx - Informational Responses

"Processing your request..."

These codes indicate that the request was received and the process is continuing.

CodeNameDescriptionWhen You'll See It
100ContinueServer received initial part of requestLarge file uploads
101Switching ProtocolsServer switching to different protocolWebSocket upgrades
102ProcessingServer processing (WebDAV)Long-running operations

2xx - Success Codes

"Everything went perfectly!"

These codes confirm that the request was successfully received, understood, and accepted.

CodeNameDescriptionCommon Use Cases
200OKStandard success responseGET requests, general success
201CreatedResource successfully createdPOST requests creating new data
202AcceptedRequest accepted for processingAsync operations, queued tasks
204No ContentSuccess but no content to returnDELETE operations, PUT updates
206Partial ContentPartial resource deliveredVideo streaming, large file downloads

3xx - Redirection Codes

"Look somewhere else..."

These codes indicate that further action needs to be taken to complete the request.

CodeNameDescriptionTesting Impact
301Moved PermanentlyResource permanently movedUpdate bookmarks/links
302Found (Temporary Redirect)Resource temporarily at different URITemporary relocation
304Not ModifiedResource hasn't changedCaching validation
307Temporary RedirectTemporary redirect, keep methodForm resubmissions
308Permanent RedirectPermanent redirect, keep methodAPI versioning

4xx - Client Error Codes

"You made a mistake..."

These codes indicate that the client seems to have made an error.

CodeNameDescriptionWhat It Means for Testing
400Bad RequestMalformed request syntaxCheck request format, parameters
401UnauthorizedAuthentication requiredMissing or invalid credentials
403ForbiddenServer understood but refusesPermission/authorization issues
404Not FoundResource doesn't existWrong URL or deleted resource
405Method Not AllowedHTTP method not supportedWrong HTTP verb (GET vs POST)
409ConflictRequest conflicts with current stateDuplicate entries, version conflicts
422Unprocessable EntityValidation errorsInvalid data format/values
429Too Many RequestsRate limiting triggeredAPI throttling, need to slow down

5xx - Server Error Codes

"We messed up..."

These codes indicate that the server failed to fulfill a valid request.

CodeNameDescriptionTesting Implications
500Internal Server ErrorGeneric server errorServer-side bug, check logs
501Not ImplementedServer doesn't support functionalityFeature not available
502Bad GatewayInvalid response from upstreamProxy/gateway issues
503Service UnavailableServer temporarily unavailableMaintenance, overload
504Gateway TimeoutUpstream server timeoutNetwork/performance issues

Quick Reference for API Testing

Most Common in Testing:

  • 200: Successful GET requests
  • 201: Successful POST (creation)
  • 400: Bad request format
  • 401: Authentication failures
  • 404: Resource not found
  • 500: Server errors

Status Codes to Watch For:

# Success range
200-299: ✅ Everything is working

# Redirection range
300-399: ↪️ Resource moved/cached

# Client errors
400-499: ❌ Fix your request

# Server errors
500-599: 🔧 Server needs fixing

Testing Best Practices

  1. Always validate status codes in your API tests
  2. Test error scenarios - don't just test happy paths
  3. Understand the difference between 401 (authentication) and 403 (authorization)
  4. Use appropriate assertions based on expected status codes
  5. Monitor 5xx errors in production - they indicate server issues

Connect With Me

Follow and connect for more API testing insights:

Additional Resources


Contribute

Found this helpful? Have suggestions for improvement? Feel free to share your feedback!

#SharingIsCaring #APITesting #HTTPStatusCodes