In this categoryIntegrations · 69
Chat Apps & Bots
Docs, Sheets & Email
IntegrationsIntermediate

How to Pin an API Version for a Stable Integration

Send an explicit API version header so a provider's updates cannot silently change responses and break your integration.

8 minIntermediate

Many APIs ship breaking changes behind dated versions. If your code does not name a version, the provider may move you to a newer default and silently change a response shape. Pinning a version header makes your integration stable until you choose to upgrade. This guide pins one and upgrades it deliberately.

What you need

  • An integration that calls a versioned API
  • The provider's current version string from their docs
  • About 8 minutes

Step 1: Find the version mechanism

Check the provider's docs for how versions are selected. Most use a request header; some use a URL segment. Note the exact current version string.

StyleWhere it goesExample
HeaderRequest headerAPI-Version: 2026-05-01
URL segmentPath prefix/v2/orders
Account defaultProvider dashboardset per project

Step 2: Send the version explicitly

Add the version header to your client so every request names it. Read the value from config, not a literal scattered through the code, so one change updates it everywhere.

src/lib/apiClient.ts
const API_VERSION = process.env.PROVIDER_API_VERSION ?? "2026-05-01";

export async function getOrders(): Promise<Response> {
  return fetch("https://api.provider.com/orders", {
    headers: {
      Authorization: `Bearer ${process.env.PROVIDER_KEY ?? ""}`,
      "API-Version": API_VERSION,
    },
  });
}

Step 3: Verify the pinned version is used

Make a call and confirm the response reports the version you pinned. Most providers echo it back in a response header.

zsh - check header
$curl -sD - https://api.provider.com/orders -H 'API-Version: 2026-05-01' -o /dev/null
HTTP/2 200
api-version: 2026-05-01
echoed version matches what you pinned
$

Step 4: Upgrade on purpose later

When you are ready for a newer version, read its changelog, bump the config value in a branch, run your tests, and merge. The upgrade becomes a reviewed change instead of a surprise.

An unpinned client is a time bomb
Without a pinned version you inherit the provider's default, which moves over time. A response your code relied on can change shape between deploys with no change on your side. Pin it.

Result: your integration speaks one fixed API version that only changes when you decide, so provider updates stop breaking you without warning.

Watch related tutorials

Free weekly email

New guides in your inbox

Fresh step-by-step how-to guides as we publish them. One email a week, no more.

Tags
#integrations#api#versioning#stability#headers