Overview
This node uploads image files to Twitter using the Twitter Media Upload API. It is designed for scenarios where you need to programmatically post images to Twitter, such as automating social media posts, integrating with content management systems, or building marketing automation workflows.
Practical examples:
- Automatically posting user-uploaded images from a website to a Twitter account.
- Scheduling and uploading promotional graphics to Twitter as part of a campaign.
- Integrating with other n8n nodes to fetch, process, and then upload images to Twitter.
Properties
| Display Name | Type | Meaning |
|---|---|---|
| Binary Property | String | The name of the binary property that contains the image data to be uploaded. |
| Media Data | String | (Optional) Raw media data as a string; if provided, this overrides the binary property. |
- Binary Property: This is required. It tells the node which input binary field contains the image file to upload.
- Media Data: Optional. If set, this raw string will be used as the image data instead of reading from the binary property.
Output
The node outputs an array of objects, each with a json field containing:
{
"success": true,
// ...all fields returned by the Twitter API response, e.g.:
"media_id": "...",
"media_id_string": "...",
"size": ...,
"expires_after_secs": ...,
"image": {
"image_type": "...",
"w": ...,
"h": ...
}
}
- On success,
successistrueand the rest of the object contains the Twitter API's response. - On failure (if "Continue On Fail" is enabled), the output will look like:
{
"success": false,
"error": "Error message",
"details": { /* error details from Twitter API, if available */ }
}
Note: The node does not output binary data; it only returns JSON responses from Twitter.
Dependencies
- Twitter Developer Account: You must have valid Twitter API credentials (API Key, API Secret, Access Token, Access Token Secret, User ID).
- n8n Credentials: The node requires a credential named
twitterApito be configured in n8n. - External Services: Internet access to
https://upload.twitter.com/1.1/media/upload.json.
Troubleshooting
Common Issues
Missing Credentials:
Error:No credentials provided
Solution: Ensure your n8n instance has the correct Twitter API credentials configured.Incomplete Credentials:
Error:Missing required Twitter OAuth credential: <Credential Name>
Solution: Double-check all required fields (User Id, Consumer Key, Consumer Secret, Access Token, Access Token Secret) are filled in your credentials.Binary Property Not Found:
Error:No binary data found in property "<propertyName>" and no image alternatives found
Solution: Make sure the input item contains the specified binary property with image data.Invalid Media Type:
Error:Invalid media type: <type>. Only images are supported.
Solution: Only image files (e.g., JPEG, PNG) are supported. Check the file type of your input.Twitter API Errors:
Error: Contains Twitter's error message and HTTP status code.
Solution: Review the error details for more information (e.g., file size too large, unsupported format).
Other Notes
- If "Continue On Fail" is enabled, errors for individual items will be reported in the output rather than stopping the workflow.
Links and References
- Twitter Media Upload API Documentation
- n8n Documentation: Working with Binary Data
- n8n Credentials Setup
If you need further help, consult the above documentation or check your n8n logs for detailed error messages.