API Versioning & Backward Compatibility
Design API versioning strategies that evolve gracefully without breaking existing consumers.
Activation Triggers
Activate on: "API versioning", "backward compatibility", "deprecation", "breaking change", "API migration", "v1 v2", "sunset header", "API evolution", "non-breaking change"
NOT for: Data schema evolution → schema-evolution-manager | Gateway version routing → api-gateway-reverse-proxy-expert | GraphQL deprecation → graphql-server-architect
Quick Start
- Classify the change — additive (safe), modification (maybe breaking), removal (breaking)
- Choose strategy — URL path (
/v2/), header (API-Version), or content negotiation
- Implement Sunset headers — RFC 8594 tells consumers when old versions die
- Run versions in parallel — minimum 6-month overlap for major versions
- Monitor adoption — track per-version traffic to know when to retire
Core Capabilities
| Domain |
Technologies |
| URL Versioning |
/api/v1/, /api/v2/ path-based routing |
| Header Versioning |
API-Version: 2024-01-15, Accept-Version |
| Content Negotiation |
Accept: application/vnd.myapi.v2+json |
| Deprecation |
Sunset header (RFC 8594), Deprecation header |
| Tooling |
OpenAPI 3.1 overlays, Optic, Bump.sh |
Architecture Patterns
Versioning Strategy Decision Tree
Is it additive only? (new fields, new endpoints)
├─ YES → No version bump needed (backward compatible)
└─ NO → Is it a field rename/type change?
├─ YES → Can you keep both old + new fields?
│ ├─ YES → Add new, deprecate old (minor version)
│ └─ NO → Major version bump (v1 → v2)
└─ NO → Is it a removal?
└─ YES → Major version bump with sunset period
Parallel Version Deployment
// Express router with version-based routing
import { Router } from 'express';
const v1Router = Router();
const v2Router = Router();
// v1: returns { name: string }
v1Router.get('/users/:id', async (req, res) => {
const user = await getUser(req.params.id);
res.json({ name: user.fullName }); // legacy shape
});
// v2: returns { firstName, lastName, displayName }
v2Router.get('/users/:id', async (req, res) => {
const user = await getUser(req.params.id);
res.json({
firstName: user.firstName,
lastName: user.lastName,
displayName: user.fullName,
});
});
app.use('/api/v1', v1Router);
app.use('/api/v2', v2Router);
// Sunset header middleware for v1
v1Router.use((req, res, next) => {
res.set('Sunset', 'Sat, 01 Nov 2026 00:00:00 GMT');
res.set('Deprecation', 'true');
res.set('Link', '</api/v2>; rel="successor-version"');
next();
});
Date-Based Versioning (Stripe Model)
API-Version: 2026-03-15
Changes are tied to dates, not integers:
2026-01-01 → baseline
2026-03-15 → renamed `name` → `display_name`
2026-06-01 → removed `legacy_field`
Server pins unversioned requests to the account's default version.
Each version is a transform layer over the canonical internal model.
Anti-Patterns
- Versioning too eagerly — most changes are additive and do not require a version bump; add fields freely
- No sunset timeline — deprecating without a concrete shutdown date means versions live forever
- Copying entire controllers — use a transform/adapter layer, not duplicated business logic per version
- Ignoring unknown fields — APIs should be tolerant readers; ignore unknown fields on input (Postel's Law)
- Breaking changes in minor versions — if consumers relied on it, removing it is breaking regardless of your intent
Quality Checklist
1---2license: Apache-2.03name: api-versioning-backward-compatibility4description: "API migration strategies, deprecation workflows, and header/URL/content versioning. Activate on: API versioning, backward compatibility, deprecation, breaking change, API migration, v1 v2, sunset header. NOT for: schema evolution in data (use schema-evolution-manager), gateway routing (use api-gateway-reverse-proxy-expert)."5allowed-tools: Read,Write,Edit,Bash(npm:*,npx:*)6category: Backend & Infrastructure7tags:8 - api-versioning9 - backward-compatibility10 - deprecation11 - migration12 - semver13pairs-with:14 - skill: api-gateway-reverse-proxy-expert15 reason: Gateway handles version-based routing16 - skill: schema-evolution-manager17 reason: Data schema evolution parallels API versioning18 - skill: graphql-server-architect19 reason: GraphQL has its own deprecation model via @deprecated20metadata:21 source: https://skillmd.com/skills/curiositech/api-versioning-backward-compatibility22---2324# API Versioning & Backward Compatibility2526Design API versioning strategies that evolve gracefully without breaking existing consumers.2728## Activation Triggers2930**Activate on:** "API versioning", "backward compatibility", "deprecation", "breaking change", "API migration", "v1 v2", "sunset header", "API evolution", "non-breaking change"3132**NOT for:** Data schema evolution → `schema-evolution-manager` | Gateway version routing → `api-gateway-reverse-proxy-expert` | GraphQL deprecation → `graphql-server-architect`3334## Quick Start35361. **Classify the change** — additive (safe), modification (maybe breaking), removal (breaking)372. **Choose strategy** — URL path (`/v2/`), header (`API-Version`), or content negotiation383. **Implement Sunset headers** — RFC 8594 tells consumers when old versions die394. **Run versions in parallel** — minimum 6-month overlap for major versions405. **Monitor adoption** — track per-version traffic to know when to retire4142## Core Capabilities4344| Domain | Technologies |45|--------|-------------|46| **URL Versioning** | `/api/v1/`, `/api/v2/` path-based routing |47| **Header Versioning** | `API-Version: 2024-01-15`, `Accept-Version` |48| **Content Negotiation** | `Accept: application/vnd.myapi.v2+json` |49| **Deprecation** | Sunset header (RFC 8594), Deprecation header |50| **Tooling** | OpenAPI 3.1 overlays, Optic, Bump.sh |5152## Architecture Patterns5354### Versioning Strategy Decision Tree5556```57Is it additive only? (new fields, new endpoints)58 ├─ YES → No version bump needed (backward compatible)59 └─ NO → Is it a field rename/type change?60 ├─ YES → Can you keep both old + new fields?61 │ ├─ YES → Add new, deprecate old (minor version)62 │ └─ NO → Major version bump (v1 → v2)63 └─ NO → Is it a removal?64 └─ YES → Major version bump with sunset period65```6667### Parallel Version Deployment6869```typescript70// Express router with version-based routing71import { Router } from 'express';7273const v1Router = Router();74const v2Router = Router();7576// v1: returns { name: string }77v1Router.get('/users/:id', async (req, res) => {78 const user = await getUser(req.params.id);79 res.json({ name: user.fullName }); // legacy shape80});8182// v2: returns { firstName, lastName, displayName }83v2Router.get('/users/:id', async (req, res) => {84 const user = await getUser(req.params.id);85 res.json({86 firstName: user.firstName,87 lastName: user.lastName,88 displayName: user.fullName,89 });90});9192app.use('/api/v1', v1Router);93app.use('/api/v2', v2Router);9495// Sunset header middleware for v196v1Router.use((req, res, next) => {97 res.set('Sunset', 'Sat, 01 Nov 2026 00:00:00 GMT');98 res.set('Deprecation', 'true');99 res.set('Link', '</api/v2>; rel="successor-version"');100 next();101});102```103104### Date-Based Versioning (Stripe Model)105106```107API-Version: 2026-03-15108109Changes are tied to dates, not integers:110 2026-01-01 → baseline111 2026-03-15 → renamed `name` → `display_name`112 2026-06-01 → removed `legacy_field`113114Server pins unversioned requests to the account's default version.115Each version is a transform layer over the canonical internal model.116```117118## Anti-Patterns1191201. **Versioning too eagerly** — most changes are additive and do not require a version bump; add fields freely1212. **No sunset timeline** — deprecating without a concrete shutdown date means versions live forever1223. **Copying entire controllers** — use a transform/adapter layer, not duplicated business logic per version1234. **Ignoring unknown fields** — APIs should be tolerant readers; ignore unknown fields on input (Postel's Law)1245. **Breaking changes in minor versions** — if consumers relied on it, removing it is breaking regardless of your intent125126## Quality Checklist127128- [ ] Additive changes (new fields, new endpoints) ship without version bump129- [ ] Breaking changes require major version with 6+ month sunset period130- [ ] Sunset header (RFC 8594) set on deprecated versions131- [ ] Link header points consumers to successor version132- [ ] Per-version traffic monitored to track migration progress133- [ ] OpenAPI spec published per version with diff tooling (Optic/Bump.sh)134- [ ] Consumer notification plan: changelog, email, dashboard warning135- [ ] Version routing handled at gateway level, not in application code136- [ ] Integration tests validate backward compatibility (contract tests)