---
title: "POST /api/v1/x/media"
method: POST
path: "/api/v1/x/media"
tags: ["X Write"]
---

# POST /api/v1/x/media

`POST /api/v1/x/media`

## Request

- Base URL: `https://xquik.com`
- URL: `https://xquik.com/api/v1/x/media`
- Auth: one of:
  - API key in header `x-api-key`
  - HTTP bearer

Uploads media and returns an identifier for later writes.

## Headers

- `Idempotency-Key` string, required

## Request body

- object
  - `account` string, required: X account (@username or ID) uploading media from URL
  - `url` string, uri, required: HTTPS URL to download and upload as media, up to 15 MB. Another scheme gets 400 `invalid_media_url`.

## Response `200`

Write reached a terminal state.

- XWriteAction: Durable write record. Poll statusUrl until terminal is true. Reusing its Idempotency-Key returns this record. Create another action only when safeToRetry is true.
  - `object` 'x_write_action', required
  - `id` string, required
  - `writeActionId` string, required
  - `action` 'create_tweet' | 'delete_tweet' | 'like' | 'unlike' | 'retweet' | 'unretweet' | 'follow' | 'unfollow' | 'remove_follower' | 'send_dm' | 'delete_dm' | 'upload_media' | 'update_profile' | 'update_avatar' | 'update_banner' | 'create_community' | 'delete_community' | 'join_community' | 'leave_community', required
  - `status` 'accepted' | 'dispatching' | 'pending_confirmation' | 'success' | 'failed' | 'expired', required
  - `terminal` boolean, required
  - `retryable` boolean, required: True only when a new attempt is likely to succeed.
  - `safeToRetry` boolean, required: True only when X did not get the write and a new idempotency key may be used.
  - `statusUrl` string, required
  - `pollAfterMs` integer, nullable, required
  - `charged` boolean, required
  - `chargedCredits` string, required
  - `billing` XWriteActionBilling, required: plannedCredits is the approved maximum. chargedCredits comes from the settled credit ledger. Xquik charges nothing for pending or failed writes.
    - `status` 'not_charged' | 'pending' | 'charged' | 'charge_failed' | 'refunded', required
    - `charged` boolean, required
    - `plannedCredits` string, required
    - `chargedCredits` string, required
  - `request` XWriteActionRequest, required: Stable fingerprint and sanitized payload for replay checks.
    - `hash` string, nullable, required: Stable hash of account, action, target, and payload.
    - `payload` object, nullable, required: Exact sanitized payload dispatched for this action.
  - `account` XWriteActionAccount, nullable, required: Connected account selected for the write.
    - `id` string, required
    - `username` string, required
  - `target` XWriteActionTarget, nullable, required: Existing X resource targeted by the write, when applicable.
    - `type` 'tweet' | 'user' | 'community', required
    - `id` string, required
  - `targetId` string, nullable, required
  - `result` XWriteActionResult, nullable, required: Confirmed result produced by the write, when available.
    - `type` 'tweet' | 'direct_message' | 'media' | 'community' | 'state_change'
    - `id` string
    - `state` string
  - `nextAction` XWriteActionNextAction, nullable, required: Exact follow-up an API client or agent should perform.
    - `type` 'poll' | 'retry' | 'verify_result' | 'fix_request', required
    - `url` string
    - `afterMs` integer: Milliseconds to wait before you poll or retry.
    - `requiresNewIdempotencyKey` boolean
  - `requestHash` string
  - `requestId` string
  - `idempotent` boolean: True when this answers a retry of an earlier request with the same Idempotency-Key.
  - `error` string
  - `message` string
  - `sendDispatched` boolean, required
  - `sendDispatchedAt` string, date-time: Dispatch timestamp when the write reached execution.
  - `createdAt` string, date-time
  - `updatedAt` string, date-time
  - `completedAt` string, date-time
  - `expiresAt` string, date-time: Deadline for resolving a non-terminal write. This is not the Idempotency-Key retention deadline.
  - `confirmedAt` string, date-time
  - `confirmationCheckedAt` string, date-time
  - `confirmationAttempts` integer
  - `tweetId` string: Compatibility field for a confirmed tweet result ID.
  - `messageId` string: Compatibility field for a confirmed direct message ID.
  - `mediaId` string: Compatibility field for a confirmed media upload ID.
  - `mediaUrl` string, uri: Public media URL when the upload creates one.
  - `communityId` string: Compatibility field for a confirmed community ID.
  - `communityName` string: Confirmed community name when available.
  - `resultId` string: Compatibility result ID for other write actions.
  - `media` object: Media count, kind, size, and billing details when used.
  - `details` object: Structured recovery context for a failed write.
  - `success` boolean, required

## Other responses

- `202`: Write accepted or dispatched. Poll Location after Retry-After. Send no other write until it ends. X's 408, 500, 502, 503 or 504 after the send gives x_write_ambiguous.
- `400`: The write request is invalid. Xquik dispatched no action.
- `401`: Unauthenticated
- `402`: Payment required. MPP reads include `WWW-Authenticate`. Authenticated reads include balances, plus checkout when the key can open it. A key that reads only gets the account page instead. A failed request never creates checkout. A caller on a plan gets top-up only, plus `credits_renew_at` when the plan renews. Guest keys offer top-up.
- `403`: The connected X account needs reauthentication or is restricted (locked, suspended, or recovering). The error code is `account_needs_reauth` or `account_restricted`.
- `404`: Connected X account not found
- `409`: The idempotency key belongs to a different write request.
- `413`: The media is over Xquik's or X's size limit.
- `415`: The file isn't a supported, readable image or video.
- `422`: X rejected the write or download. Error.code says why. `x_automation_refused` needs no wait. `x_reply_not_allowed` repeats X's refusal of a reply for 1 hour, 4 hours after X refuses it again & 24 hours after each later refusal, with `Retry-After`. Media can fail on its URL, size, origin or timeout. A video too big for X to take in time gets `x_video_too_large`, & its message names a size that works. A post into a Community gets `x_community_not_joined` when the account isn't a member, `x_community_not_selectable` when X's composer can't pick it, & `x_community_post_removed` or `x_community_post_public` when X put it outside the Community. Xquik charges nothing for any of them.
- `429`: The write hit an Xquik limit or X's `x_rate_limited`. Follow `Retry-After` when present. Otherwise back off before retrying. The follow limit's `Retry-After` is the wait until it frees, up to 24 hours.
- `500`: Write failed. Check error, safeToRetry & nextAction. x_write_failed means Xquik can't explain it.
- `503`: Tracking or the write service is down. X's 408, 500, 502, 503 or 504 before the send gives x_transient_error. Check safeToRetry.
- `default`: Unexpected error.

## Changes

- **2026-10-20** `45942c75fdc2`: 20 warning
  - added the new `topup_in_progress` enum value to the `allOf[#/components/schemas/Error]/error/oneOf[subschema #1: LegacyErrorCode]/` response property for the response status `429`
  - added the new `topup_in_progress` enum value to the `allOf[#/components/schemas/Error]/error/oneOf[subschema #2: StructuredError]/code` response property for the response status `429`
  - added the new `topup_in_progress` enum value to the `error/oneOf[subschema #1: LegacyErrorCode]/` response property for the response status `401`
  - added the new `topup_in_progress` enum value to the `error/oneOf[subschema #1: LegacyErrorCode]/` response property for the response status `403`
  - …16 more

[Operation history](https://skmtc.dev/xquik-dev/apis/xquik-api/changes/api/v1/x/media/post.md)

---

[API](https://skmtc.dev/xquik-dev/apis/xquik-api.md) · [All operations](https://skmtc.dev/xquik-dev/apis/xquik-api/llms.txt) · [OpenAPI document](https://skmtc.dev/xquik-dev/apis/xquik-api/revisions/45942c75fdc2?raw)
