API versioning without breaking existing clients
Once an API is used by more than one client, every change becomes a question of compatibility. If you want to evolve an API without breaking existing clients, versioning is hard to avoid. Here's a pragmatic approach that has served us well in most projects.
When to version at all
Not every change needs a new version. An extra, optional field in the response usually breaks nothing. A new version is only needed when the meaning or structure of existing fields changes, or a field is removed.
Versioning via the path
A version in the URL path, like /v1/ and /v2/, is the clearest solution for most teams. It's immediately visible in logs and easy to separate in documentation.
GET /v1/customers/42
GET /v2/customers/42
Don't remove the old version right away
Introducing a new version doesn't mean removing the old one immediately. A realistic transition period during which both versions run gives clients time to migrate. A deprecation date should still be communicated clearly, or the old version will stick around forever.
Monitor the old version
Knowing how many requests still hit the old version lets you plan its removal based on data, instead of guessing whether anyone still uses it.