What are service versioning strategies in microservices?

Answer

As services evolve, their APIs must be versioned to allow consumers to upgrade at their own pace without breaking changes. Common strategies include: URI versioning — embed the version in the URL path (/api/v1/orders, /api/v2/orders), which is simple and explicit; Header versioning — pass the version in a request header (Accept: application/vnd.myapp.v2+json), keeping URLs clean; Consumer-driven contract testing (Pact) — automatically verify that new service versions are still compatible with all known consumers; and additive changes only — follow backward-compatible rules: add new fields (never remove or rename), add new endpoints, and make new fields optional. Semantic versioning (MAJOR.MINOR.PATCH) helps communicate the impact of changes to consuming teams.