Change an API without breaking the apps that already use it.
API versioning is how you change an API without breaking the apps that already use it.
v1 and v2) lets the old shape keep working while the new shape is introduced.An API is a contract. Clients rely on the URLs, the field names, the types and the meaning of every response. When you control both sides (a web app and its own backend), you can change both together. But a mobile app stays on a user's phone for months, and a partner's code is not yours to edit. If you change the contract in place, those clients break the moment you deploy.
So the first question is always: is this change breaking?
| Change | Breaking? | Why |
|---|---|---|
| Add an optional response field | No | Clients ignore fields they do not know. |
| Add a new endpoint | No | Nobody calls it yet. |
| Remove or rename a field | Yes | Clients that read it now get nothing. |
| Change a fieldβs type or meaning | Yes | Old code may crash or compute the wrong answer. |
| Make a request field required | Yes | Old clients do not send it, so their calls fail. |
| Change an error code or status | Often | Clients may branch on the old value. |
| Strategy | Looks like | Good | Not so good |
|---|---|---|---|
| URL path | GET /v2/orders | Obvious, easy to test in a browser, easy to route | The URL of a thing changes between versions |
| Header | Accept-Version: 2 | URLs stay the same | Hidden from view, harder to test and cache |
| Media type | Accept: application/vnd.shop.v2+json | Fits the idea of one resource, many representations | Most complex for clients |
| Query parameter | GET /orders?version=2 | Simple to add | Easy to forget, and it clutters caching |
| No version (additive only) | GET /orders | Nothing to manage | You can never remove or change anything |
HTTP/1.1 200 OK Deprecation: true Sunset: Wed, 01 Jul 2026 00:00:00 GMT Link: <https://api.example.com/docs/migrate-v2>; rel="deprecation"
The Deprecation and Sunset headers tell clients, in a way that tools can read, that a version is on its way out and when it will stop. Pair them with docs, emails and logs of who still calls the old version.
β οΈ Breaking change. Old clients still read name, which is now missing.
One API. Every client gets the change at once.
A simplified model with three fixed clients and no random numbers. The upkeep figure is illustrative: it only shows that every live version adds testing, documentation and security work. Real costs depend on your team.
| Term | Meaning in easy words |
|---|---|
| API contract | The promise about URLs, fields, types and behaviour that clients depend on |
| Breaking change | A change that can make existing clients fail |
| Non-breaking (additive) change | A change old clients can safely ignore, such as a new optional field |
| Backward compatible | New server, old client: it still works |
| Tolerant reader | A client that ignores fields it does not understand |
| Deprecation | Marking something as old, with a plan to remove it |
| Sunset | The date when a deprecated version will stop working |
| Version pinning | A client choosing one version and staying on it |
| Media type versioning | Putting the version inside the Accept header (content negotiation) |
| Expand and contract | Add the new thing, move users across, then remove the old thing |
| Migration guide | A document that shows clients how to move to the new version |
| Choice | We gain | We lose |
|---|---|---|
| Version in the URL | Obvious and simple | Resource URLs change between versions |
| Version in a header | Clean URLs | Harder to see, test and cache |
| Additive-only policy | No versions to manage | Cannot ever remove or reshape things |
| Many live versions | Happy old clients | A heavy burden of tests and fixes |
| Short support window | Less upkeep | Clients feel pushed, partners may complain |
| Long support window | Calm clients | Old, possibly insecure code stays alive |