Start With No Versions
If you deploy the clients and the server together, you don't need versioning at all. Change both and ship. Versioning is a cost you pay at boundaries you don't control, so it starts on the day someone outside your team depends on the API.
Versioning is what you do because you can't go back in time and design the API right the first time. The 2026 reality:Asp.Versioning 10.x on .NET 10 makes URL, query-string, header, and media-type versioning equally easy in code — so the choice is now about ergonomics and tooling, not implementation. Public APIs trend toward URL versioning (/v2/orders) because it's debuggable and CDN-cacheable; internal APIs increasingly use header versioning to avoid URL churn.
The bigger question is "when to bump the version" — i.e., what counts as breaking. The healthy answer in 2026 is the same as 2010: additive changes (new fields, new endpoints, new optional parameters) never bump the version. Removals, renames, type changes, and stricter validation always do.
- You renamed a field and broke five mobile clients
- You have
/v1,/v1.1,/v2,/v2-beta, and/v2-finalin production - You can't deprecate
/v1because three customers won't upgrade - Your "non-breaking" change broke the iOS app from 2024
Pick one versioning scheme, document the contract, deprecate with sunset headers, and only bump for true breaks.
Versioning Strategies Compared
Four common schemes:
- URL path —
/v1/orders. Easy, debuggable, CDN-friendly. Most public APIs use this. - Query string —
/orders?api-version=2026-04-01. Azure's favored style; works with date-based versions. - Custom header —
X-Api-Version: 2. Clean URLs but harder to test in a browser. - Media type (Accept) —
Accept: application/vnd.example.v2+json. RESTful purist's pick; awkward in CDNs.
And a fifth strategy that works everywhere: don't break. Add new fields, never remove. GitHub's REST API shows the middle ground: additive changes go into every supported version, breaking changes ship only in a new date-named version (selected with the X-GitHub-Api-Version header), and each version stays supported for 24 months after a newer one is released.
flowchart LR
C["Client v1"] -->|GET /v1/orders/123| API["API"]
C -.->|Sunset: Fri, 01 Jan 2027<br/>Deprecation: @1767225600| C
C2["Client v2"] -->|GET /v2/orders/123| API
API --> H1["v1 handler<br/>(maps to v2 internally)"]
API --> H2["v2 handler"]
style API fill:#0078D4,color:#fff,stroke:#005a9e
Versioning With Asp.Versioning
Step 1: Wire up Asp.Versioning on .NET 10
// dotnet add package Asp.Versioning.Http
// dotnet add package Asp.Versioning.Mvc.ApiExplorer
builder.Services.AddApiVersioning(o =>
{
o.DefaultApiVersion = new ApiVersion(1, 0);
o.AssumeDefaultVersionWhenUnspecified = true;
o.ReportApiVersions = true; // adds api-supported-versions header
o.ApiVersionReader = ApiVersionReader.Combine(
new UrlSegmentApiVersionReader(),
new HeaderApiVersionReader("X-Api-Version"),
new MediaTypeApiVersionReader("v"));
}).AddApiExplorer(o =>
{
o.GroupNameFormat = "'v'VVV"; // for OpenAPI grouping
o.SubstituteApiVersionInUrl = true;
});Step 2: Versioned endpoints (Minimal API)
var versionSet = app.NewApiVersionSet()
.HasApiVersion(new ApiVersion(1, 0))
.HasApiVersion(new ApiVersion(2, 0))
.ReportApiVersions()
.Build();
var v1 = app.MapGroup("/v{version:apiVersion}/orders")
.WithApiVersionSet(versionSet)
.MapToApiVersion(1, 0);
var v2 = app.MapGroup("/v{version:apiVersion}/orders")
.WithApiVersionSet(versionSet)
.MapToApiVersion(2, 0);
v1.MapGet("/{id:long}", (long id) => GetOrderV1(id));
v2.MapGet("/{id:long}", (long id) => GetOrderV2(id)); // new shapeCheck it: Call the same resource on v1 and on v2. Each should return its own shape, and a request with no version should behave exactly as you documented.
Step 3: Internal mapping (don't fork the domain)
// Anti-pattern: two copies of OrderService.
// Pattern: ONE domain, multiple wire mappers.
public record OrderV1Dto(long Id, string Customer, decimal Total);
public record OrderV2Dto(long Id, CustomerDto Customer, MoneyDto Total, DateTimeOffset PlacedAt);
static OrderV1Dto MapV1(Order o) =>
new(o.Id, o.Customer.DisplayName, o.TotalCents / 100m);
static OrderV2Dto MapV2(Order o) =>
new(o.Id,
new CustomerDto(o.Customer.Id, o.Customer.DisplayName),
new MoneyDto(o.TotalCents, "USD"),
o.PlacedAt);
// One domain. Two views. Easy to add v3 next year.Check it: Fix a bug in the domain layer and call both versions. The fix should show up in both, because there's only one copy of the logic.
Step 4: Deprecation + Sunset headers (RFC 8594, RFC 9745)
v1.MapGet("/{id:long}", (long id, HttpContext ctx) =>
{
// RFC 9745: the value is a structured-field date (Unix seconds), not "true"
ctx.Response.Headers["Deprecation"] = "@1767225600"; // 2026-01-01T00:00:00Z
ctx.Response.Headers["Sunset"] = "Fri, 01 Jan 2027 00:00:00 GMT";
ctx.Response.Headers["Link"] =
"<https://docs.example.com/migrate-v2>; rel=\"deprecation\"";
return GetOrderV1(id);
});
// Asp.Versioning can also emit these for you: options.Policies.Deprecate(...) / .Sunset(...)Check it: Call a deprecated endpoint and read the response headers. Both dates should be there. Then check that your logs can tell you which clients called it this week.
Step 5: Date-based versions (GitHub / Azure style)
// Azure SDK / ARM convention: ?api-version=2026-04-01
// Each release date is an immutable snapshot of behavior.
// Internally: keep one current implementation + a thin compatibility layer
// that adapts the request/response to the requested date.
builder.Services.AddApiVersioning(o =>
{
o.ApiVersionReader = new QueryStringApiVersionReader("api-version");
o.DefaultApiVersion = new ApiVersion(new DateOnly(2026, 4, 1));
});Step 6: Surface versions in OpenAPI
// .NET 10 built-in OpenAPI + Asp.Versioning.Mvc.ApiExplorer
builder.Services.AddOpenApi("v1");
builder.Services.AddOpenApi("v2");
app.MapOpenApi("/openapi/{documentName}.json");
// Result: /openapi/v1.json and /openapi/v2.json — two clean specs,
// each consumable by its own SDK / docs site. The document names must match
// the ApiExplorer group names ('v'VVV gives "v1", "v2"). Alternatively, the
// Asp.Versioning.OpenApi package adds .AddOpenApi() to the versioning builder
// and app.MapOpenApi().WithDocumentPerVersion() creates one document per version.How Versioning Goes Wrong
- Bumping the version for additive changes. Adding an optional field is not breaking. Bumping for it just trains clients to upgrade for nothing and forces you to maintain N versions instead of one.
- Forking the domain layer per version. Two copies of
OrderService= two copies of the bugs. Map at the edge; share the core. - No sunset policy. "v1 forever" is a gift to customers and a tax on you. Document a 12-month minimum sunset; emit
Sunset+Deprecationheaders from day one of v2. - Mixing schemes. URL and header and media type. Pick one canonical way for clients; accept the others as aliases at most.
- Treating beta and v2 as the same thing. A breaking-change preview belongs on a separate preview endpoint with its own clearly-temporary lifecycle.
- Versioning everything. Internal microservices don't need versioning if you can deploy clients and servers together. Reserve the cost for boundaries you don't control.
Try It on Your Own System This Week
Three checks on an API with outside clients, about an hour in total:
- List the versions running in production. For each, name who still calls it. Any you can't name is one you can't retire.
- Write down what counts as breaking. Removals, renames, type changes and stricter validation. Agree it once, in writing.
- Check your last three changes against that list. If one was breaking and shipped without a version, find out which clients noticed.
How I Would Version an API
- Default to additive evolution. Done carefully, an API can go years without a v2.
- When you must break: pick URL versioning for public APIs, header for internal ones.
- One domain, multiple wire mappers. Never fork the business logic.
- Emit
Deprecation+Sunsetheaders (RFC 9745). They're the polite way to retire a version. - Generate per-version OpenAPI docs; ship per-version SDKs.
- Date-based versions work well when you ship behavioral changes, not just shape changes.
- Document the contract in writing (additive vs breaking) so "is this breaking?" isn't a Slack thread every PR.
Deprecating Without Breaking Anyone
Adding a version is the easy part. The hard part is turning the old one off, and most teams never manage it. They end up running v1, v2 and v3 forever, each with its own bugs. So plan the end of a version on the day you create its successor.
Use the standard headers. RFC 9745 defines a Deprecation response header, and RFC 8594 defines Sunset, which gives the date it stops working. Clients and gateways can read these automatically, and a good API client will log a warning.
HTTP/1.1 200 OK
Deprecation: @1774915200
Sunset: Wed, 30 Jun 2027 00:00:00 GMT
Link: <https://api.example.com/docs/migrate-v2>; rel="deprecation"
Measure who's still calling the old version, per client. Then contact those clients directly, because nobody reads your changelog. In the last weeks, consider brownouts: turn the old version off for an hour at a known time. It sounds harsh, and it finds the integrations that nobody remembered, while you can still turn it back on.
Avoid a version bump when you can
Most changes don't need a new version. Adding an optional field, adding a new endpoint or accepting a new optional parameter are all safe, as long as clients ignore fields they don't recognise. Write that rule in your API guidelines from the start. Things that do break clients include removing or renaming a field, changing a type, tightening validation, and changing a default. That last one often gets missed.
Contract tests are the safety net. Diff your OpenAPI spec in CI with a tool such as oasdiff, and fail the build on a breaking change. It catches the accidental rename that a code review misses, and it turns a judgment call into a check.
Versioning for agents
AI agents are now API clients, and they behave differently. An agent reads your tool description or OpenAPI spec, so a field rename can silently change what it does, with no compile error anywhere. If agents use your API, keep the descriptions accurate, and treat a change to one as a behaviour change. Publish clear error messages that say what to do instead, since an agent can act on them, and a person may never see them.
Announce It Early
Publish a deprecation policy before you need it, such as twelve months' notice for public APIs. Add a changelog that clients can subscribe to, and say what breaks. Knowing the rules in advance is what makes people comfortable building on your API.