X (Twitter) Posting API
Post text, images, video and threads to X from your app, for every customer who connects an account.
- Text, images, video and threads from one endpoint
- Checked against X's length and media rules before it's sent
- Accounts connect through X's own OAuth login
- If X fails in a multi-network post, the rest still go out
const pk = new Postkey(process.env.POSTKEY_API_KEY);
await pk.posts.create({
content: "We just shipped dark mode. Settings → Appearance.",
platforms: [
{
platform: "twitter",
accountId: "int_x_789"
}
],
publishNow: true
});- Xpublished
1 call · result per platform
Your first X post in three steps
- 1
Connect X
Your customer signs in through X's own login. You get an account ID, never a password.
- 2
Get the account id
List connected accounts. The id of the new account is the accountId you post with.
- 3
Post
Send the post to /v1/posts with that accountId. The X result comes back in the response and by webhook.
Every X format, one endpoint
Pick a format to see the exact request and what comes back. Options that only make sense on X sit under "twitter".
A plain post. The simplest call there is.
1POST https://api.postkey.dev/v1/posts2x-access-key: pk_live_…3Content-Type: application/json4 5{6 "content": "We just shipped dark mode. Settings → Appearance.",7 "platforms": [8 {9 "platform": "twitter",10 "accountId": "int_x_789"11 }12 ],13 "publishNow": true14}200 · published
Live on X. If it had failed, its credits would come back.
{
"success": true,
"postId": "post_3k9d2",
"status": "published",
"platforms": [
{
"platform": "twitter",
"accountId": "int_x_789",
"success": true,
"platformPostUrl": "https://x.com/acme/status/…"
}
]
}Everything you need for X posting
Checked against X's rules
Before anything is sent, Postkey checks it against X's published limits:
Threads in one call
Send the replies as a list. Postkey posts them in order, each one replying to the last. If one fails, the rest stop and the webhook says which.
Media upload handled
Send a file or a URL. Postkey runs X's media upload, including the chunked flow for video, and attaches the result.
Retry without double posts
If X fails inside a multi-network post, retry only X. The networks that already published are never posted again.
X costs passed through
X charges for API posting, so an X post costs more credits than other networks. With your own X app, X bills you and the post costs 1 credit.
No passwords
Accounts connect through X's OAuth login. Your customers never hand you a password, and you can disconnect one without touching the rest.
Also for X
Built in
Connect, publish, get told
Your users connect X through a connect link. If X fails inside a multi-network post, the others still go out and the X credits come back.
Works with your stack
Your code
Node and Python SDKs with the same calls, or plain REST from anything that speaks HTTP.
- Node
- Python
- {}REST
No-code tools
Call the REST API from an HTTP step in n8n, Make or Zapier. One request posts to every network.
- n8n
- Make
- Zapier
AI agents & MCP
The MCP server lets Claude, Cursor and other agent tools publish and schedule posts, and read the results.
- MCP server
Beyond X
Same request shape on every platform. Add an account ID and the post goes there too.
- You're hereX Posting APIText · Image · Video · Thread
- Instagram Posting APIFeed post · Reel · Story · Carousel
- Facebook Posting APIText · Photo · Video
- TikTok Posting APIVideo · Photo
- LinkedIn Posting APIText · Image · Document
- YouTube Posting APIVideo
- YouTube Shorts Posting APIShort
- Pinterest Posting APIPin
- Google Business Posting APIUpdate post · Offer · Event
X posting questions
Something not here? Email hello@postkey.dev.
What can I post to X?
Text posts, posts with images, posts with a video, and threads. Each one is a single call to the same endpoint.
How do threads work?
Put the first post in content and the replies in threadItems. Postkey publishes them in order as replies. If one fails, it stops there and tells you which one and why.
Why do X posts cost more credits?
X charges developers for posting through its API, more for posts with a link. Postkey passes that cost through as extra credits for X only. Connect X through your own X app and an X post costs 1 credit.
Does Postkey check the length before sending?
Yes. Text and media are checked against X's published limits first, so you get a clear error instead of a failed post.
Can my customers connect their own X accounts?
Yes. They sign in with X's login screen. You get an account ID to post with and never see their password.
Can I schedule X posts instead?
Yes. Add scheduledFor to the same request. See the X Scheduling API page for details.
Post to X for every customer.
Get a key, connect an account, send the request above.
Free while it's early. Read the docs