Overview
This node uploads image media files to Twitter using the Twitter API. It is designed to take binary image data from a previous node (such as an image converter) and upload it directly to Twitter's media upload endpoint. This is useful in automation workflows where you want to programmatically post images or prepare media for tweets.
Common scenarios include:
- Automatically uploading images generated or processed within n8n to Twitter.
- Integrating image processing pipelines with social media posting.
- Preparing media assets for later use in Twitter posts.
Example: You have an image file converted or created earlier in your workflow, stored in binary format under a specific property. This node uploads that image to Twitter and returns the media ID, which can then be used in subsequent Twitter posting nodes.
Properties
| Name | Meaning |
|---|---|
| Binary Property | The name of the binary property containing the image data to upload. Typically "data". |
Output
The node outputs an array of JSON objects, one per input item, each containing:
success: Boolean indicating if the upload succeeded.media_id: The Twitter media ID string assigned to the uploaded media.- Additional fields returned by Twitter's media upload API response, such as size, type, and processing info.
- In case of failure (if "Continue On Fail" is enabled), includes:
success: falseerror: Error message stringdetails: Additional error details from the Twitter API response if available.
No binary output is produced by this node; it only returns JSON metadata about the uploaded media.
Dependencies
- Requires valid Twitter API credentials with OAuth1 authentication, including:
- Consumer Key
- Consumer Secret
- Access Token
- Access Token Secret
- The node uses the Twitter media upload endpoint (
https://upload.twitter.com/1.1/media/upload.json). - The input binary data must be an image MIME type (e.g.,
image/jpeg,image/png).
Troubleshooting
- Missing Credentials: If any required Twitter credential field is missing, the node will throw an error. Ensure all four OAuth1 keys/tokens are provided.
- No Binary Data Found: If the specified binary property does not exist on the input item or contains no data, an error is thrown listing available binary properties.
- Invalid Media Type: Only image MIME types are supported. Uploading non-image binary data will cause an error.
- Empty or Invalid Buffer: The binary data must be a valid, non-empty buffer.
- OAuth Errors (401 Unauthorized): Indicates invalid or disconnected Twitter credentials. Verify API keys and permissions.
- Twitter API Errors: Any non-200 response from Twitter results in an error with the status message. Check Twitter API limits and request correctness.
- Enable "Continue On Fail" to allow the workflow to proceed despite individual item errors, capturing error details in output.