Once an API is published, it no longer belongs only to the server team. Mobile apps, partner systems, integration services, and customers' own software all connect to this contract. Changing the domain name, removing a response field, or changing the meaning of an error code may look like a small tweak on the server, but it can turn into a production failure for existing clients.
API versioning is a version management approach that keeps existing clients running when breaking changes are needed and lets new clients move to the new contract in a controlled way. Still, opening a new v2 for every change is not the right answer either. First, you should determine which changes are backward compatible and which ones break existing client behavior.
This guide does not repeat the general API-first approach. The focus is on versioning strategies, backward compatibility, breaking changes, deprecation, sunset, and client migration operations.
What Is API Versioning?
API versioning is a way to define different contract versions of the same API product and clearly state which version a client is using. While the older version keeps running for a set period, the new version can offer different fields, behavior, or endpoint structure.
Google's API Improvement Proposals document stresses that APIs are contracts with users and that compatibility for clients running in production must be preserved Google AIP-180. The API versioning document covers creating a new major version for breaking changes in stable releases Google AIP-185.
What Does Backward Compatibility Mean?
Backward compatibility means the API's new form still lets existing clients work without changes. Adding a new optional field is often compatible. Removing an existing field, changing its type, or making it required is usually breaking.
Compatibility is not just about the JSON schema. If the meaning of a response field changes while the field itself stays, the client may technically parse it but produce the wrong business result. Ordering, pagination, default values, error codes, permission scope, and rate limit behavior are also part of the contract.
Which Changes Are Usually Backward Compatible?
- Adding a new optional field to the response.
- Adding a new endpoint or a new HTTP method.
- Adding a new value to an existing enum field when clients tolerate unknown values.
- Adding a new optional request parameter.
- Improving documentation and examples without changing current behavior.
- Improving performance while keeping response semantics intact.
- Adding new error details while keeping existing error codes.
The assumption that "adding a field is safe" depends on client quality. Some clients may reject unknown fields or treat enum values as a closed list. That is why the API contract should clearly state how clients should handle unknown fields and values.
Which Changes Count as Breaking Changes?
| Change | Why It May Break | Safer Approach |
|---|---|---|
| Removing a field | The existing client keeps reading the field | Mark it deprecated first, add a new field, and allow a transition period |
| Changing a field type | The parser or type system throws an error | Add a new field name or open a new major version |
| Making an optional field required | Existing requests get a validation error | Keep the default behavior or make it required in a new version |
| Removing an enum value | Existing workflows become invalid | Keep supporting the value and retire its use gradually |
| Changing an HTTP status code | Client retry or error handling breaks | Keep the current code in the old version |
| Changing a pagination assumption | Records may be skipped or repeated | Use a new parameter or a new version |
| Changing a field's meaning | The schema looks the same, but the business result is wrong | Release a new field or an explicit new version |
How Is an API Version Shown in the URL?
URL path versioning is the most visible method: /v1/orders and /v2/orders. It is easy to follow in documentation, routing, log analysis, and gateway policies. The client can clearly see which version it is using from the URL.
The downside is that the version becomes part of the source address and is repeated across every endpoint. Opening a new path for small changes can quickly grow the API surface. Even so, it remains a popular choice for REST APIs offered to external developers because of its simplicity.
How Does Versioning with a Query Parameter Work?
The client sends a parameter such as /orders?api-version=2026-07-01 or ?version=2. Azure services include examples where API behavior is selected with a date or version parameter. Microsoft explains that versioning schemes in Azure API Management can be defined through path, header, or query Azure API Management Versions.
Query versioning keeps the existing resource URL; however, the cache key, proxy configuration, and documentation must be set up correctly. When the parameter is skipped, it should not be left unclear which version will be used.
When Does Versioning with a Header Make Sense?
The version can be sent in a custom header or a media type. This keeps the resource URL unchanged and allows a structure similar to content negotiation. However, it is not as visible as a path in the browser, debugging, curl examples, or manual testing.
If a header-based model is chosen, the header name, default version, cache behavior, and gateway routing should be standardized. Forgetting to send the header should not silently send the client to the wrong version.
What Is Date-Based API Versioning?
Date-based versioning defines the version by its release date, such as 2026-07-01. The client clearly states which contract date it depends on. On platforms that release often, this method can offer more detailed control than semantic v1, v2 names.
Stripe manages API versions by date and release name, letting clients test the new version and upgrade in a controlled way Stripe API Versioning. Stripe's versioning policy explains a model of monthly compatible changes and breaking version families released at set intervals Stripe Versioning Policy.
Which Versioning Strategy Should You Choose?
| Strategy | Strength | Weakness | Best fit |
|---|---|---|---|
| URL path | Clear, visible, and easy to route | Ties the source URL to the version | Public REST APIs and partner integrations |
| Query parameter | Keeps one path; date-based versions are easy | Caching and the default version need attention | Cloud services and date-based APIs |
| Header | Keeps URLs clean; version choice is separate | Debugging and documentation are more complex | A controlled client ecosystem |
| Media type | The representation version can be chosen explicitly | The developer experience can feel heavier | Advanced content negotiation needs |
| Pinned version per account/client | Old integrations never change silently | Requires version visibility and support operations | Payment and SaaS platforms |
What matters more than technical feasibility is the developer experience and operational capacity. When planning an API integration service, how clients choose, test, and upgrade versions should be designed together.
When Should a New Version Be Released?
A new major version should be introduced for breaking changes that cannot be shipped while preserving the existing contract. Renaming a field, changing the response model from the ground up, renewing the authentication flow, or splitting the resource structure are examples.
Opening a new version for every feature increases support costs. Compatible additions can ship in the same version. Before deciding on a new version, first assess whether the migration is possible through an adapter, a new optional field, a new endpoint, or a feature flag.
How Are Old and New Versions Managed in the Same Codebase?
The riskiest approach is copying the entire application for v1 and v2. Copies drift apart over time, security fixes get missed in one version, and maintenance costs rise. A healthier model keeps the shared domain and business rules intact, with version-specific request/response adapters at the outer boundary.
- Separate the domain model from version DTOs.
- Validate v1 and v2 request models separately.
- Share common use cases wherever possible.
- Perform response transformation in the version adapter.
- Keep version-specific behavior explicit and testable.
- Apply security and bug fixes to every supported version.
What Is Deprecation?
Deprecation signals that an API version, endpoint, or field is no longer recommended for new integrations, while it still works. The goal is to offer clients an alternative and give them time to migrate. Deprecation behavior should not change suddenly.
RFC 9745 defines the Deprecation header field, which signals in an HTTP response that a resource is deprecated, along with the link relation to further documentation RFC 9745. This signal provides visibility at the runtime level; however, it does not replace communication by email, dashboard, or documentation.
What Is Sunset?
Sunset is the planned date when an old version will stop serving requests. RFC 8594 defines the Sunset HTTP header field to announce the time when a URI will no longer be accessible in the future RFC 8594.
Deprecation is the "stop using this" message; sunset is the "it will stop working after this date" notice. The sunset date should be set based on realistic support capacity, contracts, critical clients, and migration complexity.
How Do You Find Old Clients?
The first step of a migration plan is knowing which client uses which version. The API key, OAuth client, tenant, SDK user-agent, and version info should be correlated in the logs. The overall share of v1 traffic is not enough; you need to know whether the remaining calls belong to a critical customer or an abandoned cron job.
- Measure requests and active clients per version.
- Record the last-use date per client.
- Report deprecated endpoint usage separately.
- Monitor 4xx and 5xx rates per version.
- Identify API keys with no contact owner.
- Link the mobile app version to the API version.
How Do You Prepare a Client Migration Plan?
- Publish the new version and the list of breaking changes.
- Prepare a migration guide covering old and new behavior.
- Provide access to a test or sandbox environment.
- Update SDKs and sample code for the new version.
- Announce the deprecation date and support scope.
- Contact active clients directly based on usage data.
- Track migration progress with dashboards and reports.
- Increase warning frequency gradually before the sunset.
- Provide hands-on migration support for critical customers.
- After sunset, return a controlled error response with a link to the documentation.
Why Is Versioning Harder in Mobile Apps?
A web client can be updated instantly alongside the server, while a mobile app can stay on an old version for months due to store review, user update behavior, and older devices. The API team should not assume it only supports the latest mobile version.
Mobile client version, the minimum supported app version, and the API version are separate concepts. A critical security issue may require a forced app update; during a normal API migration, the plan should keep the old app running for a set period.
How Should Webhook Versions Be Managed?
A webhook endpoint can follow a different lifecycle than the API's request-response calls. When the provider ships new event fields or behavior, an existing webhook handler can break. The event/API version each webhook endpoint depends on should be recorded clearly.
New versions should be validated on a test endpoint, and event schemas should be exercised with fixtures and contract tests. Old and new webhook versions can run in parallel for a short time, but event identity and idempotency must be preserved so the same job event does not produce side effects twice.
Why Does Contract Testing Matter?
A unit test validates the server's own code, while a consumer-driven contract test checks whether real client expectations still hold after an API change. Contract pieces such as response fields, status codes, enums, and error schemas can be compared in the CI process.
Breaking change analysis can be run between OpenAPI schemas. However, because the schema can look compatible while the semantics change, critical workflows should also be verified with integration tests. In software development, versioning checks should become an automatic gate before release.
Most Common API Versioning Mistakes
- Opening a new major version for every small feature.
- Shipping a breaking change silently under the same version.
- Changing the default version without notice.
- Duplicating old and new version code entirely.
- Removing a deprecated field without measuring its actual usage.
- Publishing only a changelog instead of a migration guide.
- Ignoring the slow migration of mobile and webhook clients.
- Not validating the sunset date with technical and business stakeholders.
- Not defining a security fix policy for old versions.
- Not making version selection visible in logs and metrics.
API Versioning Checklist
- Is the change truly breaking, or can it be added in a backward-compatible way?
- Is the client version explicitly selected through URL, query, header, or account settings?
- Is the default version behavior documented?
- Do old and new contracts pass automated contract tests?
- Is the support and security fix period defined for each version?
- Is deprecated endpoint usage measured per client?
- Are the migration guide, SDK, and sandbox ready?
- Are deprecation and sunset signals delivered at runtime and through communication channels?
- Has the transition time for mobile apps and webhooks been accounted for?
- Have the post-sunset error response and support routing been planned?
Conclusion: An API Version Is a Support Contract, Not a Technical Label
API versioning keeps your product moving forward while protecting existing clients. The healthy approach is to release backward-compatible changes in the current version, and for truly breaking changes, create a new version and retire the old one with a measurable transition plan.
Whichever method you choose—URL, query, header, or date-based—the real quality shows in your backward compatibility rules, client visibility, contract tests, deprecation communication, and a realistic sunset policy. Version management is not just routing; it is long-term integration trust.
Improve Your API Without Breaking Existing Integrations
By clarifying versioning, backward compatibility, migration, and sunset processes before development begins, you can protect your customers from forced and unplanned transitions.
Evaluate Your API Architecture with WebiooFrequently Asked Questions
Should every API change get a new version?
No. Backward-compatible changes, such as new optional fields or endpoints, can be released in the current version. Changes that would break existing clients require a new major version.
Which is better: URL path versioning or header versioning?
There is no universal winner. For public APIs, the path is visible and simple; in controlled client ecosystems, a header can keep URLs cleaner. Developer experience and operational structure decide it.
Are API deprecation and sunset the same thing?
No. Deprecation indicates that a version is no longer recommended but still works. Sunset is the planned date on which the service will be shut down.
Is adding a new field to a response a breaking change?
It is usually backward-compatible; however, it can cause issues if clients reject unknown fields or treat enum values as a closed list. Client tolerance should be defined in the contract.
How long should an old API version be supported?
There is no universal period. Customer contracts, mobile update cycles, critical integrations, security costs, and transition complexity should all be considered together.
What should be measured before an API version is retired?
Active client count, last usage date, critical customer traffic, deprecated endpoint usage, error rate, and migration progress should all be measured per client.
