REST API Versioning: Strategies and Best Practices
REST API versioning ensures that existing clients continue to function reliably even as your API evolves.
Quick Summary
REST API versioning is the practice of managing changes to an interface without disrupting existing clients. Different strategies exist—most commonly implemented in the URL path, via headers, or through content negotiation. A solid versioning strategy defines clear rules for breaking and non-breaking changes, communicates deprecations early, and enables a smooth transition between versions. Versioning isn’t just a technical detail; it’s a cornerstone of API lifecycle management and your long-term relationship with API consumers.
Key REST API Concepts
Breaking vs. Non-Breaking Changes
Not every API change requires a new version. Adding optional fields, new endpoints, or additional query parameters is backward compatible and can be rolled out without versioning. Breaking changes—like removing fields, altering data types, or relocating endpoints—demand a new version to prevent existing clients from breaking.
URI Versioning
URI versioning embeds the version directly in the URL path, such as /v1/customers or /api/v2/orders. This is the simplest and most widely adopted approach because the version is immediately visible and works seamlessly with links, logs, and caching layers.
Header Versioning
Header versioning conveys the version through a custom header like api-version: 1 or Accept-Version: v2. The URL stays clean, but the version isn’t obvious at a glance. This works well when you want the API surface to remain independent of the URL structure.
Content Negotiation
Content negotiation uses the Accept header to signal version and format preferences—for example, Accept: application/vnd.shop.v1+json. This is powerful and flexible, but more complex to implement and harder for less experienced developers to understand.
Semantic Versioning
Semantic versioning, borrowed from software engineering, translates well to APIs. Major versions signal breaking changes, minor versions introduce backward-compatible features, and patch versions indicate bug fixes. For APIs, only the major version is typically exposed in the URL.
Deprecation and Sunset
When retiring an API version, mark it as deprecated. Give users early notice of the end-of-life date, provide migration guidance, and allow sufficient time for the transition. Headers like Sunset and Deprecation make the retirement date machine-readable.
Documentation Across Versions
Every version should have clear documentation, including a changelog, migration guide, and support timeline. Users need to quickly understand which version they’re using and what changes come with an upgrade.
Caching Considerations
Caching interacts with versioning in important ways. URL-based versions are cache-friendly because different versions get different URLs. With header versioning, be cautious—many caches key only on the URL and ignore headers, which can lead to incorrect cached responses.
Backward Compatibility
Backward compatibility means new versions don’t break older ones. Older versions remain accessible for their announced support period. Avoid killing old versions without giving users adequate warning.
Versioning as a Process
Versioning only works when embedded in your team’s workflow. You need clear rules for releases, code reviews, communication, and monitoring. Each version should have a defined owner and a clear lifecycle plan.
Real-World REST API Versioning Example
A SaaS provider runs a customer API. After two years, they decide to restructure address fields—a breaking change.
Old version v1:
GET /v1/customers/42
{
"id": 42,
"name": "Musterfirma GmbH",
"address": "Musterstraße 12, 10115 Berlin"
}
New version v2:
GET /v2/customers/42
{
"id": 42,
"name": "Musterfirma GmbH",
"address": {
"street": "Musterstraße 12",
"zip": "10115",
"city": "Berlin",
"country": "DE"
}
}
Communication to users:
HTTP/1.1 200 OK
Deprecation: true
Sunset: Sat, 31 Dec 2026 23:59:59 GMT
Link: </v2/customers/42>; rel="successor-version"
Existing clients can continue using v1 while they prepare for v2. The new version is clearly advertised, and the old version is retired in an orderly fashion.
FAQ: REST API Versioning
1. What is REST API versioning?
2. When does an API need a new version?
3. What’s the difference between URI and header versioning?
/v1/customers. Header versioning transmits it via a header such as api-version. URI versioning is more visible and caches better.4. What is content negotiation in APIs?
Accept header to agree on version and format. For example, Accept: application/vnd.shop.v1+json. It’s flexible but more complex than URI versioning.5. What does deprecation mean?
6. What is the Sunset header?
Sunset header communicates the planned end-of-life date for an API or version in a machine-readable format. It helps clients automatically detect when a version will no longer be available.7. Should you support many API versions in parallel?
8. What is a backward-compatible change?
9. What is a breaking change?
10. How do you document API versions?
11. What is semantic versioning?
12. How does versioning affect caching?
13. What is backward compatibility?
14. Should you specify API versions in OpenAPI?
info.version field. With URI versioning, the version is also often reflected in server URLs or path definitions.15. What role does versioning play in the API lifecycle?
Next in the API Learning Path
The next article in the API learning path covers REST API Error Handling: Status Codes and Error Objects — how to handle errors in APIs in a structured, standards-compliant, and client-friendly way.
Sources
- https://www.rfc-editor.org/rfc/rfc9110
- https://opensource.zalando.com/restful-api-guidelines/index.html
- https://developer.mozilla.org/docs/Web/HTTP/Headers/Accept
Recommended Books on API Development
If you want to dive deeper into API versioning, API design, and software architecture, we recommend the following books:
API Development
Books about API design, REST, GraphQL, OpenAPI and API architecture
Designing Data-Intensive Applications von Martin Kleppmann
Bei Amazon ansehenAffiliate-Link: Bei einem Kauf erhalten wir möglicherweise eine Provision.
API Design Patterns von JJ Geewax
Bei Amazon ansehenAffiliate-Link: Bei einem Kauf erhalten wir möglicherweise eine Provision.




