---
title: "Uploads media to X (formerly Twitter) for attaching to tweets."
method: POST
path: "/upload"
---

# Uploads media to X (formerly Twitter) for attaching to tweets.

`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 input. The function 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.net/microfox-ai/apis/microfox-x-sdk-api.md) · [All operations](https://skmtc.net/microfox-ai/apis/microfox-x-sdk-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/microfox-ai/microfox-x-sdk-api/versions/329b4bca235b/schema)
