How to Choose a URL Versioning Strategy for a Public API

Compare path, header, media-type, and query-based API versioning, then plan compatibility, deprecation, migration, documentation, and monitoring.

Published
Reading time
7 min read
How to Choose a URL Versioning Strategy for a Public API
On this page

Choosing an API versioning strategy means deciding how clients select a contract—and how you will support them as that contract changes. Path versions are easy to see, but headers and media types can also work. The right choice depends on your consumers, infrastructure, and migration policy, not on a universal rule.

Key Takeaways

  • Use path versioning when discoverability, simple routing, and broad client compatibility are priorities.
  • Consider header or media-type versioning when keeping a stable resource URL is important and your tooling handles negotiation reliably.
  • Prefer backward-compatible changes where possible; reserve a new major version for changes that break existing clients.
  • Publish a deprecation and support policy before clients need to migrate, then use usage data to guide outreach and retirement.

Compare the main strategies

The version identifier tells a client which API contract it is requesting. It does not, by itself, determine what counts as a breaking change or how long an older contract remains available.

StrategyExampleAdvantagesTrade-offs
PathGET https://api.example.com/v1/orders/123Visible in logs and documentation; straightforward routing; easy to select in many clientsCreates distinct versioned paths; links and integrations must move when a client migrates
Custom headerGET https://api.example.com/orders/123 with API-Version: 2Keeps the resource path stable; version choice is explicit in request metadataLess visible in a copied URL; clients, gateways, tests, and caches must handle the header consistently
Media typeAccept: application/vnd.example.orders-v2+jsonUses content negotiation to select a representationMore complex to explain and debug; clients and infrastructure must preserve and interpret the Accept header
Query parameterGET https://api.example.com/orders/123?api-version=2Easy to try in a browser or simple HTTP client; version is visible in the URLCan mix contract selection with ordinary query parameters; every layer must treat the parameter consistently

These are design choices, not interchangeable guarantees. A path version is often a practical default for public APIs with varied consumers because it is conspicuous and simple to route. A header or media type can be a good fit when clients already use content negotiation and your operational tools make the selected version visible. A query parameter may suit an established platform convention, but avoid making version selection ambiguous or optional in ways that cause clients to receive an unexpected contract.

The Google API Improvement Proposals (AIPs) are one established example of path-based versioning: AIP-185 describes version identifiers in API paths. That guidance is a useful reference, not a rule every public API must adopt.

Advertisement

Decide what deserves a new version

A version strategy works best alongside a compatibility policy. Before adding a version, ask whether the change can be made without invalidating existing requests or responses.

Changes that are often compatible include adding an optional request field or adding a response field, provided clients tolerate unknown fields. Neither is automatically safe: a client that rejects unknown response fields may break, and a new field that changes the meaning of an existing field can be breaking even if its name is unchanged.

Changes that commonly require a new major contract include removing or renaming a field, changing a field's type or meaning, making an optional request field required, or changing behavior clients rely on. Adding a new value to an enum can also break generated clients that assume the list is exhaustive. Evaluate changes from the perspective of real consumers, not only the server implementation.

Do not assume that a version number must track a software release or follow semantic versioning. Choose a convention—such as a major number (v1, v2) or a dated version—and explain what changes trigger a new value. Keep that convention consistent across endpoints and documentation.

Plan deprecation and migration

A new version does not migrate clients by itself. A usable policy tells consumers:

  1. Which versions are currently supported and what support means.
  2. When an older version is deprecated, and when it is scheduled to stop accepting requests.
  3. What changes they must make, with migration examples and a change log.
  4. Where to get help and how to report a migration issue.

Give consumers a transition window suited to their release cycles and the impact of the change. A small internal integration may migrate quickly; a public API used in deployed products may need substantially more notice. State dates and conditions clearly rather than promising indefinite support.

For example, if you introduce /v2/orders, keep /v1/orders available during the announced transition period, publish a field-by-field migration guide, and avoid changing /v1 behavior in ways that defeat its compatibility promise. If you use header versioning, explain how a client selects each version and what happens when it omits the header. Never make an undocumented default change that silently moves consumers to a different contract.

Align docs, monitoring, and support

Publish documentation for each supported version, including example requests, response schemas, error behavior, authentication requirements, and known differences. Keep old-version documentation accessible during its support window; consumers need it to understand existing behavior while migrating.

Monitor requests by API version and, where appropriate, by endpoint and authenticated client. Use that data to identify active consumers, find migration blockers, and determine whether a planned retirement date is realistic. Do not rely on aggregate request counts alone: a low-volume integration can still be business-critical. Provide a clear contact or support path so consumers can raise issues that metrics cannot explain.

Make the version visible in operational records. With path versions it is usually apparent in the route; with header or media-type versions, ensure gateways, application logs, traces, and dashboards capture the selected value. If caches sit in front of a header-negotiated API, configure them to distinguish responses by the relevant request header. Otherwise, clients could receive a representation selected for a different version.

Advertisement

A practical selection workflow

  1. Inventory consumers. List client types, SDKs, gateways, caches, and whether consumers can reliably set request headers.
  2. Write compatibility rules. Define which changes are safe and how you handle edge cases such as new enum values and unknown response fields.
  3. Choose a selector. Prefer the mechanism that is easiest for your consumers and operational systems to inspect and apply consistently.
  4. Define the lifecycle. Document support, deprecation, migration notice, and retirement expectations before launching the first version.
  5. Test the transition. Verify that each version routes to the intended contract, that generated clients behave as expected, and that logs and metrics reveal version usage.
  6. Review usage before retirement. Contact affected consumers and address material blockers before ending support under the published policy.

Common Mistakes

  • Treating a path version as automatically better—or header versioning as automatically more RESTful—without considering consumers and infrastructure.
  • Creating a new version for every change, including changes clients can safely ignore.
  • Calling an addition backward-compatible without checking strict deserializers, generated clients, and exhaustive enum handling.
  • Deprecating a version without a clear end date, migration guide, or way to reach the API team.
  • Removing an older version based only on low traffic, without considering infrequent or high-impact consumers.
  • Hiding header-based version selection from caches, logs, or support tooling.

Best Practices

  • Keep version selection explicit and consistent across endpoints.
  • Document compatibility guarantees and the meaning of each version identifier.
  • Make compatible changes where feasible, and reserve major versions for changes that genuinely break clients.
  • Maintain version-specific documentation and migration examples throughout the support period.
  • Track version adoption and communicate directly with affected consumers before retirement.

Conclusion

Choose the version selector your consumers and infrastructure can apply reliably, then support it with clear compatibility rules and a realistic migration policy. Path versions are a strong practical option for many public APIs, but disciplined change management matters more than the selector alone.

References

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.