Skip to main content
POST
Upload media (pre-upload for tweets)
Upload a single image, GIF, or video and receive a media_id you can attach to a tweet via post_twitter, routed through the AIsa gateway at https://api.aisa.one/apis/v1/twitter/upload_media.
This endpoint accepts multipart/form-data only — send the file as a form part. Sending a JSON body returns 400 "upload_media requires multipart/form-data with a single media file field".

Prerequisites

  • An AIsa API key (Bearer token for every request).
  • A one-time OAuth authorization for the source user. Link your X account via POST /apis/v1/twitter/auth_twitter.
  • The X session must hold media.write, tweet.read, users.read.

Two-step media flow

  1. UploadPOST /apis/v1/twitter/upload_media with the file → returns media_id.
  2. PublishPOST /apis/v1/twitter/post_twitter with { "media": { "media_ids": ["<media_id>"] } }.
post_twitter also accepts inline file parts via media_files in a single multipart request, letting you skip the pre-upload step. Use upload_media when you want to reuse one asset across several tweets, or decouple a large upload from the publish call.

Example

Response
Then attach it:

Notes

  • The file field may be named media_files, media, or file.
  • Images up to 8 MB use a single-shot upload; larger files and video are chunked automatically.
  • Unattached media expires after ~24h.
  • Media upload is a prerequisite step and is not separately metered — you are billed when you publish the tweet via post_twitter.
See Error Codes and Rate Limits for more.

Post a Tweet

Attach the media_id via media.media_ids.

Link an X Account

Start the OAuth flow this endpoint requires.

Like a Tweet

Another write endpoint using the same OAuth session.

Authorizations

Authorization
string
header
required

Your AIsa API key. The authenticated source user (the account doing the follow) is determined by the OAuth session attached to your key.

Body

multipart/form-data
media_files
file
required

The media file to upload (image/*, image/gif, or video/*). The field may also be named media or file. Images up to 8 MB use a single-shot upload; larger files and video use chunked upload automatically.

aisa_api_key
string

Optional. Normally unnecessary — the gateway resolves your account from the Authorization: Bearer header.

Response

Upload succeeded; returns the media_id to reference in post_twitter.

data
object