Set X Article Cover Image API | Twitter Article Header
Set the cover image on an article you own, identified by its entity id. This attaches media you have already uploaded; it does not upload anything itself, so call media/upload first and pass the media_id it returns. Works on a draft. If X refuses an edit to a published article, the API answers 422 article_published and does not bill the call; this is detected for articles among your first 100 published ones. Requires a registered session. Billed at $0.0016 per call. Cost: $0.0016 per call.
POST article/update_cover_media sets the cover image on an X article you own. It takes the article's base64 entity id and a media_id from media/upload, attaches that image as the article cover, and returns ok plus the updated article object with cover_media populated. It requires a registered session and costs $0.0016 per call. Uploading the image is a separate prior step.
Authorization
bearerAuth Pass your API key as a bearer token on every request: Authorization: Bearer <API_KEY>.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/article/update_cover_media" \ -H "Content-Type: application/json" \ -d '{ "id": "QXJ0aWNsZUVudGl0eToyMDg2NjUwMjI4OTUwNjgzNjQ4", "media_id": "2088949698573090816" }'{ "ok": true, "article": { "id": "QXJ0aWNsZUVudGl0eToyMDg2NjUwMjI4OTUwNjgzNjQ4", "rest_id": "2086650228950683648", "title": "Why we rebuilt our onboarding from scratch", "preview_text": "", "lifecycle": "Draft", "content_state": { "blocks": [], "entityMap": [] }, "cover_media": { "id": "QXBpTWVkaWE6...", "media_id": "2088949698573090816", "media_key": "3_2088949698573090816", "original_img_url": "https://pbs.twimg.com/media/....jpg", "original_img_width": 1600, "original_img_height": 900, "color_palette": [] }, "media_entities": [], "author": { "id": "44196397", "username": "elonmusk", "name": "Elon Musk" }, "created_at_secs": 1786400000, "modified_at_secs": 1786400300, "first_published_at_secs": null, "visibility_setting": null, "tweet_id": null, "public_url": null }}{ "error": "bad_request", "message": "Missing or malformed parameter. Fix the request before retrying."}{ "error": "unauthorized", "message": "The API key is missing, malformed, or revoked. Check the Authorization header."}{ "error": "insufficient_credits", "message": "Your balance is exhausted. Top up your credits to continue.", "top_up_url": "https://www.twitterapis.com/dashboard/buy-credits?utm_source=api&utm_medium=402"}{ "error": "forbidden", "message": "X refused this resource for the acting account: on a read, the account is not a participant in the DM thread, the target is protected or has blocked it, or the session was attestation-blocked for calling from a datacenter or rotating IP; on a write, the account is not authorized for the action or has no logged-in session. The credentials are still valid, so do not re-register."}{ "error": "not_found", "message": "The resource does not exist, for example a deleted tweet or a private account."}{ "ok": false, "article": null, "error": "article_published", "detail": "This article is published, and X refused the edit. Edits through this API are verified on drafts only; X's own way of editing a published article in place has not been captured. The path that avoids editing a published article: (1) POST /twitter/article/unpublish, which returns it to Draft; its announcement tweet stays up. (2) Apply article/update_title, article/update_content or article/update_cover_media. (3) POST /twitter/article/publish, which returns the announcement tweet_id. This round trip has not been verified end to end, so unpublish only an article you can afford to leave unpublished if republishing fails. If the new tweet_id differs from the old one, remove the old announcement with POST /twitter/tweet/delete if you do not want both. X said: code=214 BadRequest: Bad request. (214)", "reason": "article_published"}{ "error": "rate_limited", "message": "Too many requests. Back off and retry with exponential backoff."}{ "error": "server_error", "message": "Something failed on our side. Retry with backoff; if it persists, contact support."}Pricing
| Unit | Price |
|---|---|
| Per call | $0.0016 |
| Per 1,000 calls | $1.60 |
When to use
Use this after uploading an image with media/upload, when you want that image to be the article's header image. Reach for article/update_content instead if you want an image inside the article body.
Notes
- Upload the image first with media/upload and pass the media_id it returns. This endpoint attaches, it does not upload.
- Needs a session for the account you are writing as: either register one once (POST /customer/session), or pass per-call inline credentials as x-auth-token and x-ct0 request headers, which let a single API key act as many accounts. Returns 409 session_required if neither is supplied, 401 session_dead when the session has expired.
- A published article is not edited here. Edits are verified on drafts only: if X refuses an edit and the article is among your first 100 published ones, the call answers 422 with error article_published and is not billed. The path that avoids a published-article edit is article/unpublish (the article returns to Draft and its announcement tweet stays up), this call, then article/publish. That round trip has not been verified end to end, so only unpublish an article you can afford to leave unpublished if republishing fails.
Related endpoints
- Create Article: Start a new draft article. No request body required.
- Update Article Title: Set the title on a draft article.
- Update Article Content: Replace an article's body with a new Draft.js content_state.
FAQ
Do I upload the image through this endpoint?
No. Upload it with media/upload first, then pass the returned media_id here. This endpoint only attaches an already-uploaded image as the cover.
What should I pass for media_category?
Nothing, in almost every case. It defaults to DraftTweetImage, which is what the X article editor itself sends for a cover image. It is exposed only so you are not blocked if X starts expecting a different category.
Can I set a cover on a published article?
Only a draft is verified. If X refuses the edit and the article is among your first 100 published ones, the call answers 422 with error article_published and is not billed. Unpublish the article, set the cover, then publish it again; that round trip has not been verified end to end, so only unpublish an article you can afford to leave unpublished if republishing fails.
How do I remove a cover image?
X does not expose a clear-cover operation through this path, so there is no way to unset a cover once one is attached. You can replace it by calling this endpoint again with a different media_id.
Update Article Title POST
Set the title of an article you own, identified by its entity id. Works on a draft. If X refuses an edit to a published article, the API answers 422 article_published and does not bill the call; this is detected for articles among your first 100 published ones. Requires a registered session. Billed at $0.0016 per call. Cost: $0.0016 per call.
Update Article Content POST
Replace the body of an article you own with a new content_state, identified by its entity id. content_state is Draft.js editor-state JSON ({ blocks: [...], entityMap: [...] }) that you build client-side; in the shape the X Article editor produces. Blocks are forwarded with only key, text, type, data, entityRanges and inlineStyleRanges; X's schema rejects any other block field (depth included). Block types: unstyled, header-two, unordered-list-item, ordered-list-item, blockquote and atomic (a one-space block that carries an entity through entityRanges). entityMap is an ARRAY of { key, value: { type, mutability, data } }; entity data is snake_case on input and comes back camelCase: TWEET (an embedded post) { tweet_id }, MEDIA (an inline image) { caption, entity_key, media_items: [{ local_media_id, media_category: "DraftTweetImage", media_id }] } with media_id from media/upload, DIVIDER {}, LINK { url } over a text range, MARKDOWN { markdown } for tables. A field X does not know is refused with 422, reason validation_failed and the offending path in detail. Measured live 2026-09-18. Works on a draft. If X refuses an edit to a published article, the API answers 422 article_published and does not bill the call; this is detected for articles among your first 100 published ones. Requires a registered session. Billed at $0.0016 per call. Cost: $0.0016 per call.