Skip to content

Menu

Engineering

API Versioning in Production: Where the Version Lives, Dated Versions, Deprecation and Sunset

AIDToolStack EditorialUpdated November 7, 20269 min read
APIVersioningRESTBackendBreaking Changes
Share:Twitter

Sooner or later someone files a ticket that says "rename customer_name to customer.name", and you realise the field is read by a mobile app that plenty of people haven't updated in months. You can't change it in place. You also don't want to run two copies of your API forever. API versioning is the set of habits that sits between those two outcomes.

This post covers where to put the version, how Stripe and GitHub run date-based versions in public (taken from their own docs), the two HTTP headers that now exist for announcing deprecation and shutdown, and what a changelog entry needs to say. If you'd rather generate the routing boilerplate than type it, our API versioning helper turns a small JSON config into routes, Express middleware and a Next.js route handler for path, header, query or media-type versioning.

First decide what "breaking" means

Most versioning arguments are really arguments about this. GitHub publishes a clear list in its API versions docs, and it's a decent default to adopt wholesale:

Needs a new version (breaking)Ships to every version (additive)
Removing an operationAdding an operation
Removing or renaming a parameter or response fieldAdding an optional parameter or request header
Adding a required parameter, or making an optional one requiredAdding a response field or response header
Changing the type of a parameter or response fieldAdding enum values
Removing enum values
Adding a validation rule to an existing parameter
Changing authentication or authorization requirements

Two items in the right-hand column deserve a warning in your docs. New enum values break any client that does an exhaustive switch and throws on the default branch. New response fields break clients that validate responses against a strict schema (additionalProperties: false, Zod's .strict()). If you adopt GitHub's rule, tell integrators in writing to ignore unknown fields and tolerate unknown enum values, and make your own SDKs do the same. Generated clients are a common place for that strictness to sneak in; our post on type-safe API clients with OpenAPI codegen is worth a look if you ship one.

Status codes aren't on either list, but they're part of the contract. GitHub's 2026-03-10 version changed the success code for deleting an app installation from 204 to 202 and filed it under breaking changes. Any client checking status === 204 would have broken. Our decision table for HTTP status codes helps you pick the right one the first time, so you don't need a version to fix it.

Where the version lives

StyleExampleGood atWeak at
URL pathGET /v2/orders/42Visible in logs, links and curl; trivially routable and cacheableEvery resource URL changes; invites big-bang "v2" rewrites
Custom headerX-GitHub-Api-Version: 2026-03-10URLs stay stable; versions can be fine-grained datesInvisible in a pasted URL; shared caches must vary on it
Media typeAccept: application/vnd.example.v2+jsonFits HTTP content negotiationAwkward by hand; few clients set Accept carefully
Query parameter/orders/42?api-version=2Easy to add from any clientEasy to drop; mixes versioning into cache keys and filters

The media-type style uses the vendor tree from RFC 6838: a vnd. prefix for a vendor-specific type and a +json suffix saying the underlying syntax is JSON. GitHub uses this for representations rather than versions. Its getting-started page recommends Accept: application/vnd.github+json and offers variants such as application/vnd.github.raw+json, while the version goes in its own header.

One caching gotcha with any header-based scheme: if a shared cache sits in front of the API, the response has to name the header it depends on in Vary. Under RFC 9111, a cache may only reuse a stored response when the request headers listed in Vary match the original request. Forget Vary: X-Api-Version and a CDN can hand a v1 body to a v2 client. Path versioning sidesteps this because the version is already in the cache key.

My default: a path prefix (/v1) for the coarse "this is a different API" split, which ideally happens once or never, plus a dated header for everything finer. That's roughly what both case studies below do.

Date-based versions at Stripe

Stripe names each version by release date plus a release name. As of November 2026 its versioning page lists the current version as 2026-10-28.endive. Since 2024-09-30.acacia, Stripe has shipped a version every month with no breaking changes, and twice a year starts a new major release whose first version may contain breaking ones. Stripe's announcement of the process also reserves the right to an out-of-cycle breaking change if your integration "would be severely impacted" otherwise.

Three details are worth copying:

  1. Every account has a default version, used for requests that don't name one. The upgrade guide still tells you to specify the version in code rather than rely on that default.
  2. The SDK pins the version. Recent server SDKs send the API version that was current when that SDK release was cut, and the strongly typed ones (Java, Go, .NET) can't target anything else. Upgrading the library is upgrading the API.
  3. Any request can override it with a header:
curl https://api.stripe.com/v1/charges \
  -u "$STRIPE_SECRET_KEY:" \
  -H "Stripe-Version: 2026-10-28.endive"

Webhooks are where this gets fiddly. Event payloads use the version set when the webhook endpoint was created, not the one your code sends. Stripe's documented upgrade path is to create a second endpoint on the new version with a distinguishing query parameter (?version=...), process events from only one endpoint at a time, flip over, then disable the old one. During the overlap every event arrives twice, so the handler has to be idempotent. Our Stripe integration patterns post and webhooks guide cover that side.

Date-based versions at GitHub

GitHub's REST API reads the version from X-GitHub-Api-Version. As of November 2026 the API versions page lists two: 2026-03-10, with no end of support scheduled, and 2022-11-28, supported until 10 March 2028. Requests without the header get 2022-11-28, so the newer version is opt-in. When a new version ships, the previous one stays supported for at least 24 months. Ask for a version that's no longer supported and you get 410 Gone.

The breaking changes list for 2026-03-10 shows what a dated version is for. It removes the deprecated rate property from the rate limit endpoint, drops merge_commit_sha from pull request payloads, replaces the singular assignee field with the assignees array, and changes that installation delete to 202. None of those is worth a /v4. Every one of them would break somebody.

Implementing versions without forking your codebase

Separate code paths per version stop being manageable after two or three. The pattern that holds up is to write handlers against the latest version only, then apply a chain of small downgrade transforms to the response for older clients. Each transform knows about exactly one change.

// versions.ts: newest first. Each entry undoes one breaking change.
type Transform = (body: any) => any;

const changes: { version: string; down: Transform }[] = [
  {
    version: "2026-09-01", // customer_name became customer.name
    down: ({ customer, ...rest }) => ({ ...rest, customer_name: customer?.name ?? null }),
  },
  {
    version: "2026-03-01", // total changed from float dollars to integer cents
    down: (b) => ({ ...b, total: b.total / 100 }),
  },
];

export const LATEST = changes[0].version;
export const SUPPORTED = new Set([LATEST, "2026-03-01", "2025-10-01"]);

export function render(body: unknown, requested: string) {
  // Apply every change newer than the version the client asked for.
  // ISO dates sort correctly as strings.
  return changes.filter((c) => c.version > requested).reduce((b, c) => c.down(b), body);
}

The request path resolves the version once, rejects unknown ones, and echoes the version it used so clients can log it:

const requested = req.get("X-Api-Version") ?? apiKey.defaultVersion;
if (!SUPPORTED.has(requested)) {
  return res.status(400).json({ error: "unsupported_version", supported: [...SUPPORTED] });
}
res.set({ "X-Api-Version": requested, Vary: "X-Api-Version" });
res.json(render(order, requested));

Request bodies need the mirror image (upgrade transforms on the way in), and both directions want tests that replay recorded requests against every supported version. Give each account or API key a default version, set it to the latest when the key is created, and nobody accidentally starts life on a version you're about to retire.

Announcing deprecation and sunset in HTTP

Changelog posts get missed. Response headers get logged. There are now two standard ones:

  • Deprecation (RFC 9745, Standards Track, March 2025) says the resource is or will be deprecated. The value is a Structured Fields date: @ followed by Unix seconds. It's purely informational. In the RFC's words: "The act of deprecation does not change any behavior of the resource." A Link with rel="deprecation" points to human-readable docs.
  • Sunset (RFC 8594, Informational, May 2019) carries the HTTP-date after which the resource is expected to stop responding, and defines a sunset link relation for a policy page.

RFC 9745 ties them together: the Sunset time must not be earlier than the Deprecation time. A response from a version deprecated on 1 December 2026 and switched off on 1 June 2027 looks like this:

HTTP/1.1 200 OK
Deprecation: @1796083200
Sunset: Tue, 01 Jun 2027 00:00:00 GMT
Link: <https://api.example.com/docs/migrate-2026-09-01>; rel="deprecation"; type="text/html"
X-Api-Version: 2025-10-01
Timeline of one API version: release, Deprecation header from the deprecation date, Sunset date, then 410 Gone
Timeline of one API version: release, Deprecation header from the deprecation date, Sunset date, then 410 Gone

After the sunset date, return 410 Gone with a body that names the replacement version, which mirrors what GitHub does for retired versions. Our HTTP header parser is handy for checking raw responses while you wire this up.

On the client side, the cheap win is a hook in your SDK or HTTP wrapper that logs a warning, once per process rather than per request, whenever a response carries Deprecation or Sunset. That turns a header nobody reads into a log line somebody greps.

What each changelog entry needs

A version is only as useful as its changelog entry. For each one, write:

  • the version string and release date;
  • each breaking change: the endpoint or field, what it was, what it is now, and a before/after snippet;
  • what replaces anything deprecated, plus the sunset date once it's set;
  • additive changes in a separate, shorter list.

Stripe's upgrade guide points you at a changelog view filtered to the API calls your integration actually makes, which is the bar to aim for. If you build release notes from commit messages, our changelog generator groups Conventional Commits and puts breaking changes first.

Checklist before you ship the next version

  • A written definition of breaking vs additive, published for integrators, including "ignore unknown fields".
  • Every request resolves to exactly one version; the default is pinned per account or key, never "whatever is latest".
  • Responses echo the version used, with Vary set when a header selects it.
  • Downgrade and upgrade transforms, each covered by replay tests for every supported version.
  • Deprecation, Sunset and Link headers on deprecated versions, with Sunset never before Deprecation.
  • 410 Gone plus a migration link after sunset.
  • A stated support window (GitHub commits to at least 24 months after a successor ships) that you actually keep.
  • Webhook payload versions handled separately from request versions.
AE

Written by AIDToolStack Editorial

Researched from official documentation, specifications and vendor pages, listed under Sources below. Last checked November 2026.

Sources

  1. docs.github.com /en/rest/about-the-rest-api/api-versions
  2. docs.github.com /en/rest/about-the-rest-api/breaking-changes
  3. docs.github.com /en/rest/using-the-rest-api/getting-started-with-the-rest-api
  4. docs.stripe.com /api/versioning
  5. docs.stripe.com /upgrades
  6. stripe.com /blog/introducing-stripes-new-api-release-process
  7. rfc-editor.org /rfc/rfc9745.html
  8. rfc-editor.org /rfc/rfc8594
  9. rfc-editor.org /rfc/rfc6838.html
  10. rfc-editor.org /rfc/rfc9111.html

Related Posts

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…