Designing HTTP APIs · mid
Versioning and evolving an API
Most API changes should be additive so old clients keep working; when you must break the contract, publish a new version (usually /v2 in the path), announce deprecation with headers and dates, and keep the old version until clients, including old mobile app builds, have moved.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Non-breaking: adding an optional field, a new endpoint, a new optional query parameter. Breaking: removing or renaming a field, changing a type or meaning, making an optional input required, changing status codes or error shapes.
- Version styles: URL path (/v1/orders, the most common and easiest to route and cache), a header (Accept: application/vnd.example.v2+json, or a date like Stripe's API versions), or a query parameter.
- Mobile apps make this harder: old app versions stay installed for months, so the API must support several client versions or force an upgrade.
- Deprecation: document it, send Deprecation and Sunset headers (RFC 9745 and RFC 8594), log which clients still call the old version, then remove it.
- Tolerant readers: clients should ignore unknown fields; servers should not reject unknown optional fields unless strict validation is a goal.
- Write the contract down (OpenAPI) and test it in CI so accidental breaking changes fail the build.
The red pen
Common traps: mistake → fix
Mistake: Renaming a field is a small change
Fix: it breaks every client that reads the old name.
Mistake: Every change needs a new version
Fix: additive changes do not; versions are expensive to keep running.
Easy to hard
Questions interviewers ask, easy to hard
- How do you version an API?
- Which changes are breaking?
- How do you retire v1 when old mobile app versions still call it?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.