X write
Twitter profile banner API: update header images
Use the Twitter profile banner API to update an X header image. Upload JPEG or PNG, verify 1500 × 500 pixel dimensions, and poll asynchronous write responses.
PATCH
Twitter profile banner API: update header images
Use this Twitter profile banner API to update one connected account’s header
image. Upload a JPEG or PNG file, or provide a fetchable HTTPS image URL. The
maximum file size is 2 MB. X recommends 1500 × 500 pixels for profile banners.
Update a Twitter profile banner through the API
CallPATCH /x/profile/banner to replace the wide header image. Use
Update Avatar for the profile picture.
Use Update Profile for names and other
public text fields. This route never retrieves another user’s banner.
10 credits per call · All plans from $0.00012/credit
Prepare Twitter profile banner dimensions
Use a 1500 × 500 pixel canvas. This Twitter banner size has a 3:1 aspect ratio. These Twitter profile banner dimensions match X’s recommended header dimensions. The Twitter profile banner size must remain at 2 MB or smaller. Preserve high resolution while meeting that file size. Accept only JPEG or PNG image formatting. This route does not support animated GIFs. Export JPEG or PNG with your design tool or Twitter header template. Review every template export before uploading. Read X’s profile banner guidance for current layout recommendations. Preview the banner on desktop and a mobile device. The profile picture can cover the bottom left corner. Keep faces, logos, and text outside that area. Different banner sizes or crops can hide important artwork. Validate the Twitter header size before queueing the write. A saved 1500 x 500 pixels template can save time on recurring updates. Keep one perfectly sized source for each approved campaign. Export banner images from that source instead of resizing previous uploads. Record the header dimensions and final file size beside the source. A social media platform preview cannot replace the desktop and mobile checks above. Keep the account’s online presence consistent with approved logos and colors. Check the image size before upload. Do not assume a banner will boost engagement. Measure profile visits and follows separately.Automate a safe Twitter banner update
Create one idempotency key for the selected account and banner. Reuse it only after an exact network interruption. Generate a new key after changing the image or account. A 200 response is terminal. PollstatusUrl after 202 until
terminal becomes true.
Verify the updated Twitter banner
After a terminal write, use Twitter Profile Lookup. Open itsprofileBannerUrl value. Compare the rendered header with the approved source.
Check desktop and mobile crops. Store the action ID and verification timestamp.
Fix Twitter profile banner API errors
Fix invalid image fields after 400. Replace authentication after 401. Add credits after 402. Reconnect after 403. Connect a missing account after 404. Keep the original action after 409. Replace rejected media after 422. HonorRetry-After after 429. Check safeToRetry after 500 or 503.
Headers
string
required
Your API key. OAuth bearer authentication is also supported. Generate a key from the dashboard.
string
required
Unique key for this intended write. Reuse it only for an exact network replay.
string
required
Use
multipart/form-data for file uploads or application/json for URL uploads. Most HTTP clients set the multipart boundary automatically.Body
string
required
X username or account ID of your connected account to act as.
binary
Multipart upload file. Required unless
url is provided. Accepted formats: JPEG, PNG. Maximum file size: 2 MB.string
HTTPS image URL. Required unless
file is provided. The URL must use HTTPS and remain directly fetchable.Response
- 404 Account not found
Connect the requested account, then submit a newly approved write.
Durable write recovery
- Store
id, the nestedhashinrequest,billing, andstatusUrl. - Poll after
Retry-AfterorpollAfterMswhenterminalisfalse. - Trust
safeToRetryandnextActionbefore any new write.
200 Terminal or 202 active
Store terminal results. Poll active actions without creating another write.- After HTTP
200, store the result and settled billing. - After HTTP
202, poll the same action. Never submit another write. - After HTTP
400, fix the named field. Use a new idempotency key. - After HTTP
401, fix authentication. Do not retry unchanged. - After HTTP
402, fund the account before another write. - After HTTP
403, reconnect the account. - After HTTP
409, keep the original action. Use a new key for new input. - After HTTP
422, fix the rejected request before retrying. - After HTTP
429, wait forRetry-After. Preserve the same key. - After HTTP
500, retry only whensafeToRetryistrue. - After HTTP
503, poll whileterminalisfalse.
Twitter profile banner API: update header images