惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
J
Java Code Geeks
小众软件
小众软件
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - Franky
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
腾讯CDC
T
The Blog of Author Tim Ferriss
大猫的无限游戏
大猫的无限游戏
量子位
M
MIT News - Artificial intelligence
Last Week in AI
Last Week in AI
L
LangChain Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How to Version APIs Without Breaking Production
OutworkTech · 2026-06-01 · via DEV Community

API versioning is one of those topics every backend engineer understands in theory and gets wrong in practice.

Not because it's technically complex. Because the decisions you make at v1 follow you all the way to v5 — and most teams don't think about that until something breaks in production at 2 AM.

This is a practical breakdown of how to version APIs the right way, before you're forced to.


Why API Versioning Breaks Things in the First Place

The core problem isn't versioning itself. It's that APIs are contracts.

When you expose an endpoint, every consumer — mobile app, third-party integration, internal service — builds against that contract. The moment you change a field name, remove a parameter, or alter a response structure, you've broken that contract for someone.

The instinct is to just "update the docs and notify people." That works exactly once, on a small team, with no external consumers.

At scale, it fails every time.


The Three Versioning Strategies (And When to Use Each)

1. URI Versioning

The most common approach. Version lives in the URL path.

When it works:

  • Public APIs with external consumers
  • APIs where clients need to explicitly opt into new behavior
  • Teams that want maximum clarity in logs and routing

The real tradeoff:
URI versioning is explicit — which is good — but it encourages parallel code maintenance. Running /v1 and /v2 simultaneously means two codebases, two sets of tests, two surfaces for bugs. Most teams underestimate the maintenance cost of this until v3 ships.


2. Header Versioning

Version is passed in the Accept or a custom header like API-Version: 2.

When it works:

  • Internal APIs where you control all consumers
  • Teams that want clean URLs without version pollution
  • APIs consumed primarily by server-to-server clients (not browsers)

The real tradeoff:
Header versioning is cleaner architecturally but harder to test manually and harder to cache at the CDN/proxy layer. Most teams skip this because it adds friction to client-side debugging.


3. Query Parameter Versioning

Honestly? It mostly doesn't work. It's the lazy default — easy to implement, easy to forget, easy to misuse. Avoid it for anything serious.

The only valid use case is a transitional API where you need quick rollback capability and the consumer base is entirely internal.


The Breaking vs. Non-Breaking Change Problem

Before you create a new version, ask the right question: does this change actually require one?

Most teams version too aggressively. A new version for every change is versioning theater — it looks disciplined but creates unnecessary complexity.

Changes that do NOT require a new version:

  • Adding new optional fields to a response
  • Adding new optional query parameters
  • Adding new endpoints
  • Deprecating (not removing) fields with a clear sunset date

Changes that require a new version:

  • Removing or renaming existing fields
  • Changing field data types (string → integer, object → array)
  • Altering authentication flows
  • Restructuring nested response objects
  • Changing error response formats

The rule of thumb: if a consumer can ignore the change and keep working, it's non-breaking. If they have to update their code to not break, it's breaking.


A Versioning Lifecycle That Actually Works

Most teams think about versioning as a naming problem. It's really a lifecycle management problem.

Here's a framework that holds up in production:

Phase 1 — Launch
Ship v1. Document it properly. Treat it like a public contract from day one, even if it's internal.

Phase 2 — Iterate Without Breaking
Add features as non-breaking changes. New optional fields. New endpoints. Additive-only changes.

Phase 3 — Announce Deprecation Early
When a breaking change becomes unavoidable, release v2 and mark affected v1 endpoints as deprecated. Set a sunset date — minimum 6 months for external APIs, 3 months for internal.

Add a Deprecation header to deprecated responses:
Phase 4 — Enforce Migration
Before sunset, send direct communication to consumers still hitting deprecated endpoints. Most teams skip this step. Don't — it's what separates a clean migration from a production incident.

Phase 5 — Sunset
Return 410 Gone instead of 404 Not Found for removed endpoints. The distinction matters — 410 tells consumers this was intentional and permanent, not a routing error.


Monorepo vs. Separate Codebases for API Versions

Approach A — Shared core, versioned adapters
Cleanest in practice. Business logic lives once. Versioning only affects the serialization/deserialization layer. When v1 is sunset, delete the adapter directory.

Approach B — Full version isolation
Easier to reason about in the short term. Becomes a maintenance nightmare by v3 when a security patch needs to be applied in three places simultaneously.

For most SaaS products, Approach A is the right default. Approach B only makes sense when versions have fundamentally different infrastructure requirements.


Practical Implementation Checklist

Before shipping any version change, run through this:

  • [ ] Is the change actually breaking? (If not, skip versioning)
  • [ ] Is v(n-1) deprecated with a documented sunset date?
  • [ ] Are Deprecation and Sunset headers returned on deprecated routes?
  • [ ] Is the new version documented before it ships, not after?
  • [ ] Are consumers using deprecated endpoints identified and notified?
  • [ ] Does your monitoring track requests by API version?
  • [ ] Is 410 Gone configured for sunset endpoints?
  • [ ] Are your SDK/client libraries updated before the new version goes live?

If any of these is unchecked when you push, you're setting up a future incident.


The Mindset Shift That Matters

Most teams treat API versioning as a technical task — pick a strategy, implement it, move on.

The teams that do it well treat it as a communication discipline.

Every version is a message to your consumers: "we changed something that matters, here's what, here's when the old thing goes away, here's how to migrate."

Get that communication loop right and the technical implementation almost doesn't matter. Get it wrong and even the cleanest URI versioning strategy will still cause production fires.


OutworkTech builds and scales backend systems, APIs, and SaaS infrastructure for companies that need engineering depth without the overhead. If your API architecture is becoming a bottleneck — let's talk.