API versioning without breaking your consumers

The most effective versioning strategy is to need a new version rarely, which means evolving by addition, catching breaking changes in the pipeline, knowing who calls what and running a dated deprecation when a break cannot be avoided.

By Nabil Ahmed8 minute read

The lunar surface near 28°S, 22°E, lit by a low Sun with night falling across one side.
The Moon near 28°S, 22°E. Rendered by Farside from NASA Lunar Reconnaissance Orbiter elevation data.

Most arguments about API versioning concern where to put the number (in the path, in a header or in the media type), which is the least important decision. Whether consumers get hurt depends on what you count as a breaking change, whether you find out about one before release, and whether you know who is still calling the thing you want to remove.

A breaking change is any change to an interface that can make a correctly written existing consumer fail or behave differently even though that consumer has changed nothing. Because the definition rests on what the consumer experiences rather than what the provider intended, it is harder to apply than it looks, and many changes a provider considers harmless break someone.

Our position is that a new major version imposes a cost on every consumer, so it should be issued rarely and deliberately. Most change can be made by addition, and what remains needs a process with dates, telemetry and a named owner rather than an announcement and a hope.

In brief

  • Breaking changes are defined by their effect on existing consumers, so adding a required field, tightening validation or adding a value to an enumeration can break callers even when nothing was removed.
  • Most API change can be delivered by addition within the current version, as long as consumers are told from the start to ignore fields and values they do not recognize.
  • Where the version identifier goes matters far less than applying one scheme consistently and versioning the whole contract rather than individual endpoints at random.
  • The build pipeline should catch breaking changes automatically by comparing the new contract with the published one, before a person has to notice.
  • An old version can be retired safely only when per-consumer usage data shows that it has no remaining callers, and that data has to be collected from the API's first day in production.

Step 1: write down what counts as breaking

Agree on the list before the first argument about it and publish it with the API, using the groups below as a starting point.

Breaking

  • Removing or renaming a field, endpoint, parameter or event type.
  • Changing the type, format or unit of a field (a string to a number, cents to whole currency units, local time to UTC).
  • Making an optional request field required, or adding a new required field.
  • Tightening validation so that input which used to be accepted is now rejected.
  • Changing what a field means while keeping its name, which is the worst kind of break because nothing fails and the data is silently wrong.
  • Changing default behavior that consumers may rely on, such as the default sort order or page size.
  • Changing the error codes or status codes that consumers branch on.

Not breaking, if consumers are tolerant

  • Adding an optional field to a request.
  • Adding a field to a response.
  • Adding a new endpoint or event type.

Disputed, so decide explicitly

  • Adding a value to an enumeration in a response is disputed, since a consumer with a strict switch statement, or with generated client code that rejects unknown values, will fail. Either state in your contract that enumerations are open and new values may appear, or treat every new value as breaking.

The middle group relies on a rule usually called the tolerant reader, under which a consumer ignores anything it does not recognize. Publish that expectation in your documentation from the first day, because it cannot be added later. If your consumers generate clients from the specification, check how the generator handles unknown fields and values, since some reject them by default.

Step 2: evolve by addition

With a tolerant-reader rule in place, most changes need no new version, because you can expand the contract first and contract it much later.

Suppose an order API returns customerName as a single string and you now need structured names.

  1. Expand the contract by adding a new customer object with givenName and familyName, while keeping customerName and continuing to populate it.
  2. Migrate consumers by telling them, marking the old field as deprecated in the specification and watching who still reads it, while accepting both forms in requests.
  3. Contract the interface by removing the old field once its usage has stopped or the deprecation date has passed. This is the only breaking step, and by then it has no consumer left to break.

The same sequence works for events and for database-backed contracts, and it is also the discipline behind data contracts. The provider carries both shapes for a while, which is where the cost belongs, since one team pays a little and consumers are spared from paying on the provider's schedule.

Step 3: choose a versioning scheme and apply it consistently

When a break cannot be avoided, the consumer needs a way to say which contract it expects. All the common schemes work, and they differ mainly in visibility and in how convenient they are to operate.

Scheme Example Strengths Weaknesses
Path segment /v2/orders Visible in every log and URL, simple to route and cache, easy to explain Encourages copying the whole API for one change; URLs of resources change between versions
Custom header Api-Version: 2 URLs stay stable; version is separate from resource identity Invisible in a browser or a casual log line; harder to test by hand
Media type Accept: application/vnd.example.order.v2+json Versions the representation, per resource, in line with HTTP content negotiation Least familiar to consumers; tooling support varies
Date-based Api-Version: 2026-03-01 Each consumer is pinned to the contract as of a date; small breaks can ship without a big-bang release The provider must maintain a chain of transformations between dated versions

For most internal and partner APIs we consider a major version in the path to be the pragmatic choice, because everyone can see it. Whichever scheme you pick, three rules matter more than the choice itself.

  • One scheme across the organization spares consumers from learning a new convention per API, and it is a standards decision that belongs to enterprise integration rather than to each team.
  • Only major versions belong in the interface, because minor and patch changes are additive by definition and need no identifier that consumers have to send.
  • No default to the latest version means a request without a version is either rejected or pinned to a fixed version, since defaulting to the newest turns every release into a potential break for consumers who never opted in.

Step 4: catch breaks in the pipeline

People are poor at spotting breaking changes in review, especially the subtle ones, whereas machines do it well as long as the contract is written down.

Keep the specification in the repository, using OpenAPI for HTTP APIs, AsyncAPI or registry schemas for events and Protobuf definitions for gRPC, and have the build compare the proposed contract with the one currently published. Open-source tools such as oasdiff for OpenAPI and Buf for Protobuf classify each difference as breaking or non-breaking. A breaking difference should fail the build unless someone has explicitly declared a new major version.

For the consumers that matter most, add consumer-driven contract tests as well. In this approach, which tools such as Pact support, each consumer publishes the requests it makes and the parts of the response it relies on, and the provider's build verifies them. These tests catch something a specification diff cannot, namely reliance on behavior that was never written down. How they fit with the rest of the suite is covered in a test strategy for systems that change every week.

Step 5: know who calls what, then retire by project

A version whose callers you cannot see is a version you cannot safely retire. From the first release, every request should be attributable to a consumer through an API key, a client identifier from the token or a registered application. Record the version and endpoints that each consumer calls, and keep the records long enough to cover quarterly and annual jobs.

This telemetry is a core part of treating APIs as products, because without it every deprecation is a guess, and guesses get postponed indefinitely.

With the data in hand, a deprecation becomes a change program with a small audience that needs an owner and a plan.

  1. Announce with dates, giving both the date the old version stops receiving changes and the date it stops responding. The period should match your consumers' release cycles, since a partner on a quarterly release train cannot move within a month.
  2. Signal in the protocol by sending the Sunset HTTP response header, defined in RFC 8594, which carries the date after which a resource is expected to stop working. Send it on every response from the old version and mark deprecated operations in the specification.
  3. Publish a migration guide that lists the exact differences and gives a worked request and response for each one.
  4. Chase consumers by name, using the telemetry to list each week who is still on the old version and contacting their owners directly.
  5. Rehearse the removal in short, announced windows during which the old version returns an error, so that consumers who ignored the emails notice while the fix is still a rollback away.
  6. Remove it and return 410 Gone with a pointer to the migration guide, which tells the consumer more than a generic not-found would.

The status that broke the mobile app

Consider a mid-size retailer whose order API is used by its website, its mobile app, a warehouse partner and a finance export. The order status field has four values, and when the business introduces split shipments the team adds a fifth, PARTIALLY_SHIPPED, which they regard as additive and release within the current version.

The website copes with the new value, but the mobile app was built with a generated client that maps the status to a strict enumeration, so it fails to parse any order carrying the new value and the order history screen shows an error. Because old app versions stay installed on customers' phones for months, fixing the app does not fix the problem. The warehouse partner's nightly job rejects the entire file at the first unknown value.

The response has an immediate part and a lasting part.

  • As an immediate measure, the API returns the new value only to consumers that send an opt-in header, while the others receive PROCESSING until every part has gone and SHIPPED after that, as before. The opt-in is a stopgap with an end date.
  • The contract is amended to say that status is an open enumeration, and the mobile client is changed to show unknown values as a generic "in progress" display, a change that has to ship and reach most installed versions before the stopgap ends.
  • A contract diff added to the pipeline flags any new enumeration value for explicit review, and the build now verifies a consumer contract published by the warehouse partner.
  • Telemetry by consumer and by app version is added so the team can see when the opt-in can become the default.

Progress would be measured by failed parses reported by the app, rejected partner files and the share of traffic still relying on the stopgap.

A checklist to take to your API owners

  • Is there a published definition of a breaking change, and does it say whether enumerations are open?
  • Does the consumer documentation state the tolerant-reader rule, and do your generated clients honor it?
  • Is the specification kept in source control and compared with the published version on every build?
  • Could you name every consumer of each version from last month's traffic?
  • Is a request with no version rejected or pinned, or is it served the latest version?
  • Does each deprecated version have an owner, a date and a Sunset header?

If several answers are no, start with the telemetry, because every later step depends on it, and then add contract checks to the pipeline as part of ordinary quality engineering.

Related services

Start a conversation.

A short paragraph is enough. A principal reads every message and replies within one working day.

Or email hello@farside.works. We use what you send only to reply. Privacy