LateLate API
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

PropertyRequirement
Max Images4 per post
FormatsJPEG, PNG, WebP, GIF
Max File Size5 MB (images), 15 MB (GIFs)
Min Dimensions4 ร— 4 px
Max Dimensions8192 ร— 8192 px
Recommended1200 ร— 675 px (16:9)

Aspect Ratios

TypeRatioDimensions
Landscape16:91200 ร— 675 px
Square1:11200 ร— 1200 px
Portrait4:51080 ร— 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

PropertyRequirement
Max Videos1 per post
FormatsMP4, MOV
Max File Size512 MB
Max Duration2 minutes 20 seconds (140 sec)
Min Duration0.5 seconds
Max Dimensions1920 ร— 1200 px
Min Dimensions32 ร— 32 px
Frame Rate40 fps max
Bitrate25 Mbps max

For best quality on Twitter/X:

PropertyRecommended
Resolution1280 ร— 720 px (720p)
Aspect Ratio16:9 (landscape) or 1:1 (square)
Frame Rate30 fps
CodecH.264
AudioAAC, 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 .gif extension
  • 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