Use POST /x/media when an app, support queue, CRM, workflow tool, or AI agent needs to turn a local file or hosted HTTPS media URL into media that Xquik can attach to a tweet, reply, or DM.
mediaUrl
Store mediaUrl for tweet and reply attachments. Pass it in the media
array on POST /x/tweets.
mediaId
Store mediaId for direct message attachments. Pass it as the only item in
media_ids on POST /x/dm/{userId}.
success
Store success to confirm the upload completed before the next write call.
account
Store the account you submitted to audit which connected X account
uploaded and sent the media.
Source input
Store the source URL or filename to reconcile generated images, support
files, or CRM assets with the uploaded media.
For tweets with already-public image URLs or exactly 1 public MP4 video URL up to 100 MB, skip this endpoint and call POST /x/tweets directly with media. After uploading through this endpoint, call POST /x/tweets and pass media: ["<mediaUrl>"]. To post a media reply, also pass reply_to_tweet_id. Do not send media_ids to POST /x/tweets; that endpoint returns 400 unsupported_field and expects public media URLs.For DMs, call POST /x/dm/{userId} after upload and pass media_ids: ["<mediaId>"]. DMs accept exactly 1 uploaded media ID.For JSON URL upload, the URL must use HTTPS, resolve to a public address, return AVIF, GIF, JPEG, PNG, WebP, or MP4 content, finish within 30 seconds, and stay at or below 15,728,640 bytes. URL download failures return 422 media_download_failed; fix the URL or switch to multipart upload.Upload media costs 10 credits per upload call. Posting the tweet, posting the reply, or sending the DM is a separate 10-credit write call.
HTTPS URL to download media from. Required if file is not provided. The server fetches the file from this URL. Useful for AI agents and MCP clients that work with URLs instead of binary file uploads.
X rejected the write or the media URL could not be downloaded. Possible codes: x_content_too_long, x_duplicate_action, x_account_suspended, x_account_protected, x_target_not_found, x_account_feature_required, x_rejected, media_download_failed (URL fetch path only - body.url not HTTPS, resolves to private IP, file too large, origin error, or timeout). See error handling for details.
The request hit an Xquik tier limit, or X throttled the upload. Possible codes: rate_limit_exceeded, x_rate_limited, or x_daily_limit. Respect the Retry-After header when present.