Posts
Create a post with words, images, a video or a GIF; quote a post, with files; label a sponsored post Paid partnership; read one post; delete the account's own; pin and unpin.
Early access. Tell us what you're building and we'll set you up. Contact us
Create A Post#
POST /posts (accounts.write, Idempotency-Key required) posts from the
account's own X. JSON for words only:
curl -sS -X POST "https://api.lempile.com/posts" \
-H "X-API-KEY: $LEMPILE_API_KEY" \
-H "Idempotency-Key: launch-post-1" \
-H "Content-Type: application/json" \
-d '{ "account_id": "janedemo", "text": "Shipping today." }'multipart/form-data for pictures or a video:
curl -sS -X POST "https://api.lempile.com/posts" \
-H "X-API-KEY: $LEMPILE_API_KEY" \
-H "Idempotency-Key: launch-post-2" \
-F account_id=janedemo \
-F "text=Before and after" \
-F attachments=@before.png \
-F attachments=@after.png{ "object": "PostCreated", "provider": "X", "post_id": "1850000000000000001" }A quote of another post, with a picture and X's Paid partnership label (a sponsored post):
curl -sS -X POST "https://api.lempile.com/posts" \
-H "X-API-KEY: $LEMPILE_API_KEY" \
-H "Idempotency-Key: sponsor-quote-1" \
-F account_id=janedemo \
-F "text=This is the launch I'd actually use every morning." \
-F "quote=https://x.com/acmedemo/status/1850000000000000009" \
-F paid_partnership=true \
-F attachments=@meme.jpg{
"object": "PostCreated", "provider": "X", "post_id": "1850000000000000002",
"quote": { "post_id": "1850000000000000009", "confirmed": true },
"paid_partnership": { "shown": true, "sent": true }
}text: required, up to 3,000 characters. More than 280 needs X Premium on the account: without it X keeps the post in its box, and the answer is422 errors/not_sentwith that reason indetail.attachments(multipart only): up to 4 images (JPEG, PNG, WebP or GIF, 8 MiB = 8,388,608 bytes each), or one MP4 of up to 50 MiB (52,428,800 bytes) on its own. Over 50 MiB in all:413 errors/payload_too_large, before anything is sent.gif: a GIF from X's own GIF search,{ "query": "ship it", "url": "…" }(a JSON string in a form field).urlis a result ofGET /posts/gifs; the browser searches X again and refuses if that GIF is gone. Not with attachments.quote: the post this one quotes, as its id (a string: an X id doesn't fit in a JSON number) or its link (https://x.com/<handle>/status/<id>, twitter.com too). The browser opens that post, then its Repost menu → Quote, the way a person does, so the quote can carryattachments(a quote made by pasting a link at the end oftextcan't). Before Post it checks that X's quote box shows the quoted post. Not withgif.paid_partnership: true: X's own Paid partnership label goes on the post (the post box's Content Disclosures → Paid Partnership), for a sponsored post. Works on a plain post, with files, and on a quote. No label shown in X's post box, no post:422 errors/not_sentwithcode: "paid_label_unavailable", nothing sent.trueorfalseonly (a form field takes"true").dry_run: true: everything but the Post button, answered200{ "object": "PostDryRun", "not_sent": true }, with what the box showed:quote({ "post_id", "author", "shown": true }),paid_partnership({ "shown": true }),mediafor files ({ "ready_s": 41.2, "status": "clip.mp4: Ready" }: how long X took to take them, and its own words) andgif. A dry run also checks that Post could be pressed (on, nothing over it); if not, it answers422 errors/not_sentwithcode: "post_button_disabled", as the real post would stop there.trueorfalseonly.dry_runis part of the request, so the real post needs a newIdempotency-Key. A dry run that asked forquoteorpaid_partnershipand doesn't show it answers502 errors/not_sentwithcode: "quote_unconfirmed"or"paid_label_unconfirmed": the dry run proves nothing.
quote, paid_partnership and dry_run are part of the request too: one
Idempotency-Key never stands for both a labelled and an unlabelled post, or a
quote and a plain post. All three are X's: another account answers 400 errors/invalid_parameters.
What the answer adds when you asked for them:
quote: { post_id, confirmed }:confirmedistruewhen X's own answer names the quoted post,falsewhen it names another,nullwhen it didn't say.paid_partnership: { shown: true, sent, app }: the label was on in the box;sentistruewhen X's own request carried it,nullwhen it wasn't readable;appis which of X's two web apps the account was shown,"x-web"or"responsive-web"(the label is in a different place in each; Lempile handles both). A dry run'spaid_partnershiphasshownandapp.warnings: only when something asked for isn't confirmed on a post that went out (201, the post is live):paid_label_unconfirmed,paid_label_not_sent,quote_unconfirmed,quote_not_confirmed, each with a sentence. Check the post on X; delete it if it's wrong.
When X refuses the words as already posted by the account and the request
asked for quote or paid_partnership, nothing shows the post already on X
carries them: the answer is 422 errors/not_sent with code: "duplicate_post" and that post's link, never a success.
Files go only once X has taken them: the browser waits for X's own "Ready"
under each file (up to 3 minutes for a video, 40 seconds for images) and
answers 422 errors/not_sent with code: "media_upload_failed" (X refused
the file) or "media_upload_timeout", nothing sent. A long video can take
longer than the request's 140 seconds: read the
receipt for its key. The browser keeps the job inside
its 5 minutes: a slow upload ends as media_upload_timeout rather than a job
stopped after Post.
Big files, and the rule for any 5xx: read the receipt, never send again
under a new key. Until Nov 12 a request carrying more than about 5 MB of
files could lose its HTTP answer (500 with WorkerRequestCancelled) while
the write went on: a 12.6 MB video's answer was cut 24 seconds in, and its
receipt then said what X did. Files now travel once, without that cost, up to
the limits above. While another post's big files are being sent, a post with
files can get 429 errors/files_busy with retry_at: nothing was sent, send
it again then with the same key. On any 5xx from POST /posts, read
GET /writes/{key} with the same Idempotency-Key, or send again with the
same key; a new key could post twice. A write left pending settles by itself
within minutes (see Write Receipts).
To reply, use POST /posts/{post_id}/comments.
Posts are paced: at least 45 seconds after the account's last write, 70 writes
in 24 hours. The request waits up to 140 seconds; past that it answers
504 errors/timeout and the receipt says what
happened.
Search X's GIFs#
GET /posts/gifs?account_id=&q=&limit= (accounts.read): X's GIF search as
the composer shows it (q 2–40 characters, limit 1–24, default 12).
Nothing is typed into a post.
{ "object": "GifList", "provider": "X", "query": "ship it",
"items": [{ "url": "https://media1.giphy.com/media/demoGifId/giphy.gif", "title": "Ship it", "width": 498, "height": 280 }] }Read A Post#
GET /posts/{post_id}?account_id= (accounts.read):
{
"object": "Post", "provider": "X", "id": "1850000000000000001",
"author": "Jane Demo",
"author_details": { "id": "janedemo", "public_identifier": "janedemo", "profile_url": "https://x.com/janedemo", "profile_picture_url": "https://pbs.twimg.com/profile_images/0/demo.jpg" },
"date": "2026-11-06T09:12:00.000Z", "text": "Shipping today.",
"share_url": "https://x.com/janedemo/status/1850000000000000001",
"reply_counter": 3, "comment_counter": 3, "reaction_counter": 12, "repost_counter": 1,
"quote_counter": 0, "bookmark_counter": 2, "impressions_counter": 840, "user_reacted": false
}quote_counter, bookmark_counter and impressions_counter are null when
the post's page was read instead of X's own data.
Delete A Post#
DELETE /posts/{post_id}?account_id= (accounts.write) deletes one of the
account's own posts or replies through X's menu on it, then opens it again to
check it's gone: 200 { "object": "PostDeleted", "post_id": "…" }.
403 errors/not_own_post: someone else's post. Nothing was deleted.404 errors/post_not_found: missing or already deleted.422 errors/delete_unavailable: X's menu, its Delete item or the confirmation didn't show. Nothing was deleted.504 errors/timeout: Delete was confirmed but the post may still be there. Open it before trying again.
Pin And Unpin#
POST /accounts/{account_id}/posts/{status_id}/pin and /unpin
(accounts.write, optional Idempotency-Key, optional body
{ "dry_run": true }). X keeps one pinned post, so a new pin replaces the old
one. The answer comes once the profile shows it:
{ "object": "PostPin", "provider": "X", "status": "pinned", "status_id": "1850000000000000001",
"previous_pinned_id": "1840000000000000002", "already": false }status is pinned, unpinned, already_pinned or already_unpinned. Only
the account's own posts (400 errors/not_own_post); 502 errors/pin_unconfirmed
means check the profile before trying again.
Was this page helpful?