Resources / Guides
API versioning: URL path vs header vs query parameter
Compare the ways to version a REST API — /v1/ in the URL, a custom header, Accept media types, a query parameter or dates — with examples and when to use each.
Once other people depend on your API, you need a way to change it without breaking them. Every versioning scheme answers the same question — how does the client say which version it wants? — in a different place in the request.
1. In the URL path
GET /v1/orders/42
GET /v2/orders/42
Pros: impossible to miss; visible in logs, docs and browser address bars; trivial to route (each version can even be a separate deployment); caches treat versions as different URLs automatically.
Cons: the version applies to the whole API, so a small change to one endpoint tempts you to bump everything; URLs for "the same" resource change between versions.
Use it when: you have a public API with many clients of mixed skill. This is the most common choice, for good reason.
2. In a custom header
GET /orders/42
Api-Version: 2
Pros: URLs stay stable; you can version per request without new routes.
Cons: invisible in URLs and easy to forget; clients that omit it get a default, so you must decide what that default is and never change it silently; caches need Vary: Api-Version or they will mix versions.
Use it when: your clients are SDKs you control, so the header is always set for them.
3. In the Accept header (media type versioning)
GET /orders/42
Accept: application/vnd.example.v2+json
Pros: the most "RESTful" — the version describes the representation, not the resource; different resources can evolve independently.
Cons: awkward to test with a browser or a quick curl; unfamiliar to many developers; also needs Vary: Accept for caching.
Use it when: you have a sophisticated API with strong hypermedia conventions and clients who already work this way.
4. In a query parameter
GET /orders/42?version=2
Pros: easy to add and to test.
Cons: mixes versioning with filtering parameters; easy to drop when URLs are built by hand; optional by nature, so defaults matter just as with headers.
Use it when: you need a quick, low-ceremony option for an internal API.
5. Date-based versions
GET /orders/42
Api-Version: 2026-11-01
Each account is pinned to the version current when it signed up and upgrades explicitly. Payment APIs popularised this. It is excellent for very long-lived APIs with many small changes, but it requires infrastructure to transform responses between versions.
Side by side
| Scheme | Visible | Easy to test | Caching | Best for |
|---|---|---|---|---|
| URL path | Yes | Yes | Works by default | Public APIs |
| Custom header | No | Medium | Needs Vary | SDK-driven APIs |
| Accept media type | No | Hard | Needs Vary | Hypermedia APIs |
| Query parameter | Yes | Yes | Works by default | Internal APIs |
| Dates | No | Medium | Needs Vary | Long-lived APIs with many changes |
Whatever you pick
- Only bump the version for breaking changes. Adding a field or an endpoint isn't one.
- Publish a deprecation date for old versions and announce it well ahead.
- Log which version each client uses, so you know who to contact before you retire one.
More on what counts as breaking in API versioning best practices.
On Wisp
Wisp versions the code behind your API: every change is a numbered draft you can call at ?test before publishing, and older versions can be republished in one step. For the public contract, URL versioning (/v1/…, /v2/… as separate endpoints) works without any extra setup.
Build it with Wisp — describe an API, get it live.