---
title: "Uploads a media file to X (formerly Twitter) for attachment to a tweet."
method: POST
path: "/upload"
---

# Uploads a media file to X (formerly Twitter) for attachment to a tweet.

`POST /upload`

This function uploads a media file to X, which can then be attached to a tweet. It takes a Buffer object containing the media file and its MIME type as parameters, and returns a promise that resolves to a MediaUploadResponse object containing details about the uploaded media.

## Request body

- object
  - `body` object — Body of the upload sls call
    - `arguments` unknown[], required
      - unknown
    - `auth` object — Authentication object
      - `strategy` 'apikey' — Authentication strategy
      - `variables` unknown[] — Variables for the authentication strategy
        - unknown
    - `packageName` string — @microfox/twitter

## Response `200`

Successful media upload

- object
  - `media_id` number — The media ID as a number.
  - `media_id_string` string, required — The media ID as a string.
  - `size` number — The size of the media file in bytes.
  - `expires_after_secs` number — The number of seconds until the uploaded media expires.
  - `image` object — Image information (if applicable).
    - `image_type` string — The type of the image.
    - `w` number — The width of the image.
    - `h` number — The height of the image.

## Other responses

- `400` — Bad request
- `500` — Server error

---

[API](https://skmtc.dev/microfox-ai/apis/microfox-x-sdk-api.md) · [All operations](https://skmtc.dev/microfox-ai/apis/microfox-x-sdk-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/microfox-ai/microfox-x-sdk-api/revisions/9a6d6c9f0b84/schema)
