409 vs 412
Conflict vs Precondition Failed
409Conflict
Clash of the titans! What you're trying to do doesn't match up with what's already there. Like double-booking a meeting room.
HTTP/1.1 409 Conflict
Content-Type: application/json
{"error": "Resource already exists"}412Precondition Failed
Your conditions weren't met! You said 'only if...' and the server said 'nope, that's not the case.'
HTTP/1.1 412 Precondition Failed
ETag: "new-etag-value"⚔️409Conflict
❌412Precondition Failed
Description
The request conflicts with the current state of the server.
Common Causes
- Editing outdated version of resource
- Username already taken
- Conflicting concurrent updates
Description
The client has indicated preconditions in its headers which the server does not meet.
Common Causes
- If-Match header doesn't match ETag
- If-Unmodified-Since condition failed
- Conditional request preconditions not satisfied