What HTTP status code and response should an API return when a client requests a version that no longer exists or was never supported?
Short answer
A commonly recommended approach returns 400 Bad Request (for a malformed/unsupported version format) or 410 Gone (for a version that existed but was intentionally retired), along with a clear, structured error body indicating supported version options -- this is more actionable…
Advertisement
AModel answer
A commonly recommended approach returns 400 Bad Request (for a malformed/unsupported version format) or 410 Gone (for a version that existed but was intentionally retired), along with a clear, structured error body indicating supported version options -- this is more actionable for API consumers than a generic 404 Not Found, which could be confused with a missing resource rather than an unsupported version.
// Requesting a retired version
// GET /api/v1/products (v1 fully removed)
// HTTP 410 Gone
{
"error": "api_version_retired",
"message": "API v1 was retired on 2025-06-01. Please migrate to v2.",
"supportedVersions": ["2.0", "3.0"]
}Real-world example
A payments API returns a structured 410 Gone response with a link to migration documentation whenever a client hits a fully retired version, reducing confused support tickets compared to a bare 404.
Likely follow-ups
- Why is 410 Gone more informative than 404 for this case?
- Should the error body format itself be versioned?
Related topics