API Versioning and Backward Compatibility: A Practical Guide

By Arkaitz

Stripe shipped almost a hundred backwards-incompatible upgrades in its first six years and still serves /v1. Its engineers date-name each release instead of cutting a v2, and they call a major-version upgrade almost as painful as re-integrating from scratch (Stripe engineering). That fact should change how you plan your next API change. A version number does not keep clients alive. Compatible change does.

So you should treat the version as a liability with a job. It marks a compatibility boundary you promise to support. Every boundary you publish costs you tests, documentation, on-call attention, and a migration you must finish. Your goal is to ship most changes without a new boundary, and to make the rare boundary you publish easy to leave.

You can read this guide as part of the system design practical guide. It covers what a version promises, what actually breaks a client, how to change a schema in place, how to choose a versioning scheme, and how to retire one.

What is API versioning, and what does a version actually promise?

API versioning is a public promise that a named surface keeps its behaviour for as long as the name resolves. Your version is a compatibility boundary. It is not your release counter, your build number, or the version field in your OpenAPI document.

The HTTP specification gives you the model to copy. RFC 9110 increments the major protocol version only when a change breaks the message syntax. It makes additive changes through extension points without changing the version at all (RFC 9110, §2.5). You should apply that discipline to your API. You do not need v2 for a new optional field. You need one when the meaning changes.

Google splits compatibility into three kinds, and you should test all three (AIP-180):

  • Source compatibility. Your code written against the old client library still compiles.
  • Wire compatibility. Your old code still serialises and deserialises correctly.
  • Semantic compatibility. Your old code still receives what a reasonable developer expects.

The third kind causes most of your outages. Your JSON stays valid, your types stay stable, and a field that used to mean captured now means captured or pending. Every client keeps running, and every client is wrong.

Your version numbers also multiply. OpenAPI warns that info.version is distinct from the OpenAPI Specification version and from the API implementation version (OpenAPI 3.1). You need one identifier that governs behaviour, and you need to say so in public. The rest are build metadata.

Scope matters as much as the name you choose. You can version a whole API, one resource, or one interface. Google's newer scheme scopes a version as small as a single interface or as large as an entire service (AIP-185). You should choose the smallest unit that can change independently. If you version everything together, one team's field addition forces every other team through your release.

What counts as a breaking change in an API?

A breaking change is any change that can stop an existing client without a code change on that client. Your intent does not matter. A helpful new validation rule that rejects a request your old server accepted is a breaking change.

GitHub publishes a concrete list you can use, and it comes close to a complete taxonomy (GitHub breaking changes):

  • Remove or rename an operation, parameter, response field, or enum value.
  • Add a new required parameter, or make an optional parameter required.
  • Change the type of a parameter or field.
  • Add a validation rule to an existing parameter.
  • Change authentication or authorisation requirements.

You should add three more. Change a default value and you break clients that rely on it. Change how you serialise that default and you break clients that treat presence as meaning. Tighten a rate limit or a permission model and you break clients even though the schema never moves. Google treats the first two as incompatible within a major version, so you cannot ship them in place (AIP-180).

Semantic change is your hard case. Google's rule is blunt, and it leaves you little room: APIs must not change visible behavior or semantics in ways that are likely to break reasonable user code. Hyrum's Law explains why the rule needs to exist: with enough consumers, all observable behaviors of your system will be depended on by somebody (hyrumslaw.com). Your documentation describes the contract you intended. Your traffic describes the contract you have.

You face the same taxonomy across a service boundary and across an event stream. You can treat a queue message as an API with no URL. When you add a required field to an event, you break every consumer that validates the payload. Synchronous versus asynchronous communication covers the transport choice; the compatibility rule does not change with it. And when two teams own two services, the contract between them decides how often they must coordinate, which is the argument in monolith versus microservices.

How do you make a backward-compatible change without a new version?

Add the new shape, migrate every reader and writer, then remove the old shape. You know the pattern as expand and contract. You will also see it called parallel change. It turns your one breaking deploy into a sequence of compatible deploys.

The sequence has seven steps:

  1. Expand. You add the new field or endpoint alongside the old one, and you keep the old one populated.
  2. Dual-write. You write both shapes from the same transaction so they cannot disagree.
  3. Backfill. You fill the new shape for existing records. Run it idempotently, because you will run it twice.
  4. Migrate readers. You move consumers to the new shape one at a time. Publish an SDK or a codemod if you own the clients.
  5. Measure. You watch reads of the old shape by credential and by client version. Do not trust deploy counts.
  6. Stop writing the old shape. You keep reading it until the last consumer leaves.
  7. Contract. You remove the old shape in a release that nobody notices, because the traffic is already zero.

Stripe runs the same pattern at the response layer, and you can copy the shape. Its service formats every response at the current version, then applies version-change modules backwards until it reaches the caller's pinned version. Old behaviour lives in small modules, so your new code never branches on it. Stripe calls the result fixed-cost: an old version adds little maintenance cost because new code never thinks about it (Stripe engineering). Adyen names the same pattern directly and uses it to add elements without changing the API version (Adyen).

Two constraints decide whether expand and contract works for you. First, you must be able to represent both shapes at the same time. If your new model cannot coexist with the old one in storage, you need a migration, not a field addition. Second, you must own the order of removal. You will usually contract too early if you measure your own deploys rather than your consumers' reads. This is the same discipline that lets you evolve an architecture without a rewrite at a larger scale.

Why is additive-only not always backward compatible?

Because additive describes your change, not your client's parser. A new response field is compatible only if your consumers ignore fields they do not know. That is a client promise, and you have to publish and enforce it.

The major vendors disagree here, which tells you the answer is policy rather than physics. Microsoft requires services to fail a request with 400 Bad Request when any JSON field or value is not fully understood by that service version (Microsoft REST API guidelines). Under that rule, you may need a new api-version to add a field. Adyen treats an added optional response field as non-breaking for its new APIs and breaking for its classic APIs (Adyen). Zalando goes the other way and requires clients to accept compatible extensions (Zalando).

Enums break your additive story on their own. If your client uses an exhaustive switch, it handles the old values and falls through on the new one. GitHub lists removing an enum value as breaking and adding one as additive (GitHub). Both statements are true, and together they mean your client needs a default branch. If your SDK generates a closed enum without one, you shipped the break yourself.

Defaults and absence cause your quiet version. If you add an optional field with a default, you change server behaviour for every client that omits it. Google treats a default change, and a change to how you serialise that default, as incompatible, so you cannot ship either in place (AIP-180). You hit the same problem with null versus missing, empty array versus absent, and a number that moves from integer to decimal.

So you should write the tolerance rule into your contract. Tell your consumers to ignore unknown fields, handle unknown enum values through a default path, and treat absence and null the same way. Then you test it. A contract test that feeds your old client a response with an extra field and an extra enum value catches more regressions than a schema diff.

Should you put the API version in the URL, the media type, or a header?

Put it where your consumers and your infrastructure can see it. For most public APIs that means the URL or a required header, not the media type. Each location buys you a different property, and each one costs you something.

URL versioning puts the boundary in the path: /v1/orders. You can see it in logs, cache keys, routing rules, and a browser address bar. Google requires a major version as the first path segment for REST APIs (AIP-185), and Adyen ships /v68/payments (Adyen). The cost is gravity. Once /v1 and /v2 both exist, you must decide which path gets every fix, and the old path becomes a product you maintain.

Media-type versioning keeps the URI stable and negotiates the representation: Accept: application/vnd.acme.v2+json. It fits HTTP content negotiation, which your clients already speak, and RFC 9110 defines the mechanism. Zalando mandates it and forbids URL versioning (Zalando). The costs are real. Your version disappears from most access logs. Your caches need Vary: Accept. A browser sends a broad Accept header while curl sends */*, so you get different representations from the same URL. RFC 9110 also lists the general problems with proactive negotiation: the server cannot know what is best for a user, the client repeats capabilities on every request, the implementation gets harder, and shared caching gets less reusable (RFC 9110, §12.1).

Header or query versioning carries the boundary outside the path: Stripe-Version, X-GitHub-Api-Version, or ?api-version=2021-06-04. Microsoft requires the query parameter and explicitly forbids a version segment in the path (Microsoft). Google's newer interface-based scheme accepts a header or a query parameter, with dates such as 2025-09-04 (AIP-185). This style suits you when you need fine-grained date versions, because it keeps one resource identifier stable. It also hides the version from anyone reading a URL, so you must log the header.

You must also decide what happens when a request carries no version. That default is a compatibility decision, not a neutral fallback. GitHub sends an unversioned REST request to 2022-11-28, even though the latest version is 2026-03-10 (GitHub). Stripe pins an account to the newest version on its first request, then keeps it there (Stripe engineering). Both choices protect existing clients from a surprise break, and both create a long tail you must migrate later. Pick the default deliberately, document it, and log the resolved version with every request.

You should pick one location for the version and state its precedence. A request that carries a path version, a header version, and an Accept parameter with three different values gives you a response whose behaviour you cannot predict. That is how versioning turns into an incident.

Should you use semantic versioning or a date for an API?

Use semantic versioning for the artifact you ship and a date for the contract you serve. SemVer answers a dependency-resolution question. An API version answers a compatibility question. They are not the same question.

SemVer gives you MAJOR.MINOR.PATCH: major for incompatible changes, minor for backward-compatible features, patch for backward-compatible fixes (semver.org). That works when your package manager can resolve a range and pick a version for you. A hosted API gives your client no such resolver. Your client sends one value and gets one behaviour. Minor and patch numbers then advertise a promise you cannot act on, while your release cadence leaks into a public identifier.

Google avoids the problem by refusing to expose minor or patch numbers at all: Google APIs use `v1`, not `v1.0`, `v1.1`, or `v1.4.2` (AIP-185). That is a major number used as a compatibility boundary, not SemVer.

A date-based identifier tells you something different and more honest: this response is the behaviour as of 2026-03-10. GitHub names its versions that way, so you can pin a client to a day (GitHub API versions). Stripe names its versions 2017-05-24 (Stripe), and Azure requires YYYY-MM-DD (Microsoft). Dates sort, pin, and compare without a resolver, which saves you a tool.

The trade-off is that a date tells you nothing about upgrade risk. You need a changelog with before-and-after examples, and you need a diff tool. A date is a label on a snapshot, not a safety rating for your upgrade.

Many mature APIs run both, and you can too. They keep a coarse major path or a stable host, and they date-name the compatibility snapshots inside it. Stripe still serves /v1 and still changes behaviour by date (Stripe docs). You should use SemVer where a resolver exists, such as your SDK, your OpenAPI document, and your container images. Zalando requires SemVer for the OpenAPI info.version field (Zalando). Keep that number out of your wire contract.

What belongs in an API deprecation policy?

A deprecation policy needs five things: what can be deprecated, when notice starts, how you signal it, how long support lasts, and what happens at the end. Without all five, you have an intention, not a policy.

You start with scope. You say whether the policy covers endpoints, fields, parameters, whole versions, and event schemas. You also say who can start a deprecation and who can extend it. A policy that only covers endpoints will fail you the first time you need to remove a field.

Then you set the clock and the channels. Notice starts on a date you publish, not on soon. You publish the date in the changelog, in the developer portal, and in the response itself. RFC 9745 defines a Deprecation response header and a deprecation link relation, and RFC 8594 defines Sunset for the date a URI stops answering (RFC 9745, RFC 8594). Use both, because you need to reach two different readers. A header reaches you at 2am; a changelog reaches you when you plan a quarter.

You need a number for your support window, and the industry gives you anchors rather than a law:

  • GitHub supports the previous REST API version for at least 24 months and returns 410 Gone for an unsupported one (GitHub).
  • Kubernetes will not remove a GA API within a major version, and it time-boxes beta APIs at both ends: a beta API is deprecated no more than 9 months or 3 minor releases after introduction, whichever is longer, and stops serving 9 months or 3 minor releases after deprecation, whichever is longer (Kubernetes).
  • Google recommends 180 days for a deprecated beta feature (AIP-185).
  • Azure retires prior preview versions 90 days after a replacement ships (Azure versioning guidelines).

Pick a window you can staff, publish it, and apply it without exceptions. A 24-month promise you honour beats a 6-month promise you extend four times.

Finally, you define the end. You say which status code the old surface returns, whether you keep it in DNS, and what data you retain. 410 Gone tells your client the resource is gone for good. 404 suggests a typo. A 400 with a migration link is kinder than either. Then you write down what support means: security fixes only, or bug fixes, or new features. Most teams promise more than they fund.

How do you finish an API migration instead of supporting two versions forever?

Instrument the old version, make the new one cheaper to adopt, and set a date you will enforce. Migrations stall for two reasons: you cannot see who is left, and the new path costs you more work than staying.

You start with telemetry. You count requests per version, per credential, per SDK version, and per endpoint. A single total tells you the migration is 90% done and hides the one integration that sends half your traffic. You put the old-version count on a dashboard with a target line, and you alert when it stays above zero after the sunset date. If you cannot attribute traffic to a consumer, you cannot run a deprecation; fix that before you announce one.

Then you lower the cost of moving. You publish a changelog with a before-and-after payload for every breaking change. You ship the new SDK major with a migration guide and a codemod where the change is mechanical. You offer a sandbox and test credentials. The cheapest migration is the one a consumer can finish in an afternoon.

You use brownouts once the date is close. You return 410 Gone from the old surface for a short, announced window, then restore it. A brownout finds the clients that ignored every email you sent, and it does so while you still have time to help them. You increase the window until the shutdown is boring.

You fund the support. Every live version is a branch of behaviour you must test, document, and secure. That is architectural debt with a renewal date. You cap the number of live versions at two or three, give the oldest one an owner, and put its cost in the platform budget. When nobody owns the old version, it survives by default, and you pay for it.

What is the smallest API versioning policy that holds up?

Default to compatible change, use expand and contract for structural change, and reserve a new version for semantic change. Everything else is detail you can add later.

Seven rules cover the cases you will hit:

  1. Publish the promise. You state what a version covers, how long you support it, and what your clients must tolerate. Include the unknown-field and unknown-enum rules.
  2. Classify every change before merge. You put the breaking-change checklist in the pull-request template. A reviewer who cannot classify the change cannot approve it.
  3. Prefer additive plus expand and contract. Most of your features fit. The ones that do not usually need a data migration, not a new version.
  4. Reserve a new version for a semantic break or an urgent removal. If your old and new meanings cannot coexist, a boundary is honest. If they can coexist, use one.
  5. Use a date for the contract. You add a major path only when you truly need a flag day. Never put minor and patch numbers on the wire.
  6. Signal deprecation in the response and in the changelog. You set Deprecation and Sunset, publish your migration guide, and name the status code the old surface will return.
  7. Measure, then enforce. You attribute traffic to consumers, run brownouts, and shut the old version down on the published date.

The counter-intuitive part is your accounting. A new version feels like progress because you ship it. In practice it adds a permanent support obligation for you and postpones the conversation with the consumer who will not move. The compatible change is slower for you to design and faster to finish. It keeps one contract alive, one test suite green, and one migration off your backlog.

That is the real compatibility strategy: make the contract stable enough that you can change it, and make the exit cheap enough that you can retire it. The cheapest version is the one you never ship. The only version that survives is the one you can end.

Related Reading