Course contentsShow
← Web Development
Lesson 1492 of 2,98227. REST API Design for FrontendFree lesson

4xx Client Error Codes: 409, 422, and 429

Learn conflict resolution with 409, validation with 422, and rate limiting with 429.

4xx Client Error Codes: 409, 422, and 429

What you'll learn: How to handle conflict resolution, validation errors, and rate limiting using specific HTTP status codes in your REST APIs.

The Three Specialized Error Codes

While 400, 401, 403, and 404 handle common client mistakes, REST APIs need more precise status codes for specific scenarios. Three critical ones are 409 Conflict, 422 Unprocessable Entity, and 429 Too Many Requests.

409 Conflict: When Resources Collide

Status Code: 409 Conflict

This code signals that the request cannot be completed because it conflicts with the current state of the resource. Think of it like trying to book a hotel room that someone else just reserved seconds before you—the resource exists, but your request creates a conflict.

Common use cases:

  • Attempting to create a resource that already exists
  • Version conflicts during concurrent updates
  • Business rule violations (e.g., deleting a user who still has active orders)

422 Unprocessable Entity: Validation Failures

Status Code: 422 Unprocessable Entity

While 400 Bad Request handles malformed syntax, 422 is more specific: the request is well-formed but semantically incorrect. It's like filling out a form correctly but entering an invalid email format or a birthdate in the future.

Common use cases:

  • Field validation errors (email format, password strength)
  • Business logic validation (age requirements, duplicate usernames)
  • Data integrity constraints

429 Too Many Requests: Rate Limiting

Status Code: 429 Too Many Requests

This code tells clients they've exceeded the API's rate limit. It's like a bouncer saying "slow down" when someone's making too many requests too quickly. Often paired with Retry-After headers to tell clients when they can try again.

Common use cases:

  • Protecting servers from abuse
  • Fair resource allocation across clients
  • API tier enforcement

Key Takeaway: Use 409 for resource conflicts, 422 for validation failures beyond syntax errors, and 429 to enforce rate limits—each provides clear, actionable feedback to API consumers.