A video upload system encountered 403 Forbidden errors when attempting to upload videos exceeding 2 minutes (140 seconds) via X API v2, despite Premium account holders successfully posting identical videos through the web interface. The issue persisted even after regenerating OAuth 1.0a tokens and migrating domains from twitter.com to x.com.
Issue
Premium account users faced API restrictions when uploading videos longer than 2 minutes, despite having active subscriptions. The API consistently returned a 403 Forbidden error, stating that the user was not permitted to post videos exceeding this duration, even though the web interface allowed it.
Culprit
The root cause was the use of the media_category=tweet_video parameter in the API request, which enforced legacy 140-second limits regardless of Premium subscription status. This disconnect between the web interface and API permissions was a known issue in X API v2, where Premium features like extended video duration were not properly exposed via API endpoints.
Solution
Media Category Change
The solution involved replacing the tweet_video media category with amplify_video, which supports Premium duration limits. This change allowed the API to recognize and validate Premium subscriptions correctly during media processing.
Domain Migration
API endpoints were updated from legacy twitter.com domains to the current x.com domains, ensuring compatibility with the latest X API infrastructure.
Processing Improvements
- Async Polling: Added asynchronous polling to monitor video processing status, ensuring timely updates and completion tracking.
- Failed Upload Handling: Modified the system to retain failed uploads for retry rather than archiving them immediately, improving reliability and error recovery.
The solution successfully enabled the upload of videos longer than 2 minutes (e.g., 2m40s) via the API, aligning with the capabilities of the web interface. This leveraged X’s Amplify Partner Program, which properly validates Premium subscription status during media processing.