Implementing API Deprecation Strategies
1. Setting Deprecation Headers
Example: RFC 9745 Deprecation header
HTTP/1.1 200 OK
Deprecation: @1735689600
Sunset: Wed, 31 Dec 2025 23:59:59 GMT
Link: <https://api.example.com/v2/orders>; rel="successor-version"
Link: <https://docs.example.com/migrate-v1-v2>; rel="deprecation"
| Header | Standard |
|---|---|
Deprecation | RFC 9745 |
Sunset | RFC 8594 |
Link rel=successor-version | RFC 5829 |
2. Configuring Deprecation Warnings
Example: Warning header (RFC 9111 obsoleted, use custom)
HTTP/1.1 200 OK
X-API-Warning: Endpoint deprecated. Use /v2/orders. Removed 2026-01-01.
Deprecation: true
Sunset: Sat, 01 Jan 2026 00:00:00 GMT
3. Implementing Sunset Dates
| Phase | Timeline |
|---|---|
| Deprecation announced | T-0 (deprecation header on) |
| Migration period | T-0 to T-6mo |
| Brownout tests | T-3mo (short 503 windows) |
| Sunset date | T+6mo (returns 410 Gone) |
| Removal | T+9mo (route deleted) |
4. Using Version Sunset Policies
| Audience | Notice |
|---|---|
| Public APIs | 12 months minimum |
| Partner APIs | 6 months + direct comms |
| Internal APIs | 3 months |
| Security retirement | 30 days (CVE-driven) |
5. Configuring Redirect Rules
Example: 301 redirect old → new
location ~ ^/v1/orders/(.*)$ {
return 301 /v2/orders/$1$is_args$args;
}
# Optional: 308 preserves method for non-GET
location /v1/payments {
return 308 /v2/payments;
}
6. Setting Up Migration Guides
| Section | Content |
|---|---|
| Why migrate | Benefits, sunset reason |
| Breaking changes | Side-by-side diff |
| Code samples | Before/after in N languages |
| SDK upgrade | Package version bumps |
| FAQ + support | Office hours, Slack |
7. Implementing Usage Tracking
| Metric | Use |
|---|---|
| Calls per deprecated route | Identify hold-outs |
| Unique consumers | Reach out to top users |
| Migration % done | v1 / (v1+v2) trend |
| SDK version distribution | Force upgrade messaging |
8. Using Deprecation Notices in Responses
| Location | Detail |
|---|---|
| Headers | Always, machine-readable |
| JSON envelope | _warnings: [...] |
Error meta | JSON:API meta field |
| SDK telemetry | Log warning to console |
9. Configuring Graceful Degradation
| Technique | Detail |
|---|---|
| Brownouts | Brief 503 windows pre-sunset |
| Read-only mode | Block writes first |
| Reduced limits | Lower rate-limit on old API |
| Static response | Return cached snapshot |
10. Setting Up Client Communication
| Channel | Timing |
|---|---|
| Email to API key owners | T-12mo, T-6mo, T-1mo, T-1wk |
| Dev portal banner | Persistent |
| Changelog/RSS | On every change |
| Webhook | api.deprecation event |
| Status page | Sunset milestones |