Quick revision
The short answer
In each state, the server exposes the allowed transitions as links or affordances, so partners act on what the server offers instead of hardcoding the state machine; when a transition rule changes, the links change and partners need no release. For this to work, partners must be built to follow stable, documented link relations in a media type such as HAL or HAL-FORMS, the documentation describes relations rather than URLs, contract tests or SDKs interpret the links, and a simpler fallback is offered to partners who are not ready.
What to remember
In this answer, we used hypermedia controls to cut the coordination cost of a partner workflow whose transitions change every quarter. The server exposes the allowed transitions in each state as links or HAL-FORMS affordances, enforces them on every call, and documents stable relations rather than URLs. To make it work, partners need link-following clients, so we provide SDKs and contract tests, and we keep a simpler fallback for partners who are not ready.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
In each state, the server exposes the allowed transitions as links or affordances, so partners act on what the server offers instead of hardcoding the state machine; when a transition rule changes, the links change and partners need no release. For this to work, partners must be built to follow stable, documented link relations in a media type such as HAL or HAL-FORMS, the documentation describes relations rather than URLs, contract tests or SDKs interpret the links, and a simpler fallback is offered to partners who are not ready.
Why this question is asked
A partner-facing workflow that changes every quarter is where hypermedia finally earns its reputation. Each change to the rules, a new review step or a transition that is no longer allowed, normally means a coordinated release with every partner, and partners are slow and expensive to coordinate with. Interviewers ask this design question to see whether a candidate can apply HATEOAS where it truly helps and also name what has to be true for it to work. In this answer, we will look at the cost of hardcoded state machines, design the hypermedia controls, see the Spring code, define the contract around relations, and deal with partners of different maturity.
1Why Hardcoded State Machines Are Expensive
A state machine is the set of states an application can be in (submitted, under review, approved, rejected) and the transitions allowed between them. If each partner encodes it in their own code, for example showing an approve button whenever the status is UNDER_REVIEW, every change to the rules must be implemented by every partner. Suppose next quarter an application under review can also be sent back for more information, and approval requires a completed risk check. Without hypermedia, we email 40 partners, wait months for their releases, and meanwhile some of them call transitions that are no longer allowed and get errors.
2Exposing Transitions as Links and Affordances
With hypermedia controls, the server decides in each response which transitions are possible right now and includes a control for each. A link carries a relation name and a URL. An affordance goes further: it also describes the HTTP method and the input fields the action needs, so a client can build the request without hardcoding its shape. HAL-FORMS is a media type that adds such templates to HAL.
| State | Controls the server includes |
|---|---|
| SUBMITTED | acme:start-review, acme:withdraw |
UNDER_REVIEW | acme:request-info, acme:approve (only if risk check done), acme:reject |
INFO_REQUESTED | acme:provide-info, acme:withdraw |
| APPROVED | none (final) |
| REJECTED | acme:appeal (new this quarter) |
The partner's code no longer asks whether status equals UNDER_REVIEW; it asks whether the acme:approve control is present. When the rules change next quarter, the server starts or stops sending controls and the partner's behaviour follows, with no partner release.
3Building It With Spring HATEOAS
Spring HATEOAS supports HAL-FORMS once it is enabled, and affordances are attached to links with afford(methodOn(...)). The transition rules stay in one place on the server, in the domain model.
The server also enforces every transition when it is called: a partner that posts to an approval URL anyway receives 409 Conflict with a problem details body. Links guide clients; they are never the security boundary.
4The Contract: Relations, Not URLs
Hypermedia moves the contract from URLs to link relations. So we publish and keep stable the relation names, their meaning, the HTTP method and the input each one expects, and the media type. Relations are namespaced, here acme:approve, and each one links to documentation (in HAL, CURIEs map the acme prefix to a documentation URL). URLs, by contrast, are documented as opaque: partners must take them from responses and never construct them. This lets us restructure paths, split services or move hosts without breaking anyone.
Adding a new relation, such as acme:appeal, is an additive change. Removing a relation that partners rely on, or changing its meaning, is a breaking change and follows the versioning policy.
5What Needs to Be in Place, and a Fallback
This design only reduces coordination if partners actually build link-following clients, and many partners are used to generated clients that call fixed URLs. So we help them: a reference SDK in a couple of languages that reads controls and exposes methods such as availableActions() and perform("acme:approve"), example code, and contract tests that check our responses always include the controls promised for each state.
We also accept that adoption depends on partner engineering maturity. Some partners will keep hardcoding. For them we keep the URLs stable for a long time, include the status field, and announce rule changes with notice. The partners that do follow links get quarterly changes for free; the others are no worse off than before.
5 messages in order. Play them, or step through them one at a time.
6Follow-up questions
What if a partner calls a transition that is not offered?
The server checks every transition against the current state and rules, regardless of links, and rejects an invalid one with 409 Conflict and a problem details body explaining why. Links are guidance for well-behaved clients, and the server remains the authority.
Why HAL-FORMS and not plain HAL?
Plain HAL tells the client where it can go but not how to call it or what to send. HAL-FORMS adds the method and input fields, which lets a partner client build forms or requests for new transitions with less custom code. If partners only need to know whether an action is available, plain HAL links are enough.
How do you test that the controls are right?
With contract tests that set up an application in each state and assert which relations are present and absent, and with partner SDK tests that drive full workflows only through links.
7Conclusion
In this answer, we used hypermedia controls to cut the coordination cost of a partner workflow whose transitions change every quarter. The server exposes the allowed transitions in each state as links or HAL-FORMS affordances, enforces them on every call, and documents stable relations rather than URLs. To make it work, partners need link-following clients, so we provide SDKs and contract tests, and we keep a simpler fallback for partners who are not ready.
Open with
This is a case where hypermedia really helps, because the state machine changes every quarter and partners are expensive to coordinate. Instead of partners hardcoding which actions are allowed in each status, the server includes in every response a control for each transition that is allowed right now, like acme:request-info or acme:approve, and omits the ones that are not, for example approve before the risk check is done.
Then, if they want more
With HAL-FORMS those controls also carry the method and input fields. Partners then ask whether a control is present, not whether the status equals something, so when we add or remove transitions, their behaviour follows without a release. The server still validates every transition and returns 409 for invalid ones.
For this to work, the contract moves from URLs to link relations: we publish stable, namespaced relation names with their meaning, method and input, document URLs as opaque, and treat adding a relation as additive and removing one as breaking. We would provide reference SDKs that interpret the controls, and contract tests that check which relations appear in each state.
And because adoption depends on partner maturity, we keep URLs stable and a status field for partners who keep hardcoding, as a fallback.
About this answer
- Last updated
- 12 November 2026
- 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.
- Official documentation
- Spring Framework reference, Spring Web MVC
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 "A partner-facing workflow API (application submitted, under review, approved, rejected)...": https://scrivio-interview-library.netlify.app/spring-boot/rest-api-design/76e4b3fe30/