409 Conflict는 요청이 리소스의 현재 상태와 충돌하여 처리할 수 없음을 나타냅니다. 요청 자체는 형식적으로 유효하지만, 서버의 현재 상태와 양립할 수 없는 변경을 시도할 때 반환됩니다.
대표적으로 두 사용자가 같은 문서를 동시에 수정하다 발생하는 편집 충돌(lost update), 이미 존재하는 값으로 인한 유일성 제약 위반, 버전 불일치가 있습니다.
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