Should duplicate email signup return 400, 409, or 422?
409 Conflict is the most semantically accurate status for uniqueness conflicts against existing server state (unless security policy requires hiding account existence).
HTTP 409 Conflict indicates the request could not be completed because of a conflict with the current state of the target resource—such as duplicate unique keys, stale optimistic-lock versions, or concurrent edits.
HTTP/1.1 409 Conflict
Content-Type: application/problem+json
{
"type": "https://api.example.com/errors/duplicate-resource",
"title": "Resource Conflict",
"status": 409,
"detail": "An account with this email already exists.",
"instance": "/v1/users"
}
curl -i -sS -X PUT -H 'If-Match: "v3"' -H 'Content-Type: application/json' -d '{"name":"test"}' https://api.example.com/v1/items/42
409 Conflict is the most semantically accurate status for uniqueness conflicts against existing server state (unless security policy requires hiding account existence).
Require a client-generated `Idempotency-Key` header stored in a unique database index so retries return the original result cleanly.
Use 412 specifically when conditional headers like `If-Match` fail, and 409 for general domain or database state conflicts.