Versioninghard5-8 years

URI versioning, header versioning, or media-type versioning — how do you choose, and what does each cost you operationally?

URI versioning (/v2/orders) is visible in a log or a curl command, trivially routable at a gateway, and needs no special dispatch mechanism — it's just an ordinary path pattern. Header versioning (X-API-Version: 2) keeps the URL stable but is invisible to a developer pasting a URL, and needs the dispatcher to match on more than the path. Media-type versioning (Accept: application/vnd.example.order.v2+json) is the formally correct use of HTTP content negotiation, but almost nobody does it because parsing the version out of a vendor-specific media type isn't something a default JSON converter does — you have to build that mapping yourself. URI versioning is the practical default unless there's a specific reason otherwise.

The lesson behind it →