API Versioning

Master this essential documentation concept

Quick Definition

The practice of maintaining multiple simultaneous versions of an API so that existing integrations continue to work while newer versions introduce improvements or breaking changes.

How API Versioning Works

graph TD Client([API Client]) --> Gateway[API Gateway] Gateway --> Router{Version Router} Router -->|/v1/*| V1[API v1 Legacy - Stable] Router -->|/v2/*| V2[API v2 Current - Active] Router -->|/v3/*| V3[API v3 Beta - Breaking Changes] V1 --> DB1[(v1 Schema Users Table)] V2 --> DB2[(v2 Schema Users + Profiles)] V3 --> DB3[(v3 Schema Unified Identity)] V1 -->|Deprecated Notice| DepWarn[⚠️ Sunset: Q4 2024] style V1 fill:#ffcccc,stroke:#cc0000 style V2 fill:#ccffcc,stroke:#006600 style V3 fill:#cce5ff,stroke:#0066cc style DepWarn fill:#fff3cd,stroke:#856404

Understanding API Versioning

The practice of maintaining multiple simultaneous versions of an API so that existing integrations continue to work while newer versions introduce improvements or breaking changes.

Key Features

  • Centralized information management
  • Improved documentation workflows
  • Better team collaboration
  • Enhanced user experience

Benefits for Documentation Teams

  • Reduces repetitive documentation tasks
  • Improves content consistency
  • Enables better content reuse
  • Streamlines review processes

Keeping API Versioning Knowledge Accessible Across Your Team

When your team rolls out a new API version, the knowledge transfer often happens in recorded walkthroughs, architecture review meetings, or onboarding sessions where engineers explain which endpoints changed, what was deprecated, and how v1 and v2 clients should coexist. That context is valuable — but locked inside a video timestamp that nobody remembers.

The challenge with video-only documentation for API versioning is precision. A developer troubleshooting a breaking change between versions needs to find the exact decision — why a field was renamed, or when a legacy endpoint will be sunset — without scrubbing through a 45-minute recording. Version-specific details get buried, and teams end up asking the same questions in Slack that were already answered on camera six months ago.

Converting those recordings into searchable documentation changes how your team works with API versioning over time. Imagine a recorded sprint demo where your lead engineer explains the migration path from v2 to v3 — turned into a structured doc with headings, code references, and a clear deprecation timeline that any developer can find in seconds. That institutional knowledge stays accurate and retrievable as your API continues to evolve.

If your team regularly captures API versioning decisions on video but struggles to surface them later, see how converting recordings into structured documentation can close that gap.

Real-World Documentation Use Cases

Stripe-Style Payment API Migration: Retiring SHA-1 Webhook Signatures

Problem

A fintech platform needs to upgrade webhook signature hashing from SHA-1 to SHA-256 for PCI-DSS compliance, but thousands of merchant integrations rely on the existing v1 signature format. A hard cutover would break live payment flows overnight.

Solution

API versioning allows the platform to ship v2 webhooks with SHA-256 signatures while keeping v1 active with a published sunset date, giving merchants a 6-month migration window without service disruption.

Implementation

['Release /v2/webhooks endpoint with SHA-256 signatures and document the cryptographic change in a dedicated migration guide, including side-by-side code samples for both versions.', "Add a 'Stripe-Version' header to all v1 responses flagging deprecation with a link to the v2 migration guide and the sunset date of 2024-12-31.", 'Instrument both endpoints with version-specific analytics to track the percentage of merchants still on v1, enabling targeted outreach to laggards.', 'Send automated email alerts to API key owners still calling v1 at 90, 30, and 7 days before sunset, referencing their specific integration endpoints.']

Expected Outcome

95% of merchants migrate voluntarily before sunset, reducing forced migration support tickets by 80% and achieving PCI-DSS compliance without a single payment outage.

Twilio-Style Response Schema Refactor: Renaming Fields Without Breaking SDKs

Problem

An SMS API team needs to rename the 'phone' field to 'to_number' and restructure nested address objects across all message responses, but auto-generated SDKs in Python, Ruby, and Java have already been distributed to 10,000+ developers who depend on the old field names.

Solution

Version the REST API at the URL path level (/v1/ vs /v2/) so that v1 continues returning the legacy field names while v2 introduces the new schema, allowing SDK maintainers to publish updated packages on their own release cycle.

Implementation

["Freeze the v1 response schema and document it as 'stable/deprecated', then publish the v2 schema with a full field-by-field changelog table in the API reference docs.", 'Update the OpenAPI specification for v2 with the new field names and run code generators to produce updated SDKs for Python, Ruby, and Java, publishing them as major version bumps (e.g., sdk v2.0.0).', 'Add response headers to v1 endpoints (X-API-Deprecated: true, X-Sunset-Date: 2025-03-01) so SDK developers can surface warnings in their libraries automatically.', 'Publish an interactive migration diff tool in the developer portal that accepts a v1 JSON response and outputs the equivalent v2 structure with annotations.']

Expected Outcome

SDK adoption of v2 reaches 70% within 3 months of release, field naming is standardized across all language SDKs, and zero breaking changes are introduced to existing v1 integrations during the transition.

GitHub-Style REST-to-GraphQL Transition: Running Parallel API Paradigms

Problem

A developer platform's REST API returns over-fetched payloads (full repository objects with 47 fields) causing mobile clients to hit rate limits unnecessarily, but the team cannot force all existing CI/CD integrations to rewrite their HTTP calls to a new GraphQL endpoint.

Solution

Introduce a versioned v2 API surface that exposes a GraphQL endpoint alongside the existing REST v1, allowing new mobile clients to use precise queries while legacy CI/CD tools continue using REST without modification.

Implementation

['Deploy /v2/graphql alongside /v1/repos and /v1/users REST endpoints, documenting both paradigms in the same developer portal with a comparison guide explaining when to use each.', 'Create a version negotiation header (API-Version: 2024-01-15) following the Stripe date-based versioning pattern so clients can opt into specific behavior changes without changing URL paths.', 'Write migration tutorials with concrete before/after examples showing how a REST call fetching 47 fields maps to a GraphQL query fetching only 5 required fields, including latency benchmarks.', 'Instrument GraphQL query complexity scoring and expose it in response headers so teams can self-assess their query efficiency and justify the migration to stakeholders.']

Expected Outcome

Mobile client API payload sizes drop by 73%, rate limit errors decrease by 60%, and legacy CI/CD integrations continue operating unmodified, extending their useful life by 18+ months.

Salesforce-Style Enterprise API Governance: Managing Versions Across a Multi-Tenant SaaS Platform

Problem

An enterprise SaaS platform with Fortune 500 clients has 12 different API versions in production simultaneously because enterprise contracts prohibit forced upgrades, making it impossible to deprecate old endpoints, patch security vulnerabilities uniformly, or maintain coherent documentation.

Solution

Implement a formal API versioning policy with a maximum supported version window (e.g., N-2 versions), documented lifecycle states (beta, active, deprecated, sunset), and a contractual upgrade SLA that gives enterprise clients 12 months notice before any version is retired.

Implementation

['Define and publish an API Lifecycle Policy document specifying that only 3 major versions are supported simultaneously, with each version guaranteed 24 months of active support from its GA date.', "Create a version status dashboard in the developer portal showing each API version's release date, deprecation date, sunset date, and the percentage of API traffic it currently serves.", "Establish a security patch protocol that backports critical CVE fixes to all supported versions (N, N-1, N-2) while documenting the patch in each version's changelog, ensuring compliance without forced upgrades.", 'Automate version usage reports delivered monthly to enterprise account owners, showing which deprecated endpoints their integrations are calling and linking directly to the relevant migration guide sections.']

Expected Outcome

Active production API versions are reduced from 12 to 3 within 18 months, security patch deployment time drops from 3 weeks to 48 hours across all supported versions, and enterprise churn related to forced migration drops to zero.

Best Practices

Encode the Version in the URL Path, Not Just Request Headers

URL path versioning (e.g., /v1/users, /v2/users) makes the API version immediately visible in logs, browser history, and curl commands without requiring header inspection. Header-based versioning (e.g., Accept: application/vnd.api+json;version=2) is harder to test, harder to route in API gateways, and invisible in most HTTP logging tools. For public APIs consumed by diverse clients, URL path versioning reduces integration friction significantly.

✓ Do: Structure your API routes as /v{major}/resource (e.g., /v1/payments, /v2/payments) and configure your API gateway to route based on the path prefix, enabling independent deployment of each version.
✗ Don't: Do not rely solely on custom headers like X-API-Version or Accept header media type parameters for version routing on public APIs, as these are invisible in URL-based caching, difficult to test in browsers, and frequently stripped by proxies.

Publish a Machine-Readable Sunset Header on All Deprecated Endpoints

The IETF RFC 8594 Sunset HTTP header provides a standardized, machine-readable way to communicate when a deprecated API endpoint will be decommissioned. Client libraries and API monitoring tools can parse this header automatically to surface warnings to developers without requiring them to read changelog emails. Pairing the Sunset header with a Link header pointing to the migration guide creates a self-documenting deprecation signal directly in the HTTP response.

✓ Do: Add 'Sunset: Sat, 31 Dec 2024 23:59:59 GMT' and 'Link: ; rel="deprecation"' headers to all v1 responses as soon as v2 reaches GA status.
✗ Don't: Do not communicate deprecation only through blog posts, emails, or changelog entries, as these are easily missed by developers who inherit codebases or join teams after the announcement was made.

Maintain a Separate OpenAPI Specification File for Each Active API Version

Keeping distinct openapi-v1.yaml and openapi-v2.yaml files allows each version's contract to be independently validated, linted, and used to generate version-specific SDKs and documentation. Attempting to represent multiple versions in a single OpenAPI file using tags or discriminators creates a confusing spec that breaks most code generators and documentation tools. Separate files also enable automated diff tools like openapi-diff or oasdiff to generate precise breaking-change reports between versions.

✓ Do: Maintain versioned spec files at /docs/openapi/v1/openapi.yaml and /docs/openapi/v2/openapi.yaml, run oasdiff or similar tools in CI to automatically detect and flag breaking changes between versions before merge.
✗ Don't: Do not attempt to encode multiple API versions into a single OpenAPI specification using conditional schemas or version-specific tags, as this breaks SDK generators, documentation renderers, and contract testing tools.

Define Breaking vs. Non-Breaking Changes in a Written Versioning Policy Before You Ship v1

Without a written policy, teams debate endlessly whether adding a required field, changing an enum value, or modifying error response shapes requires a major version bump. Establishing a clear taxonomy upfront (e.g., adding optional fields is non-breaking; removing fields, renaming fields, or changing data types is breaking) removes ambiguity from code reviews and prevents accidental breaking changes from shipping in patch releases. This policy should be publicly documented so API consumers can make informed integration decisions.

✓ Do: Publish a 'What Constitutes a Breaking Change' section in your API documentation listing specific examples: removing a field, changing a field's data type, making an optional parameter required, and altering authentication schemes all require a major version increment.
✗ Don't: Do not make ad-hoc decisions about whether a change is breaking on a PR-by-PR basis without a written standard, as this leads to inconsistent versioning that erodes developer trust and causes unexpected integration failures.

Instrument Version-Specific Traffic Metrics to Drive Data-Informed Sunset Decisions

Announcing a sunset date without knowing how many clients are still on the deprecated version is operationally dangerous and can damage enterprise relationships. Tracking API call volume, unique API key counts, and error rates per version gives you the data to negotiate sunset dates confidently, identify high-value clients who need migration support, and demonstrate to stakeholders that a version is truly safe to decommission. This data also helps prioritize which deprecated endpoints need migration guides most urgently.

✓ Do: Tag all API requests with their version at the API gateway layer and stream metrics to your observability platform (e.g., Datadog, Prometheus) with dashboards showing weekly active clients per version, call volume trends, and a projected zero-traffic date based on the deprecation trend line.
✗ Don't: Do not set a sunset date based solely on time elapsed since deprecation announcement without verifying through traffic data that adoption of the replacement version is sufficient to make decommissioning safe.

How Docsie Helps with API Versioning

Build Better Documentation with Docsie

Join thousands of teams creating outstanding documentation

Start Free Trial