Designing API Versioning and Evolution

1. Designing API Versioning Strategy

StrategyProsCons
URI pathCache-friendly, explicitPollutes URLs
Header (Accept)Clean URIsHard to test in browser
Date-based (Stripe)Pin client to dateServer must maintain transformations
Additive onlyNo versionRequires strict discipline

2. Designing Backward Compatibility

Safe ChangeUnsafe Change
Add optional fieldRemove field
Add endpointChange response shape
Loosen validationTighten validation
Add enum value (with default)Rename field
Add headerChange error semantics

3. Designing Breaking Change Management

Breaking Change Process

  1. Announce + deprecation date in changelog
  2. Add new field/endpoint alongside old
  3. Mark old as deprecated (header, docs)
  4. Send Sunset header on old endpoint
  5. Track usage of old; outreach to clients
  6. Remove after deprecation window (e.g., 12 months)

4. Designing API Deprecation Strategy

MechanismDetail
Deprecation headerDeprecation: true; Sunset: <date>
Docs bannerBig visible warning
Client warningsLog on use; email account owners
BrownoutsPeriodic short outages near sunset

5. Designing API Sunset Policy

WindowUse Case
3 monthsInternal/private APIs
6–12 monthsPartner APIs
12–24 monthsPublic/critical integrations
RFC 8594Sunset HTTP header

6. Designing Schema Evolution

FormatRules
ProtobufDon't reuse field numbers; reserved keyword
AvroDefault values for new fields; aliases for renames
JSONOptional fields; ignore unknown
CompatibilityBACKWARD, FORWARD, FULL (Schema Registry)

7. Designing Client Migration Strategy

PracticeDetail
Adapter on serverTranslate v1 → v2 internally
SDK upgrade pathCodemods, migration scripts
Dual reportingTrack v1 vs v2 RPS per client
Forced upgradesLast resort: respond 410 Gone

8. Designing Version Negotiation

MechanismExample
Accept headerapplication/vnd.api.v2+json
Custom headerX-API-Version: 2026-05-15
Server defaultLatest if not specified
Client pinningSDK locks to known version

9. Designing Parallel Version Support

ApproachTrade-off
Separate code pathsClear; duplication
Adapter layerSingle core; mapping cost
Separate servicesIndependent deploys; ops cost
Feature flagsPer-version behavior toggles

10. Designing API Changelog Management

SectionContent
Version + dateHeader
AddedNew endpoints/fields
ChangedBehavior tweaks
DeprecatedWith sunset date
RemovedBreaking
FixedBug fixes

11. Designing Consumer-Driven Contracts

ElementDetail
ToolPact, Spring Cloud Contract
FlowConsumer publishes contract → Producer verifies
CI gateBlock prod deploy if contracts fail
BrokerPact Broker tracks per-version compatibility

12. Designing API Gateway Version Routing

StrategyDetail
Path prefix/v1/* → svc-v1, /v2/* → svc-v2
HeaderX-API-Version selects upstream
WeightedGradual cutover from v1 to v2
Per-tenantBring users over in waves