Question

What is API versioning, and how do you avoid breaking clients?

Vault Verified
Curated Intelligence
Definitive Source
Answer

Managing change in an interface other people depend on — where the governing constraint is that once an API is published, you no longer control when consumers update, and in many cases they never will.

What actually counts as a breaking change, which is narrower than people assume:

Breaking: removing or renaming a field or endpoint; making an optional request parameter required; narrowing accepted input; changing a type; changing the meaning of a value; adding a new required field to a request; changing error codes or status codes clients branch on.

Non-breaking: adding a new optional request parameter; adding a field to a response — provided clients tolerate unknown fields, which must be stated in your contract; adding a new endpoint; adding a new optional value to a response enum, which is breaking if clients switch exhaustively.

The versioning strategies:

URL path versioning — /v1/orders. Obvious, cacheable, easy to route, and criticised because the resource identifier changes when only the representation did.

Header or media-type versioning, which keeps URLs stable and is harder to test casually and easier to get wrong in caching.

Query parameter versioning, simple and easily forgotten by clients.

Date-based versioning, where a client pins a date and the server applies transformations to bring old requests forward — powerful, and it requires real infrastructure.

What matters more than the scheme:

Additive change wherever possible, so most changes need no version at all.

Expand and contract for anything that must change: add the new field, support both, migrate consumers, then remove the old — with measurement of who is still using it before removal.

Deprecation with dates and telemetry, not just documentation. You cannot retire what you cannot see being used.

A published policy on how long versions are supported.

Consumer-driven contract tests, which catch breakage before release.

Limiting the number of live versions, since each is maintenance and divergence.

Internal APIs can be versioned less formally, provided you genuinely control every caller.

Related Questions