SocialRails CLICLI Getting Started

CLI Getting Started

Install the SocialRails CLI and schedule your first post from the terminal.

The SocialRails CLI lets you schedule posts, manage accounts, generate AI content, and view analytics from your terminal. All output is JSON, making it ideal for scripting, CI/CD pipelines, and AI agent integrations.

Installation

npm install -g socialrails

Setup

Set your API key as an environment variable:

export SOCIALRAILS_API_KEY="sr_live_your_key_here"

Get your key from Dashboard > Settings > API Keys.

Optionally override the API URL (defaults to https://socialrails.com/api/v1):

export SOCIALRAILS_API_URL="https://socialrails.com/api/v1"

Your First Command

List your connected accounts to verify everything works:

socialrails accounts

Schedule a post:

socialrails posts:create -c "Hello from the CLI!" -p twitter -s "2026-03-15T14:30:00Z"

Workflow Examples

Schedule a post with media

# 1. Upload the image
MEDIA=$(socialrails upload ./hero.jpg --type image | jq -r '.data.key')
 
# 2. Schedule the post with the uploaded media
socialrails posts:create \
  -c "New blog post is live!" \
  -p twitter \
  -s "2026-03-15T14:30:00Z" \
  -m "$MEDIA"

Cross-platform scheduling

socialrails posts:batch \
  -c "We just hit 10,000 users! Thank you all." \
  --platforms twitter,linkedin,facebook,threads,bluesky \
  -s "2026-03-15T12:00:00Z"

AI Agent Guide

The CLI outputs JSON to stdout and errors to stderr, making it easy for AI agents (Claude, GPT, etc.) to use:

  1. Discover accounts: socialrails accounts
  2. Check capabilities: socialrails accounts:settings <id>
  3. Generate content: socialrails ai:generate --prompt "..."
  4. Schedule posts: socialrails posts:create -c "..." -p <platform> -s "..."
  5. Verify: socialrails posts:list --status scheduled
  6. Monitor: socialrails analytics --period 7d

Error responses always use exit code 1 with JSON on stderr:

{"error":{"code":"BAD_REQUEST","message":"Content must be 5000 characters or fewer."}}

Next Steps

See the CLI Commands Reference for all available commands.