Skip to content

API versioning

Once an API has clients you don’t control, every change is a negotiation. Versioning is how you make changes that clients would otherwise have to absorb all at once, and deprecation is how you eventually stop supporting the old behavior. The best versioning strategy is one you rarely need, because most changes can be made without breaking anyone.

Usually safe (additive):

  • Adding an optional request field or query parameter
  • Adding a field to a response
  • Adding a new endpoint or a new resource
  • Adding a new optional header

Breaking:

  • Removing or renaming a field, endpoint or parameter
  • Making an optional field required
  • Changing a field’s type or format (a number becomes a string, a date format changes)
  • Changing the meaning of a value, even if the type stays the same
  • Changing error codes or status codes clients rely on
  • Tightening validation so previously accepted requests are rejected
  • Adding a value to an enum that clients switch on, if they treat unknown values as errors

“Additive” changes are only safe if clients follow the tolerant reader rule: ignore fields you don’t recognize and don’t fail on new enum values. Say so in your API guidelines, and test your own clients for it. The most dangerous change is the one where nothing in the schema changes but the meaning does; see the failure story below.

Approach Example Strengths Weaknesses
URL path /v2/orders Visible, easy to route, cache and test Encourages big-bang versions of the whole API
Header Api-Version: 2 Clean URLs, can version per request Less visible; easy to forget in tests and logs
Media type Accept: application/vnd.example.v2+json Versions the representation, fits HTTP semantics Unfamiliar to many developers
Date-based Api-Version: 2026-11-01 Small, frequent changes; each client pins the version it was built against The server must translate between many versions

URL path versioning is the most common for public APIs because it’s obvious. Date-based versioning, described in Stripe’s account of its API versioning (opens in a new tab), lets an API change often while each client stays on the behavior it was built for: the server keeps a chain of small transformations from each old version to the current one.

For internal APIs between teams, versioning the whole API is often unnecessary. Additive changes, consumer-driven contract tests and a deprecation process usually do the job.

Events need versioning as much as APIs do, and they’re harder, because old events stay in logs and get replayed. Use a schema registry with compatibility checks (backward compatibility, so new consumers can read old events), add fields rather than changing them, and publish a new event type when the meaning changes.

  1. Announce the deprecation with a date, a reason and a migration guide.
  2. Signal it at runtime. The Deprecation header (RFC 9745 (opens in a new tab)) tells clients a resource is or will be deprecated, and the Sunset header (RFC 8594 (opens in a new tab)) gives the date it stops working.
  3. Measure who still uses it. Log the client identity on every call to the old version. You can’t retire what you can’t attribute.
  4. Contact the remaining clients directly; don’t rely on the announcement.
  5. Run brownouts for heavy users: switch the old version off for short, announced periods so missed dependencies show up while you can still switch it back.
  6. Retire it on the date, and keep a clear error that points to the migration guide.

Agree a support policy up front (for example, at least 12 months between deprecation and sunset for public APIs) so clients can plan.

  • Versioning too often. Every live version is code to run, test and secure.
  • Breaking changes inside a version “because it’s only a small one”.
  • No owner for old versions, so they rot without anyone noticing.
  • Generated client libraries that fail on unknown fields, which turns every additive change into a breaking one.

Written and edited by Abhinav Taduka, enterprise software architect.