Skip to main content
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

Call PATCH /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. Poll statusUrl after 202 until terminal becomes true.

Verify the updated Twitter banner

After a terminal write, use Twitter Profile Lookup. Open its profileBannerUrl 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. Honor Retry-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

Connect the requested account, then submit a newly approved write.

Durable write recovery

Send one unique Idempotency-Key per intended write. Reuse it only for the same account, target, payload, and media.
  1. Store id, the nested hash in request, billing, and statusUrl.
  2. Poll after Retry-After or pollAfterMs when terminal is false.
  3. Trust safeToRetry and nextAction before 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 for Retry-After. Preserve the same key.
  • After HTTP 500, retry only when safeToRetry is true.
  • After HTTP 503, poll while terminal is false.
See Get Write Action Status for every lifecycle field, terminal state, billing field, and retry rule.