ASP.NET Core Web API Interview Question #86

When should an API introduce a new version?

Routing, Versioning, OpenAPI/Swagger & API Documentation Mid-Level Intermediate

Quick Interview Answer

A new version is appropriate when a public contract must change incompatibly and existing clients cannot safely consume the new behavior. Examples can include removing or renaming required fields, changing meanings, or restructuring resources incompatibly.

Detailed Explanation

A new version is appropriate when a public contract must change incompatibly and existing clients cannot safely consume the new behavior. Examples can include removing or renaming required fields, changing meanings, or restructuring resources incompatibly.

Additive changes may sometimes remain backward compatible. Version decisions should be based on the documented contract and real client impact rather than every implementation change.

Code Example

// v1 response
{ "id": 10, "name": "Phone" }

// An incompatible redesigned contract may be exposed as v2
{ "productId": 10, "displayName": "Phone" }