Semantic versioning for APIs: choose version numbers for compatibility changes
Semantic Versioning (SemVer) increments MAJOR.MINOR.PATCH according to compatibility changes in a declared public API. An incompatible change increments the major version; backward-compatible functionality or a deprecation increments the minor; a backward-compatible bug fix increments the patch. This is a release scheme for packages or SDKs, however, and does not mean every remote API must put v1.2.3 in its URL.
Semantic Versioning (SemVer) increments MAJOR.MINOR.PATCH according to compatibility changes in a declared public API. An incompatible change increments the major version; backward-compatible functionality or a deprecation increments the minor; a backward-compatible bug fix increments the patch. This is a release scheme for packages or SDKs, however, and does not mean every remote API must put v1.2.3 in its URL.
Decide what is being versioned first
Before assigning a number, define the public surface consumers depend on. For a library, it may include callable functions and types; for an SDK, methods, models, and supported runtimes; for a remote API, paths, requests and responses, errors, permissions, and observable behavior. You can judge compatibility only after defining that surface.
SemVer 2.0.0 requires a clear, comprehensive public API declaration. For a stable 1.x public API, use this as a decision guide:
| Change | Example package version | Why |
|---|---|---|
| Backward-compatible fix to internal implementation | 2.4.1 → 2.4.2 | The public API and existing use remain the same. |
| Add an optional response field or operation | 2.4.2 → 2.5.0 | Existing consumers need not use the addition. Actual compatibility may depend on how consumers handle unknown fields. |
| Add a required parameter, remove or change a field’s type, or change established behavior | 2.5.0 → 3.0.0 | Older consumers may fail or receive a different result from the new provider. |
| Mark a public feature as deprecated | 2.5.0 → 2.6.0 | SemVer treats marking public functionality deprecated as a minor increment. Later removal is an incompatible change. |
These are examples of applying the rules. Adding a response field is often additive, but strict deserializers or enum handling can still break consumers. Do not assume “adding a field is always safe”; check the public contract and consumer behavior.
Keep remote API versions separate from SDK versions
A client SDK distributed through a package registry can use SemVer. A remote API’s version is a separate policy for choosing which contract the server processes. For example, SDK 4.7.2 might call API path /v2, and a caller could also make direct requests in another language. A patch release of the SDK does not itself change the server API version.
Google AIP-185 describes exposing only a major version for Google APIs, placed at the start of the path as in v1. That policy differs from putting SemVer’s full MAJOR.MINOR.PATCH in an API path. GitHub REST API uses date-based versions selected with the X-GitHub-Api-Version header and documents its own support window and change policy. These are different operating models, not universal answers. A service should define how consumers select a version, how long versions coexist, and how deprecation and shutdown are communicated.
Judge a change with a concrete example
Suppose an API adds an optional nickname field to a 2.4 response. If the field is optional in the contract and consumers ignore unknown response fields, this may be an additive change that preserves existing behavior. If nickname becomes required input or userId changes from an integer to a string, older requests or clients may break, so treat the change as incompatible. Even with the same field type, changing its meaning can violate reasonable consumer expectations.
In practice, classify the proposal from the consumer’s point of view, check it against contracts and actual use cases, then apply the release policy.
List the affected public surface and the consumers it supports.
Examine source, wire, and semantic compatibility separately. Google AIP-180 uses these as distinct analysis dimensions.
Check expected impact with consumer contracts or integration tests, schema comparisons, or migration review. No single check proves semantic compatibility in full.
Increment the package version and remote API version under their respective policies; document changes, migration guidance, and support periods.
If incompatible API versions run in parallel, define a transition period and deprecation notice, then base shutdown criteria on evidence about consumer usage.
What version numbers do not guarantee
SemVer communicates the author’s intent only when the public API and policy are declared and followed. A number alone does not prove that every consumer implementation remains compatible; an unclear contract or mismatch between documentation and behavior also undermines the signal. SemVer treats 0.y.z as initial development without stability guarantees and requires changes to released versions to be published as new versions rather than overwriting them.
API operators therefore need to state separately what they count as compatible, which consumers they protect, and how they announce deprecation and shutdown. A narrowly scoped internal API with coordinated deployments may reasonably use different rules from a public API, but it should state that assumption and identify affected consumers.
Sources
[Semantic Versioning 2.0.0 specification](https://semver.org/spec/v2.0.0.html)
[Google AIP-185: API versioning strategies](https://google.aip.dev/185)
[Google AIP-180: types and guidance for backward compatibility](https://google.aip.dev/180)
[GitHub REST API version selection and support policy](https://docs.github.com/en/rest/about-the-rest-api/api-versions)
[Examples of breaking changes in the GitHub REST API](https://docs.github.com/en/rest/about-the-rest-api/breaking-changes)