API versioning
API versioning makes changes plannable for existing users. Compatible extension, parallel operation and replacement each need clear rules.
- Compatible changeOld users work unchanged.
- Breaking changeBreaking existing users.
- Tolerant ReaderUsers ignore unknowns.
Context
Why this is important
If an interface changes its meaning unannounced, existing users break. Compatible extensions and planned transitions keep changes manageable. The current content is the subject of API contracts.
This building block explains the development of existing interfaces. For their current content, see API Contracts.
At a glance · Two versions side by side
Does this change break users?
The warehouse module extends the reservation response with expiresAt. Later, the existing field available should change from a number to a business availability level.
This is how you read the picture
- Compatible change The judgment is compatible, for example with optional expiresAt.
- Breaking change The judgment breaks users, for example, when removing available.
- Tolerant Reader The judgment only with Tolerant Reader for a new status value or error code.
Reservation response of the camp
CompatibilityOptional field extendsAt
Old users ignore the unknown field and continue reading as before.
→ Publish as a secondary version
Further develop the reservation agreement
- v1
Existing contract
reservationId and available as a number
- v1.1
Compatible complement
optional expiresAt; old users read on
- Transition
Observing usage
Order takes over expiresAt
- v2
Changes in meaning
AvailabilityLevel replaces Available
- Replacement
v1 consumer ended
Remove old variant after proof
Benefits & limitations
Helps if:
- Incompatible contract changes can be migrated controllably with versioning and parallel operation.
- Usage measurement shows which older consumers are still active and when a replacement becomes viable.
- An explicit new contract version keeps changes in meaning separate from existing assumptions.
Boundaries
- Parallel versions increase maintenance and security work; measure usage and schedule retirement.
- Additive changes can change meaning; check real user assumptions instead of just schema compatibility.
- Retirement needs fallback and migration plans. Data Migration covers stored data; API Contracts protects behavioural guarantees.
In practice
- Assess schema and semantic changes and classify their compatibility. Additive structural changes and changes in meaning need different migration paths.
- Introduce new contract versions alongside existing ones and measure consumer usage. Define owners, a schedule and a fallback option for retirement.
- Remove old versions only after verifying migration. API Contracts defines observable behaviour; Data Migration covers stored data.
Read the detailed explanation
Versioning makes incompatible contract changes explicit and gives providers and consumers a migration path. Compatibility includes data structure and business meaning; an unchanged type does not guarantee unchanged semantics.
Additive extensions often support parallel operation, while removing or reinterpreting fields may break existing consumers. Usage measurements show when an older contract version can be retired.
API Contracts defines the observable behaviour that should remain stable; Data Migration addresses the separate evolution of stored structures.
Semantic Versioning expresses compatibility through version numbers. A Tolerant Reader ignores unknown fields, making additive extensions easier to accommodate.
Check your understanding
Test yourself in three stages
ReadingCheck in the picture
What judgment does the optional field diesAt carry, and what action follows?
View the solution with justification
Compatible. Old users continue to read; the change appears as a secondary version.
ApplyingTransferred to a new situation
The camp changes the meaning of available, the field remains the same. Are users breaking?
View the solution with justification
Yes, as a silent break: data type and name remain, but users misinterpret the value. Introducing a new field instead of re-interpreting the old one.
EvaluateWeighing an alternative
A new status value is to be added. What are you doing?
View the solution with justification
Advantage: small, additive change. Risk: Users without Tolerant Reader break into unknown values. Recommendation: Check users in advance and record the tolerance in the contract.
Explore further
These building blocks continue the thoughts of this page.
References
- Google AIP-185 · API Versioning (opens in new tab)Defines rules for versioning and stability of public APIs.
- Google AIP-180 Backwards Compatibility (opens in new tab)Explains compatible changes and breaks of API contracts.
- Microsoft · Web API Design (opens in new tab)Covers resources, HTTP behavior, and versioning decisions.