LearnThatStack Ace your next interview
API Design · question
Question 81 of 110

What are the challenges of API deprecation and how do you manage them?

expert Pro
← All API Design questions

The full answer covers the core mechanics, when this pattern wins, and the trade-offs interviewers most often probe. It includes a code sample. Read it once at your own pace, then try to recall the structure from memory before the interview. Pro also includes this question's interview lens - the likely follow-up probes and what you can say in the room.

Full answer + code samples + AI explanations

Unlock to read the complete answer for this premium question.

Guided practice for API Design One question at a time. Answer out loud, get graded, see what you missed.
Related concept

Versioning an API: changing the contract you already published

Only a breaking change needs a new version, and most changes are additive. The deprecation lifecycle matters far more than where the version number goes.

For this question · chapter 3 of 3

3/3 Sunset is a lifecycle, not a date
deprecationSunset is a lifecycle, not a dateannounce, measure, sunset, chase/v1410 Gonecalls a day0080k/v2answeringcalls a day019020kwhat /v1 answers withDeprecation: @1788220800Link: rel="deprecation"Sunset: Wed, 31 Mar 2027Link: rel="successor-version"migration guidename is now full_namelinked from every responsecallers still on /v1k_a4128k/dayk_b0717k/dayk_c196k/dayk_d553k/dayk_e021k/dayk_f8820k/dayk_g139k/dayk_h745k/dayk_j263k/dayacme-prod4k/daybilling3k/daypartner-x1k/day
deprecationSunset is a lifecycle, not a dateannounce, measure, sunset, chase/v1410 Gonecalls a day0080k/v2answeringcalls a day019020kwhat /v1 answers withDeprecation: @1788220800Link: rel="deprecation"Sunset: Wed, 31 Mar 2027Link: rel="successor-version"callers still on /v1keys030no calls leftacme-prod, billing, partner-x

Sunset is a lifecycle, not a date

  1. Running /v1 and /v2 at the same time is normal for a healthy API. Two live versions are not a failure. Right now, all 100k calls a day still go to /v1. The question is never whether to run two versions. The question is how you get back to running one.
  2. A blog post is not a deprecation. Every /v1 response now includes a Deprecation header and a link to the migration guide. The header's value is an RFC 9745 date that says when /v1 was deprecated. A client library can read that header and warn its own users, so warning users is no longer only your job.
  3. Measuring usage is the step people skip. Skipping it is why a removal turns into an outage. Now you can see how many calls each of the twelve API keys sends a day. You cannot honestly name a sunset date, the day the old version stops working, until you can see who still uses the old version.
  4. The sunset date comes after the traffic measurement, never before. The Sunset header now names the day /v1 stops answering. Five callers move to /v2, so /v1 traffic drops from 100k calls a day to 45k. Now the date is a promise you can keep, because you can see exactly who the date affects.
  5. An email moves the last few callers faster than any header will. Four more callers have moved off /v1. So /v1 now gets only 8k calls a day, from three keys: acme-prod, billing and partner-x. Those keys are no longer anonymous traffic. They are three teams, and each team gets an email.
  6. A late caller now gets an explanation instead of a timeout, because the old /v1 answers 410 Gone. The 410 response also includes a link to the version that replaces /v1. The lifecycle starts with announce and measure, then sunset and chase. Removal of /v1 comes last, and only once traffic to /v1 is zero.
Chapter 3 · step 1 of 6

Running /v1 and /v2 at the same time is normal for a healthy API. Two live versions are not a failure. Right now, all 100k calls a day still go to /v1. The question is never whether to run two versions. The question is how you get back to running one.

1 of 6 Use ← → or swipe See the concept: all 3 chapters in it

© LearnThatStack - diagrams may not be republished without permission.

Want a quick review of the fundamentals? See the API Design cheatsheet.

← Back to all API Design questions
Pro · $10/mo

90 of 110 API Design answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime