Platform GuidesHow to Schedule Twitter/X Posts via API

How to Schedule Twitter/X Posts via API

Schedule tweets and Twitter/X posts programmatically with the SocialRails API. Covers character limits, media support, rate limits, and code examples.

Schedule tweets and Twitter/X posts programmatically using the SocialRails API. This guide covers character limits, supported content types, code examples, and best practices for automated Twitter posting.

Character Limits

  • Standard tweets: 280 characters
  • Twitter Blue/Premium: Up to 4,000 characters (long-form)
  • URLs count as 23 characters regardless of actual length
  • Images don't count against the character limit

Supported Content Types

TypeSupportedNotes
Text postsYesUp to 280 characters (or 4K for Premium)
ImagesYesUp to 4 images per tweet (JPEG, PNG, GIF, WebP)
VideosYesUp to 140 seconds, 512MB max
ThreadsComing soonMulti-tweet threads via batch posting
PollsNoNot supported via API

API Example

# Schedule a tweet
curl -X POST https://socialrails.com/api/v1/posts \
  -H "Authorization: Bearer sr_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Our new API! Check out the docs at socialrails.com/documentation",
    "platform": "twitter",
    "scheduled_for": "2026-03-03T14:00:00Z"
  }'

Best Practices

  • Optimal posting times: Weekdays 9-11am and 1-3pm in your audience's timezone
  • Hashtags: Use 1-2 relevant hashtags (more can reduce engagement)
  • Media: Tweets with images get 150% more retweets
  • Thread timing: If posting a thread, space tweets 1-2 minutes apart
  • Keep content concise, tweets under 100 characters see 17% higher engagement

Rate Limits

Twitter's own API limits apply in addition to SocialRails rate limits:

  • 300 tweets per 3 hours per account
  • 1,000 direct messages per 24 hours
  • Media uploads: 15 per 15 minutes

SocialRails handles these limits automatically and will retry failed posts.

Frequently Asked Questions

What is the character limit for Twitter/X API posts?
Standard tweets are limited to 280 characters. Twitter Blue/Premium accounts can post up to 4,000 characters. URLs always count as 23 characters regardless of their actual length, and images do not count against the character limit.
Can I schedule tweets through an API?
Yes. The SocialRails API lets you schedule tweets by sending a POST request to /api/v1/posts with the platform set to 'twitter' and a scheduled_for timestamp. The tweet will be published automatically at the scheduled time.
Does the Twitter API support image and video uploads?
Yes. You can attach up to 4 images per tweet (JPEG, PNG, GIF, WebP) or one video up to 140 seconds long. Upload media first via the /api/v1/media/upload endpoint, then include the media keys when creating your post.
What are Twitter's API rate limits for posting?
Twitter allows 300 tweets per 3 hours per account and 15 media uploads per 15 minutes. SocialRails tracks these limits automatically and retries failed posts when limits reset.
Updated 2 days ago