diff --git a/changelog.mdx b/changelog.mdx index f605fb046..605392714 100644 --- a/changelog.mdx +++ b/changelog.mdx @@ -7,6 +7,31 @@ keywords: ["changelog", "API updates", "release notes", "what's new", "API chang To subscribe to updates, please [**“Turn on notifications”**](https://help.x.com/en/managing-your-account/notifications-on-mobile-devices#:~:text=In%20the%20top%20menu,%20you,you%20would%20like%20to%20receive) for [**@API**](https://x.com/api). You can also follow this changelog in your feed reader via the [**RSS feed**](https://docs.x.com/changelog/rss.xml). + + ### Strict `x-api-minor-version` validation and supported-version hints + + Requests that send an invalid or unsupported `x-api-minor-version` header now fail fast with `400 Bad Request` (`application/problem+json`) instead of silently falling back to the default minor version: + + - **Malformed headers:** Non-integer or non-positive values return a clear `400 Invalid Request` explaining the expected positive integer format. + - **Unsupported minor versions:** Out-of-range minor versions return `400 Invalid Request` listing the currently supported v2 minor version range and live default (for example, `Supported versions for v2: 2.166-2.175 (live default: 2.175)`). + - **Response header:** Every v2 response continues to return the active `.` version in the `api-version` response header. + + See [Minor version headers](/x-api/fundamentals/versioning#minor-version-headers-api-version-and-x-api-minor-version). + + + + ### Structured RFC 7807 errors, `x-request-id`, and `x-api-minor-version` across all 5 official XDKs + + All five official XDKs (**Python**, **TypeScript**, **Java**, **C#**, and **Ruby**) now expose first-class correlation, retry, and structured error properties on `ApiError` / `XApiException` alongside client-level API minor version pinning: + + - **Correlation & retry metadata:** `request_id` / `requestId` (`x-request-id`, also appended to exception messages), `retry_after` / `retryAfter` (`retry-after` header with JSON body fallback), and `api_version` / `apiVersion` (`api-version`). + - **Structured `403`, `402`, and `429` fields:** Typed accessors for `error_type`, `title`, `detail`, `missing_scopes`, `provided_auth_type`, `supported_auth_types`, `used`, `cap`, `billing_url`, `limit_scope`, `limit_window`, `limit`, `remaining`, and `reset`. + - **Backwards-compatible Python `ApiError`:** `xdk.ApiError` subclasses `requests.HTTPError`, so existing `except requests.HTTPError:` handlers keep working unchanged. + - **Client-level `x-api-minor-version` pinning:** Pass `api_minor_version` (Python/Ruby) or `apiMinorVersion` / `ApiMinorVersion` (TypeScript/Java/C#) when constructing a client. + + See [Versioning](/x-api/fundamentals/versioning#pinning-in-official-xdks) and [Response Codes & Errors](/x-api/fundamentals/response-codes-and-errors#error-types). + + ### .NET Framework 4.7.2+ support for C# XDK (`XDevPlatform.Xdk` `0.4.0`) diff --git a/x-api/fundamentals/versioning.mdx b/x-api/fundamentals/versioning.mdx index 4aa8cc3b4..5ca6355b7 100644 --- a/x-api/fundamentals/versioning.mdx +++ b/x-api/fundamentals/versioning.mdx @@ -35,6 +35,83 @@ https://api.x.com/2/tweets --- +## Minor version headers (`api-version` and `x-api-minor-version`) + +Every X API v2 response includes an `api-version` response header reporting the exact `.` version that served your request (for example, `api-version: 2.175`). + +By default, requests are served at the current live minor version. To pin a specific supported minor version for a request, pass the positive integer minor version in the `x-api-minor-version` request header: + +```bash +curl -H "Authorization: Bearer $BEARER_TOKEN" \ + -H "x-api-minor-version: 175" \ + "https://api.x.com/2/tweets/search/recent?query=from:XDevelopers" +``` + +### Strict validation on `x-api-minor-version` + +Invalid or unsupported `x-api-minor-version` headers return `400 Bad Request` (`application/problem+json`) instead of silently falling back to the default version: + +- **Malformed header value** (non-integer or non-positive, e.g. `x-api-minor-version: notanumber`): + ```json + { + "type": "https://api.x.com/2/problems/invalid-request", + "title": "Invalid Request", + "detail": "Invalid x-api-minor-version header value 'notanumber'. Expected a positive integer minor version (e.g. '175').", + "status": 400 + } + ``` +- **Unsupported minor version** (outside the active supported range, e.g. `x-api-minor-version: 9999`): + ```json + { + "type": "https://api.x.com/2/problems/invalid-request", + "title": "Invalid Request", + "detail": "One or more parameters to your request was invalid.", + "errors": [ + { + "message": "API version 2.9999 is not supported. Supported versions for v2: 2.166-2.175 (live default: 2.175)." + } + ] + } + ``` + +### Pinning in official XDKs + +All five official XDKs support client-level `x-api-minor-version` configuration: + + +```python Python +from xdk import Client + +client = Client(bearer_token="...", api_minor_version=175) +``` + +```typescript TypeScript +import { Client } from "@xdevplatform/xdk"; + +const client = new Client({ bearerToken: "...", apiMinorVersion: 175 }); +``` + +```java Java +XClient client = XClient.builder() + .bearerToken("...") + .apiMinorVersion(175) + .build(); +``` + +```csharp C# +var client = new XClient(new XClientOptions { + BearerToken = "...", + ApiMinorVersion = "175" +}); +``` + +```ruby Ruby +client = Xdk::Client.new(bearer_token: "...", api_minor_version: 175) +``` + + +--- + ## Breaking vs. non-breaking changes ### Breaking changes (require code updates)