409 Conflict means the request conflicts with the current state of the resource and cannot be processed. The request itself is well-formed, but it attempts a change incompatible with the server's present state.
Typical cases are an edit conflict (lost update) when two users modify the same document at once, a uniqueness constraint violated by an existing value, or a version mismatch.
PUT /api/docs/7 HTTP/1.1
Host: api.example.com
If-Match: "v3"
Content-Type: application/json
{"title":"Edited"}HTTP/1.1 409 Conflict
Content-Type: application/json
{"error":"conflict","message":"Document was modified by another user","currentVersion":"v5"}app.put('/api/docs/:id', (req, res) => {
const doc = db.get(req.params.id);
if (req.headers['if-match'] !== doc.etag)
return res.status(409).json({ error: 'conflict', currentVersion: doc.etag });
// ...
});@app.post('/api/users')
def create():
if db.exists(email=request.json['email']):
abort(409, 'email already registered')
return {}, 201