We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
This idea carries a full system design question on its own. Each walks through the full answer.
System Design Masterclass · Api Design Protocols
Free preview: the first 2 parts of this 7-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Api Design Protocols
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
You launch an API. 500 developers integrate with it. Six months later, you need to change the response structure, rename a field, remove a deprecated property, change a data type. If you deploy the change, 500 applications break overnight.
This is the API versioning problem. Once an API is public, every response format and behavior becomes a contract. Changing that contract without warning is like a bank changing your account number without telling you, everything connected to it breaks.
API versioning lets you evolve your API while keeping old consumers working. You introduce a new version (v2) with the changes you need, while v1 continues to function exactly as before. Consumers migrate on their own schedule. Nobody breaks.
Stripe, GitHub, Twilio, Google, every serious API provider has a versioning strategy. It's not a technical luxury; it's a business necessity. Breaking your consumers' integrations is the fastest way to lose them.
1. URL path versioning (most common):
GET /api/v1/users/123
GET /api/v2/users/123
Pros: Explicit, easy to understand, easy to route. Cons: URL changes when version changes, cache keys differ per version.
2. Header versioning:
GET /api/users/123
Accept: application/vnd.myapi.v2+json
Pros: Clean URLs, version is metadata not resource identity. Cons: Less visible, harder to test in a browser, easy to forget the header.
3. Query parameter versioning:
GET /api/users/123?version=2
Pros: Simple to add. Cons: Mixes versioning with query logic, easy to omit.
4. Date-based versioning (Stripe's approach):
Stripe-Version: 2024-12-01
Stripe pins each API key to the version that existed when the key was created. Changes are rolled out by date. Your integration uses the API as it existed on the date your key was created, unless you explicitly update.
| Strategy | Used By | Tradeoff |
|---|---|---|
| URL path (/v1, /v2) | GitHub, Twitter, Google | Most explicit, URL changes |
| Header | Microsoft, GitHub (alt) | Clean URLs, less visible |
| Query param | Amazon (some APIs) | Simple, easy to overlook |
| Date-based | Stripe, Shopify | Smooth rollout, complex implementation |