Q24: What is API versioning, and how do you evolve an API safely?

Difficulty:MediumTopic:API Design

Versioning allows clients and servers to evolve without breaking existing consumers. Common approaches include URL versions, headers, or compatible additive changes. Prefer backward-compatible changes such as adding optional fields; avoid silently changing field meaning or removing fields. Track client adoption, publish deprecation dates, support a migration window, and use contract tests to catch incompatible changes.

Key Takeaways
  • Compatibility is more than adding a version number.
  • Measure usage before removing old behavior.