YieldVault uses a header-based API versioning strategy. All API responses carry version information, and clients may explicitly negotiate a version on every request. Legacy unversioned routes emit RFC 8594-compliant deprecation headers to guide consumers toward the canonical /api/v1/ surface.
| Version | Status |
|---|---|
1.0.0 |
Current |
2.0.0-preview |
Preview |
Canonical routes are served under /api/v1/. The v2 preview prefix is /api/v2/.
See GET /api/versions for the live discovery document.
Three mechanisms are supported, evaluated in priority order (highest first):
| Priority | Mechanism | Example |
|---|---|---|
| 1 | X-API-Version request header |
X-API-Version: 1.0.0 |
| 2 | Accept-Version request header |
Accept-Version: 1.0.0 |
| 3 | version parameter in Accept media-type |
Accept: application/json;version=1.0.0 |
Accepted version strings for the current release:
1— short formv1— prefixed alias1.0.0— exact semver1.x.y— any minor/patch variant (forward-compatible with future 1.x releases)
Omitting the version header defaults the request to the current version (1.0.0).
Every response — regardless of whether a version was requested — includes:
| Header | Value | Description |
|---|---|---|
X-API-Version |
1.0.0 |
The version that processed the request |
X-API-Version-Supported |
1.0.0 |
Comma-separated list of all supported versions |
When the client requests a version string that does not match any supported version, the middleware short-circuits and returns 406 Not Acceptable before any route handler runs:
HTTP/1.1 406 Not Acceptable
X-API-Version-Supported: 1.0.0
Content-Type: application/json
{
"error": "Not Acceptable",
"status": 406,
"message": "The requested API version '2.0.0' is not supported. Supported versions: 1.0.0",
"supportedVersions": ["1.0.0"]
}The following route prefixes are on the legacy unversioned API surface:
| Legacy path prefix | Canonical successor |
|---|---|
/vault/* |
/api/v1/vault/* |
/referrals/* |
/api/v1/referrals/* |
/transactions/* |
/api/v1/transactions/* |
/portfolio/* |
/api/v1/portfolio/* |
/api/* (non-/api/v1/) |
/api/v1/* |
Every response from a deprecated path includes:
| Header | Value | Standard |
|---|---|---|
Deprecation |
true |
RFC 8594 |
Sunset |
Fri, 31 Dec 2027 23:59:59 GMT |
RFC 8594 |
Link |
</api/v1/…>; rel="successor-version" |
RFC 5988 |
X-API-Deprecation-Info |
Human-readable migration note | Non-standard informational header |
GET /vault/summary HTTP/1.1
HTTP/1.1 301 Moved Permanently
Location: /api/v1/vault/summary
Deprecation: true
Sunset: Fri, 31 Dec 2027 23:59:59 GMT
Link: </api/v1/vault/summary>; rel="successor-version"
X-API-Deprecation-Info: This endpoint is deprecated. Please migrate to /api/v1/vault/summary before Fri, 31 Dec 2027 23:59:59 GMT.
X-API-Version: 1.0.0
X-API-Version-Supported: 1.0.0- Update all base URLs from
/vault/,/referrals/,/transactions/,/portfolio/to the corresponding/api/v1/prefix. - Optionally add
Accept-Version: 1.0.0orX-API-Version: 1.0.0to requests for forward-compatibility signalling. - Handle
406 Not Acceptablein your HTTP client to detect version mismatches early. - Monitor the
Sunsetheader in your client logging to receive advance notice of removal dates.
File: backend/src/middleware/versionNegotiation.ts
Version routing: backend/src/middleware/versionRouting.ts
Discovery route: backend/src/routes/apiVersions.ts
Exported symbols:
| Symbol | Type | Description |
|---|---|---|
apiVersionMiddleware |
RequestHandler |
Express middleware — apply globally with app.use(apiVersionMiddleware) |
CURRENT_VERSION |
string |
The version string set on X-API-Version response headers |
SUPPORTED_VERSIONS |
readonly string[] |
Array of all accepted version strings |
LEGACY_SUNSET_DATE |
string |
RFC 1123 date string used in Sunset headers |
Applied in: backend/src/index.ts — registered early in the middleware stack (before routing) so that all responses carry version headers.
File: backend/src/__tests__/versionNegotiation.test.ts
Coverage areas:
X-API-VersionandX-API-Version-Supportedpresent on every responseAccept-Version— exact version, short form (1), prefix alias (v1), semver variant (1.x.y)X-API-Versionrequest header — supported, unsupported, priority overAccept-VersionAcceptmedia-typeversion=parameter — supported and unsupported values- 406 response body shape (
error,status,message,supportedVersions) - Deprecation headers on
/vault/*,/referrals/*,/transactions/*,/portfolio/* - Deprecation headers on
/api/vault/*(non-v1 legacy) - No deprecation headers on canonical
/api/v1/*routes - Requests with no version header are allowed and default to the current version