Scrivio Interview library
DesignAdvanced5 min read · updated 12 November 2026

Your API platform versions REST APIs through URL paths, headers and custom media types depending on the team. Would you adopt Spring 7 API versioning as the standard, and how?

I would adopt Spring 7 API versioning as the implementation inside Spring services, but the real standard is a single organisation-wide resolution strategy that gateways, documentation and clients all agree on, because mixed strategies confuse everyone. Next to it we need a deprecation and sunset policy with dates and response headers, a strong preference for additive, backward-compatible changes so new versions are rare, and a pilot on one API with per-version OpenAPI documents before mandating it.

Why this question is asked

An API platform where some teams version by URL path, some by header and some by custom media type is hard to use from the outside. A client developer has to learn three conventions, the gateway needs three kinds of routing rules, and documentation tools show versions in three different ways. Spring Framework 7 now offers built-in versioning, and it is tempting to declare it the standard. Interviewers ask this design question to see whether we separate the organisational decision from the framework feature. In this answer, we will see why one strategy matters more than the tool, choose a strategy, define the deprecation policy, reduce how often we need versions at all, and plan a pilot and rollout.

1Why One Strategy Matters More Than the Tool

A version strategy is part of the public contract. Clients put it into their code, gateways route on it, caches key on it and documentation is organised by it. If teams choose differently, every one of those consumers must handle every style, and a client calling four of our APIs writes four kinds of version logic.

Spring 7's versioning reduces hand-made routing code: instead of custom request conditions or duplicated controllers, a mapping declares version = "1.2" and the framework resolves it. But it only works inside Spring services. Our gateway, our API portal, our non-Java services and our client SDKs must follow the same strategy, so the decision has to be made at the platform level first, and Spring becomes how Spring services implement it.

2Choosing the Strategy

Each strategy has a cost, and the table shows the trade-offs we discuss with the teams. For a platform with external clients, HTTP caches and a gateway, the URL path, for example /v2/orders, is usually the most practical, because the version is visible in logs, routable by any gateway and part of every cache key. A header keeps URLs stable and is a fine choice for an internal platform where caches and gateways are under our control, as long as every response that varies by version sends a Vary header.

Version strategies for the whole platform
StrategyStrengthsCosts
Path segment /v2/ordersvisible, cache key, easy gateway routingURLs change between versions
Header API-Version: 2stable URLs, clean resourcesneeds Vary, header-aware gateway rules
Query ?version=2easy to try in a browsermixes with filters, easy to forget
Media type parametermost RESTful in theoryhard for tools, clients and docs
Whichever we choose, the important part is that every team uses the same one.

3A Deprecation and Sunset Policy With Dates

A version number alone tells a client nothing about how long it can wait. The policy should say how long a version is supported after its successor ships, for example at least 12 months for external APIs and 6 months for internal ones, and how clients are told. Spring 7 can attach deprecation information to responses; headers such as Deprecation, Sunset with the removal date and a Link to the migration guide let clients detect it automatically. Confirm the supported mechanism in the reference docs for your version.

The policy also needs evidence. We log the version of every request through a tag on the request metrics, so before a sunset date we know exactly which clients still call the old version and can contact them, rather than discovering them by breaking them.

Java
HTTP/1.1 200 OK
API-Version: 1.1
Deprecation: @1767225600 # deprecated since 2026-01-01 (RFC 9745 date format)
Sunset: Thu, 31 Dec 2026 23:59:59 GMT # removed after this date
Link: <https://api.acme.example/docs/migrate-1.1-to-2.0>; rel="deprecation"
Vary: API-Version

Notice the Vary header: when the version is in a header, it tells caches that the same URL can return different bodies.

4Making New Versions Rare

The cheapest version is the one we never create. Most changes can be additive: a new optional field, a new endpoint, a new enum value that clients are told to tolerate. The standard should require teams to try that first, document a tolerant reader rule for clients, which means ignoring unknown fields, and reserve a new version for changes that cannot be made compatible, such as changing the meaning of a field. A platform that ships one breaking version per API every two or three years is healthier than one with v7 after eighteen months.

5Piloting and Rolling Out

Before mandating anything, we pilot with one API that genuinely needs a second version. The pilot proves the Spring configuration, the gateway rules, and the documentation: we generate one OpenAPI document per version, so the portal shows v1 and v2 side by side. We also check the client side, for example that our RestClient-based SDK sends the version correctly.

Step throughFrom pilot to platform standard
  1. Choose the strategyplatform architects with gateway and docs owners
  2. Pilot one APISpring 7 versioning, gateway rule, OpenAPI per version
  3. Did clients, gateway and docs all work?
    YesPublish the standard and a starterNoAdjust the strategy or tooling
  4. New versions follow the standardexisting APIs move at their next breaking change
  5. Track versions per clientand enforce the sunset policy

5 steps in order. Play them, or step through them one at a time.

Existing APIs do not need to migrate immediately. A team moves to the standard the next time it needs a breaking change, so the mixed landscape shrinks without forcing rewrites that give clients nothing.

6Follow-up questions

Should the gateway or the service resolve versions?

Both have a role. The gateway routes by version when different versions live in different deployments, and it can reject unknown versions early. The service resolves the version again to choose the handler, because a single deployment usually serves several versions. Using the same strategy in both places is what keeps that simple.

What if a team insists its custom media type is needed?

I would ask what problem it solves that the standard does not. If it is a real need, such as content negotiation between formats, it can stay as a format concern while the version still follows the standard. A documented exception is better than a silent divergence.

How do you version events or messages, not just REST?

With a version field or a schema registry version in the message, and the same additive-first rule. The deprecation policy and dates should apply to event schemas too, since consumers of events are clients of the API just like HTTP callers.

7Conclusion

In this answer, we treated API versioning as a platform decision first and a framework feature second. We pick one resolution strategy for the whole organisation, often the URL path for external APIs, and use Spring 7 versioning to implement it inside Spring services while gateways and docs follow the same rule. A deprecation and sunset policy with dates and headers, a preference for additive changes, and a pilot with per-version OpenAPI documents make the standard work before we mandate it.

What to say in the interviewAbout 80 seconds aloud

Open with

I would adopt Spring 7 versioning, but as the implementation, not as the standard itself. The standard is one resolution strategy for the whole organisation, because mixed strategies confuse clients, gateways, caches and documentation.

Then, if they want more

For a platform with external clients I would usually pick the path segment, since the version is visible, part of the cache key and easy to route; for an internal platform a header is fine as long as we send Vary.

Spring 7 then removes the hand-made routing code inside Spring services, but the gateway, API portal and non-Java services must follow the same choice.

Next I would write a deprecation and sunset policy with dates, for example at least twelve months after a successor, and signal it with Deprecation, Sunset and Link headers, after checking which mechanism Spring supports in our version. We would tag request metrics with the version so we know who still calls an old one.

I would also push hard for additive, backward-compatible changes so new versions are rare. Before mandating it, I would pilot with one API that really needs a second version, generating an OpenAPI document per version and proving the gateway rules. Existing APIs move to the standard at their next breaking change.

About this answer

Last updated
12 November 2026
Versions it names
Spring Framework 7
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your API platform versions REST APIs through URL paths, headers and custom media types...": https://scrivio-interview-library.netlify.app/spring-boot/spring-framework-evolution/7f8b39d6a6/