Versioning APIs

1. Using URI Versioning

PatternExample
Path prefix/v1/users, /v2/users
Subdomainv1.api.example.com
ProsVisible, cacheable, easy to test
ConsViolates "URI = resource" purist view

2. Using Header Versioning

HeaderExample
Custom headerX-API-Version: 2
Date-based (Stripe)Stripe-Version: 2026-01-15
ProsClean URIs
ConsLess visible, harder to test in browser

3. Using Query Parameter Versioning

PatternExample
Query param/users?api-version=2
ProsEasy to test, optional
ConsCan be forgotten; cache key issues

4. Using Content Negotiation Versioning

Example: Vendor Media Type Versioning

GET /users/42
Accept: application/vnd.example.v2+json

HTTP/1.1 200 OK
Content-Type: application/vnd.example.v2+json

5. Implementing Backward Compatibility

Safe ChangeBreaking Change
Add optional fieldRemove/rename field
Add optional query paramMake optional → required
Add new endpointChange response shape
Loosen validationTighten validation
Add enum value (with caveat)Remove enum value

6. Handling Deprecated Versions

HeaderUse
Deprecation: trueMark endpoint deprecated (RFC 9745)
Sunset: <date>End-of-life date (RFC 8594)
Link: <...>; rel="successor-version"Point to replacement
Warning: 299 - "Deprecated; use v2"Human-readable

7. Communicating Version Changes

ChannelContent
ChangelogPer-version diffs, migration notes
Email to API consumersPre-deprecation, mid, sunset
Developer dashboardBanner with usage of deprecated APIs
Status page / blogPublic announcements

8. Managing Multiple Versions Simultaneously

StrategyTrade-off
Separate codebasesIsolation; duplication
Adapter layerSingle core, version-specific transforms
Feature flagsPer-version behavior in same code
Limit to N versionse.g. current + 1 prior

9. Using Semantic Versioning

ComponentWhen to Bump
MAJORBreaking change
MINORBackward-compatible new features
PATCHBackward-compatible bug fixes
API URL versioningUsually only MAJOR (/v1, /v2)

10. Documenting Version Differences

Doc ElementContent
Per-version OpenAPI specMaintain separate specs
Migration guideStep-by-step v1→v2 changes
Diff toolAuto-generated diff page
Code samplesPer-version SDK examples