How do I post to X (Twitter) with an API?
Send a request to Upload-Post with platform[]=x: POST https://api.upload-post.com/api/upload_text for tweets and threads, POST /api/upload for video and POST /api/upload_photos for images. Upload-Post posts through its own X API access, so you don't need to buy an X API tier or manage X OAuth yourself. Just connect the X account once in the dashboard. Text longer than 280 characters is automatically split into a well-formatted thread (override with x_long_text_as_post=true).
Steps
- Create an account at upload-post.com and generate an API key under API Keys (Authentication).
- Connect the X account at Manage Users (or via a white-label JWT link for your users).
- Post a tweet:
- cURL
- Python
- JavaScript
curl \
-H 'Authorization: Apikey your-api-key-here' \
-F 'user="test"' \
-F 'platform[]=x' \
-F 'title="This is my tweet content!"' \
-X POST https://api.upload-post.com/api/upload_text
import requests
response = requests.post(
"https://api.upload-post.com/api/upload_text",
headers={"Authorization": "Apikey your-api-key-here"},
data={
"user": "test",
"platform[]": "x",
"title": "This is my tweet content!",
},
)
print(response.json())
const form = new FormData();
form.append("user", "test");
form.append("platform[]", "x");
form.append("title", "This is my tweet content!");
const response = await fetch("https://api.upload-post.com/api/upload_text", {
method: "POST",
headers: { Authorization: "Apikey your-api-key-here" },
body: form,
});
console.log(await response.json());
Threads, video and images
- Threads: just send long text. Paragraphs are grouped up to 280 chars per tweet and posted as a thread, with media attached to the first tweet. Details in Upload Text.
- Video:
POST /api/uploadwithplatform[]=x(Upload Video). - Images:
POST /api/upload_photostakes up to 4 images per tweet; more images are split across a thread controlled byx_thread_image_layout(Upload Photo).
Useful X parameters
Full list in the Upload Video and Upload Text references:
| Parameter | What it does | Default |
|---|---|---|
x_title | X-specific text (falls back to title) | title |
x_long_text_as_post | Publish long text as a single post instead of a thread | false |
reply_to_id | Reply to an existing tweet | none |
community_id | Post into an X community | none |
reply_settings | Who can reply: following, mentionedUsers, subscribers, verified | none |
tagged_user_ids | Tag up to 10 users in media | [] |
first_comment / x_first_comment | Auto-reply under the post | none |
scheduled_date | ISO-8601 date to schedule the post | none |
X bills ~$0.200 per post containing a URL vs $0.015 without (13×), so Upload-Post removes clickable URLs from captions, titles and first comments on every X post. To publish posts with links, enable the X Links add-on. Details: Character Limits.
Limits and gotchas
- Daily cap (per connected X profile, rolling 24 h) is per plan: Free/Basic 10, Professional 20, Advanced/Business 30 (upload limits).
- Quote tweets with media are rejected. Post the quote as text-only via Upload Text (details).
- Replies can 403 on X's Pay-Per-Use tier when the account never engaged with the author (details).