How to Schedule Twitter/X Posts via API
Schedule tweets, threads, and Twitter/X posts programmatically with the SocialRails API. Covers character limits, threading, 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
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-15T14:00:00Z"
}'Scheduling a Thread
Use the thread array to create multi-tweet threads. Each item becomes a tweet, posted as replies in sequence.
curl -X POST https://socialrails.com/api/v1/posts \
-H "Authorization: Bearer sr_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Thread start",
"platform": "twitter",
"scheduled_for": "2026-03-15T14:00:00Z",
"thread": [
"1/ Here is why we built SocialRails",
"2/ Managing 9 platforms from one API",
"3/ Try it free at socialrails.com"
]
}'- 2-25 items per thread, each up to 4,000 characters
- Attach media per thread item with
thread_media:{"0": ["media-key"], "2": ["media-key"]} - Control pacing with
thread_delay(0-60 minutes between items)
See the full Threading API reference for details.
First Comment
Automatically post a reply to your tweet right after it goes live. Use this for adding context, a call-to-action, or hashtags that you don't want in the main tweet.
curl -X POST https://socialrails.com/api/v1/posts \
-H "Authorization: Bearer sr_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "We just shipped a huge update to our API!",
"platform": "twitter",
"scheduled_for": "2026-03-15T14:00:00Z",
"first_comment": "Full changelog here: socialrails.com/changelog #buildinpublic"
}'The first comment is posted as a reply to the original tweet. Max 2,200 characters. Not available on thread posts.
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.