Platforms
Twitter/X API
Post to Twitter/X with Late API - tweets, threads, images, videos, and GIFs
Quick Start
Post to Twitter/X in under 60 seconds:
curl -X POST https://getlate.dev/api/v1/posts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Hello from Late API! ๐",
"platforms": [
{"platform": "twitter", "accountId": "YOUR_ACCOUNT_ID"}
],
"publishNow": true
}'const response = await fetch('https://getlate.dev/api/v1/posts', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: 'Hello from Late API! ๐',
platforms: [
{ platform: 'twitter', accountId: 'YOUR_ACCOUNT_ID' }
],
publishNow: true
})
});
const { post } = await response.json();
console.log('Tweet posted!', post._id);import requests
response = requests.post(
'https://getlate.dev/api/v1/posts',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json={
'content': 'Hello from Late API! ๐',
'platforms': [
{'platform': 'twitter', 'accountId': 'YOUR_ACCOUNT_ID'}
],
'publishNow': True
}
)
post = response.json()
print(f"Tweet posted! {post['_id']}")Image Requirements
| Property | Requirement |
|---|---|
| Max Images | 4 per post |
| Formats | JPEG, PNG, WebP, GIF |
| Max File Size | 5 MB (images), 15 MB (GIFs) |
| Min Dimensions | 4 ร 4 px |
| Max Dimensions | 8192 ร 8192 px |
| Recommended | 1200 ร 675 px (16:9) |
Aspect Ratios
| Type | Ratio | Dimensions |
|---|---|---|
| Landscape | 16:9 | 1200 ร 675 px |
| Square | 1:1 | 1200 ร 1200 px |
| Portrait | 4:5 | 1080 ร 1350 px |
Post with Image
curl -X POST https://getlate.dev/api/v1/posts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Check out this photo! ๐ธ",
"mediaItems": [
{"url": "https://example.com/photo.jpg"}
],
"platforms": [
{"platform": "twitter", "accountId": "YOUR_ACCOUNT_ID"}
],
"publishNow": true
}'const response = await fetch('https://getlate.dev/api/v1/posts', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: 'Check out this photo! ๐ธ',
mediaItems: [
{ url: 'https://example.com/photo.jpg' }
],
platforms: [
{ platform: 'twitter', accountId: 'YOUR_ACCOUNT_ID' }
],
publishNow: true
})
});response = requests.post(
'https://getlate.dev/api/v1/posts',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json={
'content': 'Check out this photo! ๐ธ',
'mediaItems': [
{'url': 'https://example.com/photo.jpg'}
],
'platforms': [
{'platform': 'twitter', 'accountId': 'YOUR_ACCOUNT_ID'}
],
'publishNow': True
}
)GIF Support
Twitter/X has excellent GIF support:
- Max file size: 15 MB
- Max dimensions: 1280 ร 1080 px
- Animated GIFs play automatically in timeline
- Only 1 GIF per post (counts as all 4 image slots)
{
"content": "Check out this animation!",
"mediaItems": [
{ "url": "https://example.com/animation.gif" }
],
"platforms": [
{ "platform": "twitter", "accountId": "acc_123" }
]
}Video Requirements
| Property | Requirement |
|---|---|
| Max Videos | 1 per post |
| Formats | MP4, MOV |
| Max File Size | 512 MB |
| Max Duration | 2 minutes 20 seconds (140 sec) |
| Min Duration | 0.5 seconds |
| Max Dimensions | 1920 ร 1200 px |
| Min Dimensions | 32 ร 32 px |
| Frame Rate | 40 fps max |
| Bitrate | 25 Mbps max |
Recommended Video Specs
For best quality on Twitter/X:
| Property | Recommended |
|---|---|
| Resolution | 1280 ร 720 px (720p) |
| Aspect Ratio | 16:9 (landscape) or 1:1 (square) |
| Frame Rate | 30 fps |
| Codec | H.264 |
| Audio | AAC, 128 kbps |
Threads (Multi-Tweet)
Create Twitter threads with multiple connected tweets:
curl -X POST https://getlate.dev/api/v1/posts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platforms": [{
"platform": "twitter",
"accountId": "YOUR_ACCOUNT_ID",
"platformSpecificData": {
"threadItems": [
{
"content": "1/ Starting a thread about API design ๐งต",
"mediaItems": [{"url": "https://example.com/image1.jpg"}]
},
{
"content": "2/ First, always use proper HTTP methods..."
},
{
"content": "3/ Second, version your APIs from day one..."
},
{
"content": "4/ Finally, document everything! /end"
}
]
}
}],
"publishNow": true
}'const response = await fetch('https://getlate.dev/api/v1/posts', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
platforms: [{
platform: 'twitter',
accountId: 'YOUR_ACCOUNT_ID',
platformSpecificData: {
threadItems: [
{
content: '1/ Starting a thread about API design ๐งต',
mediaItems: [{ url: 'https://example.com/image1.jpg' }]
},
{ content: '2/ First, always use proper HTTP methods...' },
{ content: '3/ Second, version your APIs from day one...' },
{ content: '4/ Finally, document everything! /end' }
]
}
}],
publishNow: true
})
});response = requests.post(
'https://getlate.dev/api/v1/posts',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json={
'platforms': [{
'platform': 'twitter',
'accountId': 'YOUR_ACCOUNT_ID',
'platformSpecificData': {
'threadItems': [
{
'content': '1/ Starting a thread about API design ๐งต',
'mediaItems': [{'url': 'https://example.com/image1.jpg'}]
},
{'content': '2/ First, always use proper HTTP methods...'},
{'content': '3/ Second, version your APIs from day one...'},
{'content': '4/ Finally, document everything! /end'}
]
}
}],
'publishNow': True
}
)Common Issues
Image Too Large
Twitter rejects images over 5 MB. Compress before upload or Late will attempt automatic compression.
GIF Won't Animate
- Check file size (must be โค 15 MB)
- Ensure it's a true animated GIF, not a static image with
.gifextension - Twitter may convert large GIFs to video
Video Rejected
Common causes:
- Duration over 2:20
- File size over 512 MB
- Unsupported codec (use H.264)
- Frame rate over 40 fps
Related API Endpoints
- Connect Twitter Account โ OAuth flow
- Create Post โ Post creation and scheduling
- Upload Media โ Image and video uploads
- Analytics โ Post performance metrics