# 400 Bad Request: API version header 'X-API-Version' is required and must be a valid semver

- **ID:** `api/rest-api-version-mismatch-header`
- **Domain:** api
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

The client did not include the required 'X-API-Version' header in the request, or the value does not conform to semantic versioning (e.g., '2.0' instead of '2.0.0').

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| REST API best practices 2023+ | active | — | — |
| Spring Boot 3.x | active | — | — |
| FastAPI 0.100+ | active | — | — |
| Express.js 4.x | active | — | — |

## Workarounds

1. **Add the 'X-API-Version' header with a valid semver value. Example in cURL:
curl -H 'X-API-Version: 2.0.0' https://api.example.com/resource** (95% success)
   ```
   Add the 'X-API-Version' header with a valid semver value. Example in cURL:
curl -H 'X-API-Version: 2.0.0' https://api.example.com/resource
   ```
2. **Check the API documentation for the exact version string required (e.g., '1.0.0', '2.1.3').** (90% success)
   ```
   Check the API documentation for the exact version string required (e.g., '1.0.0', '2.1.3').
   ```
3. **If using an HTTP client library, set default headers. Example in Python requests:
headers = {'X-API-Version': '2.0.0'}
response = requests.get('https://api.example.com/resource', headers=headers)** (95% success)
   ```
   If using an HTTP client library, set default headers. Example in Python requests:
headers = {'X-API-Version': '2.0.0'}
response = requests.get('https://api.example.com/resource', headers=headers)
   ```

## Dead Ends

- **** — The server strictly requires the header; omitting it results in a 400 error. (90% fail)
- **** — The server expects a full semver string (e.g., '2.0.0'); partial versions are rejected. (70% fail)
- **** — The server specifically looks for 'X-API-Version'; other headers are ignored. (95% fail)
