POST statuses/update_with_media

Updated on Wed, 2014-06-18 10:09

Updates the authenticating user's current status and attaches media for upload. In other words, it creates a Tweet with a picture attached.

Unlike POST statuses/update, this method expects raw multipart data. Your POST request's Content-Type should be set to multipart/form-data with the media[] parameter .

See Uploading Media for a guide to using this method.

The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.

Important: In API v1.1, you now use api.twitter.com as the domain instead of upload.twitter.com. Use of SSL is required with this method.

Resource URL

https://api.twitter.com/1.1/statuses/update_with_media.json

Parameters

status required

The text of your status update. URL encode as necessary. t.co link wrapping may affect character counts if the post contains URLs. You must additionally account for the characters_reserved_per_media per uploaded media, additionally accounting for space characters in between finalized URLs.

Note: Request the GET help/configuration endpoint to get the current characters_reserved_per_media and max_media_per_upload values.

media[] required

Up to max_media_per_upload files may be specified in the request, each named media[]. Supported image formats are PNG, JPG and GIF, including animated GIFs of up to 3MB . This data must be either the raw image bytes or encoded as base64.

Note: Request the GET help/configuration endpoint to get the current max_media_per_upload and photo_size_limit values.

possibly_sensitive optional

Set to true for content which may not be suitable for every audience.

in_reply_to_status_id optional

The ID of an existing status that the update is in reply to.

Note: This parameter will be ignored unless the author of the tweet this parameter references is mentioned within the status text. Therefore, you must include @username, where username is the author of the referenced tweet, within the update.

lat optional

The latitude of the location this tweet refers to. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding long parameter.

Example Values: 37.7821120598956

long optional

The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, not a number, geo_enabled is disabled, or if there not a corresponding lat parameter.

Example Values: -122.400612831116

place_id optional

A place in the world identified by a Twitter place ID. Place IDs can be retrieved from geo/reverse_geocode.

Example Values: df51dec6f4ee2b2c

display_coordinates optional

Whether or not to put a pin on the exact coordinates a tweet has been sent from.

Example Values: true

Extended description

Important: In API v1.1, you now use api.twitter.com as the domain instead of upload.twitter.com.

Users are limited to a specific daily media upload limit.. Requests to this endpoint will return the following headers with information regarding the user's current media upload limits:

  • X-MediaRateLimit-Limit - Indicates the total pieces of media the current user may upload before the time indicated in X-MediaRateLimit-Reset.
  • X-MediaRateLimit-Remaining - The remaining pieces of media the current user may upload before the time indicated in X-MediaRateLimit-Reset.
  • X-MediaRateLimit-Reset - A UTC-based timestamp (in seconds) indicating when X-MediaRateLimit-Remaining will reset to the value in X-MediaRateLimit-Limit and the user can resume uploading media.

If the user is over the daily media limit, this method will return an HTTP 403 error. In addition to media upload limits, the user is still limited in the number of statuses they can publish daily. If the user tries to exceed the number of updates allowed, this method will also return an HTTP 403 error, similar to POST statuses/update.

OAuth is handled differently for POST messages. See Uploading Media for more details on this.

Example Request

Note: The OAuth tool does not support multipart requests, so you will not be able to use it to generate an example request to this endpoint. An example request has been included to demonstrate the multipart request format.

  1. POST /1.1/statuses/update_with_media.json HTTP/1.1
  2. Host: api.twitter.com
  3. User-Agent: Go http package
  4. Content-Length: 15532
  5. Authorization: OAuth oauth_consumer_key="...", oauth_nonce="...", oauth_signature="...", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1347058301", oauth_token="...", oauth_version="1.0"
  6. Content-Type: multipart/form-data;boundary=cce6735153bf14e47e999e68bb183e70a1fa7fc89722fc1efdf03a917340
  7. Accept-Encoding: gzip
  8.  
  9. --cce6735153bf14e47e999e68bb183e70a1fa7fc89722fc1efdf03a917340
  10. Content-Disposition: form-data; name="status"
  11.  
  12. Hello 2012-09-07 15:51:41.375247 -0700 PDT!
  13. --cce6735153bf14e47e999e68bb183e70a1fa7fc89722fc1efdf03a917340
  14. Content-Type: application/octet-stream
  15. Content-Disposition: form-data; name="media[]"; filename="media.png"
  16.  
  17. ...
  18. --cce6735153bf14e47e999e68bb183e70a1fa7fc89722fc1efdf03a917340--
  1. {
  2.   "contributors": null, 
  3.   "coordinates": null, 
  4.   "created_at": "Fri Sep 07 22:46:18 +0000 2012", 
  5.   "entities": {
  6.     "hashtags": [], 
  7.     "media": [
  8.       {
  9.         "display_url": "pic.twitter.com/lX5LVZO", 
  10.         "expanded_url": "http://twitter.com/fakekurrik/status/244204973972410368/photo/1", 
  11.         "id": 244204973989187584, 
  12.         "id_str": "244204973989187584", 
  13.         "indices": [
  14.           44, 
  15.           63
  16.         ], 
  17.         "media_url": "http://pbs.twimg.com/media/A2OXIUcCUAAXj9k.png", 
  18.         "media_url_https": "https://pbs.twimg.com/media/A2OXIUcCUAAXj9k.png", 
  19.         "sizes": {
  20.           "large": {
  21.             "h": 175, 
  22.             "resize": "fit", 
  23.             "w": 333
  24.           }, 
  25.           "medium": {
  26.             "h": 175, 
  27.             "resize": "fit", 
  28.             "w": 333
  29.           }, 
  30.           "small": {
  31.             "h": 175, 
  32.             "resize": "fit", 
  33.             "w": 333
  34.           }, 
  35.           "thumb": {
  36.             "h": 150, 
  37.             "resize": "crop", 
  38.             "w": 150
  39.           }
  40.         }, 
  41.         "type": "photo", 
  42.         "url": "http://t.co/lX5LVZO"
  43.       }
  44.     ], 
  45.     "urls": [], 
  46.     "user_mentions": []
  47.   }, 
  48.   "favorited": false, 
  49.   "geo": null, 
  50.   "id": 244204973972410368, 
  51.   "id_str": "244204973972410368", 
  52.   "in_reply_to_screen_name": null, 
  53.   "in_reply_to_status_id": null, 
  54.   "in_reply_to_status_id_str": null, 
  55.   "in_reply_to_user_id": null, 
  56.   "in_reply_to_user_id_str": null, 
  57.   "place": null, 
  58.   "possibly_sensitive": false, 
  59.   "retweet_count": 0, 
  60.   "retweeted": false, 
  61.   "source": "<a href=\"http://www.google.com\" rel=\"nofollow\">Fakekurrik's Test Application</a>", 
  62.   "text": "Hello 2012-09-07 15:48:27.889593 -0700 PDT! http://t.co/lX5LVZO", 
  63.   "truncated": false, 
  64.   "user": {
  65.     "contributors_enabled": false, 
  66.     "created_at": "Fri Sep 09 16:13:20 +0000 2011", 
  67.     "default_profile": false, 
  68.     "default_profile_image": false, 
  69.     "description": "I am just a testing account, following me probably won't gain you very much", 
  70.     "entities": {
  71.       "description": {
  72.         "urls": []
  73.       }, 
  74.       "url": {
  75.         "urls": [
  76.           {
  77.             "display_url": null, 
  78.             "expanded_url": null, 
  79.             "indices": [
  80.               0, 
  81.               24
  82.             ], 
  83.             "url": "http://blog.roomanna.com"
  84.           }
  85.         ]
  86.       }
  87.     }, 
  88.     "favourites_count": 1, 
  89.     "follow_request_sent": false, 
  90.     "followers_count": 2, 
  91.     "following": false, 
  92.     "friends_count": 5, 
  93.     "geo_enabled": true, 
  94.     "id": 370773112, 
  95.     "id_str": "370773112", 
  96.     "is_translator": false, 
  97.     "lang": "en", 
  98.     "listed_count": 0, 
  99.     "location": "Trapped in factory", 
  100.     "name": "fakekurrik", 
  101.     "notifications": false, 
  102.     "profile_background_color": "C0DEED", 
  103.     "profile_background_image_url": "http://a0.twimg.com/profile_background_images/616512781/iarz5lvj7lg7zpg3zv8j.jpeg", 
  104.     "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/616512781/iarz5lvj7lg7zpg3zv8j.jpeg", 
  105.     "profile_background_tile": true, 
  106.     "profile_image_url": "http://a0.twimg.com/profile_images/2440719659/x47xdzkguqxr1w1gg5un_normal.png", 
  107.     "profile_image_url_https": "https://si0.twimg.com/profile_images/2440719659/x47xdzkguqxr1w1gg5un_normal.png", 
  108.     "profile_link_color": "0084B4", 
  109.     "profile_sidebar_border_color": "C0DEED", 
  110.     "profile_sidebar_fill_color": "FFFFFF", 
  111.     "profile_text_color": "333333", 
  112.     "profile_use_background_image": true, 
  113.     "protected": true, 
  114.     "screen_name": "fakekurrik", 
  115.     "show_all_inline_media": false, 
  116.     "statuses_count": 546, 
  117.     "time_zone": "Pacific Time (US & Canada)", 
  118.     "url": "http://blog.roomanna.com", 
  119.     "utc_offset": -28800, 
  120.     "verified": false
  121.   }
  122. }