categories.api-design Intermediate

API Versioning Strategies: Trade-offs and Best Practices

AI Practice

API Versioning Strategies

1. URL Path (most common)

GET /api/v1/users / GET /api/v2/users

✅ Intuitive, easy to log and bookmark ❌ Violates RESTful principle (URI should represent a resource)

2. Query Parameter

GET /api/users?version=2

✅ URL structure unchanged ❌ Easy to forget; hard to route at gateway level

3. Custom Header

Api-Version: 2

✅ Clean URL, REST-compliant ❌ Requires tools for browser testing

4. Content Negotiation

Accept: application/vnd.myapp.v2+json

✅ Most semantically correct per HTTP spec ❌ Complex to implement and test

Deprecation (Sunset) Strategy

  1. Add Sunset header to notify clients of end-of-life date
  2. Allow 6–12 months migration window
  3. Update docs and proactively notify consumers

Interview bonus: Mention Stripe's versioning—default version locked at account creation time; new features use date-based versions.

✦ AI Mock Interview

Type your answer and get instant AI feedback

Sign in to use AI scoring

Copyright © 2026 Wood All Rights Reserved · FE Interview Hub