From d5ba6f079b717d26383e96faa10997cbce608c75 Mon Sep 17 00:00:00 2001 From: Taylor Caldwell Date: Thu, 3 Dec 2026 16:57:51 -0800 Subject: [PATCH] Document structured 403/402/429 error fields and Console spend guardrails --- changelog.mdx | 23 +++++++++++++++++++ .../response-codes-and-errors.mdx | 13 +++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/changelog.mdx b/changelog.mdx index 567745d90..6b57727ec 100644 --- a/changelog.mdx +++ b/changelog.mdx @@ -27,6 +27,29 @@ To subscribe to updates, please [**“Turn on notifications”**](https://help.x - **Java XDK (`com.x:xdk:0.4.0`):** Lowered minimum JVM version to Java 8 with an Apache HttpClient 5 default transport supporting full streaming and idle-timeout recovery on Java 8+. See [Java XDK](/xdks/java/overview). + + ### Structured error fields on `403`, `402`, and usage-cap `429` responses + + X API v2 auth, billing, and usage-cap errors now include machine-readable RFC 7807 extension fields alongside existing `type`, `title`, `detail`, and `status` fields so clients and SDKs can handle failures programmatically without parsing error text: + + - **`403 Missing OAuth2 Scopes` (`.../missing-scopes`):** Includes `"missing_scopes": [...]` listing each scope required by the endpoint that is absent from the token. + - **`403 Unsupported Authentication` (`.../unsupported-authentication`):** Includes `"provided_auth_type"` and `"supported_auth_types": [...]`. + - **`429 Usage Capped` (`.../usage-capped`):** Includes `"used"` and `"cap"` counts alongside an enriched `detail` message. + - **`402 Payment Required` (`.../credits-depleted`):** Includes `"billing_url": "https://console.x.com"`. + + No request changes are needed. See [Response Codes & Errors](/x-api/fundamentals/response-codes-and-errors#error-types). + + + + ### Spend pace forecasting and credit runway guardrails + + The [Developer Console](https://console.x.com) Credits page now surfaces live spend-pace forecasting and low-runway warnings for Pay-Per-Use accounts: + + - **Daily burn rate and cycle projection:** Once at least 24 hours have elapsed in your current billing cycle, the Spend cap section shows your daily pace and projected end-of-cycle spend (including when no spend cap is set). + - **Early spend-cap warning:** When your current pace is projected to exceed your billing-cycle spend cap before the cycle ends, an amber notice highlights the estimated date you will reach the cap. + - **Credit runway guardrail:** When auto-recharge is inactive and your remaining balance covers 14 days or fewer at your current burn rate, a warning badge appears beneath your remaining balance. + + ### `x-request-id`, `Retry-After`, and actionable `429` error details diff --git a/x-api/fundamentals/response-codes-and-errors.mdx b/x-api/fundamentals/response-codes-and-errors.mdx index 0b49b2b20..96762a4ef 100644 --- a/x-api/fundamentals/response-codes-and-errors.mdx +++ b/x-api/fundamentals/response-codes-and-errors.mdx @@ -74,7 +74,10 @@ Additional fields may be present depending on the error type. | `.../resource-not-found` | Post, user, or other resource doesn't exist | | `.../not-authorized-for-resource` | No access to private/protected content, or request blocked by account IP allowlist | | `.../client-forbidden` | App not enrolled or lacks required access | -| `.../usage-capped` | Usage cap exceeded | +| `.../missing-scopes` | OAuth 2.0 user token is missing one or more required scopes (`missing_scopes` array lists each missing scope) | +| `.../unsupported-authentication` | Authentication type is not permitted for this endpoint (`provided_auth_type` and `supported_auth_types` list what was sent vs accepted) | +| `.../credits-depleted` | Account credit balance is depleted (`402 Payment Required`, includes `billing_url`) | +| `.../usage-capped` | Monthly usage cap exceeded (`429 Too Many Requests`, includes `used` and `cap`) | | `.../rate-limit-exceeded` | Rate limit exceeded | | `.../streaming-connection` | Stream connection problem | | `.../rule-cap` | Too many filtered stream rules | @@ -127,11 +130,17 @@ This happens when requesting multiple resources and some are unavailable. **Check your access:** - Verify your app has access to this endpoint - Some endpoints require specific enrollment or approval -- User-context endpoints need appropriate OAuth scopes +- **Missing OAuth 2.0 scopes** (`.../missing-scopes`): Inspect the structured `missing_scopes` array in the JSON response to see the exact scopes to request during authorization +- **Unsupported authentication** (`.../unsupported-authentication`): Inspect `provided_auth_type` and `supported_auth_types` in the JSON response to see which authentication methods the endpoint accepts on your plan - The resource may be private or protected - If the response body has `"type": "https://api.x.com/2/problems/not-authorized-for-resource"` and `"detail": "client IP not allowed: "` (or `"client IP not allowed"`), your developer account has an active [IP allowlist](/fundamentals/ip-allowlist) that does not cover the request's egress IP. Check the IP reported in `detail`, add it (or its CIDR block) under **Developer Console → Settings → IP allowlist** as an account Administrator, and allow a few seconds to a few minutes for propagation. Note that IPv4 and IPv6 blocks match only their own address family. + +**Credits depleted (`.../credits-depleted`):** +- Your Pay-Per-Use credit balance has reached zero. Top up credits or enable auto-recharge at the `billing_url` returned in the response (`https://console.x.com`). + + **Rate limited:** - Wait for the duration in the `retry-after` response header (covers 1-second, 15-minute, and 24-hour limits without clock skew), or fall back to `x-rate-limit-reset`