# Automate Instagram from the Command Line: CLI Guide (2026)

> Schedule posts, generate DM automations, and pull analytics from your terminal. The SociaHive CLI puts Instagram automation in your shell scripts and CI pipelines.

Published: 2026-08-14 · Updated: 2026-10-20 · By: SociaHive Team
Canonical: https://www.sociahive.com/blog/instagram-automation-cli

There's no official Instagram CLI — Meta doesn't ship one, and browser-automation wrappers get accounts banned. But if you live in the terminal, you can still run real Instagram automation from your shell: the SociaHive CLI wraps the same [MCP tool surface](/mcp) that AI assistants use, so every command is an authenticated, compliant API call against connected Instagram Business or Creator accounts.

## Setup

```bash
export SOCIAHIVE_API_KEY=sk_live_...   # Settings → API Keys
sociahive accounts list                # verify your connected accounts
```

API keys are scoped — mint a read-only key for dashboards and a write key for publishing workflows.

## Schedule and Publish Posts

```bash
# Create a draft
sociahive posts create --text "Launch day. Comment START for early access." \
  --platforms '[{"platform":"instagram","account_id":"<id>"}]'

# Schedule it
sociahive posts schedule <id> --at "2026-09-01T15:00:00Z" --timezone America/New_York

# Or publish immediately (confirmation-gated — irreversible actions require --yes)
sociahive posts publish <id> --yes

# See what's queued
sociahive posts list --status scheduled
sociahive calendar --month 2026-09
```

Bulk-load a whole content calendar from a spreadsheet with `sociahive posts import calendar.csv` — each row becomes a reviewable draft. If you'd rather script the scheduling yourself (with per-row account lookup and the bulk-vs-loop cutoff), the [CSV scheduling recipe](/docs/cookbook#schedule-a-week-of-posts-from-a-csv) in the cookbook has copy-paste Python, Node, and CLI versions.

## Generate DM Automations from One Sentence

The CLI exposes the same AI flow generator behind the web app:

```bash
sociahive flows generate --description "When someone comments PRICE on my posts, DM them my pricing page and ask if they want a call" --platform instagram
```

That returns a draft flow — review it, then turn it on:

```bash
sociahive flows list --status draft
sociahive flows activate <id>
sociahive flows stats <id>      # executions, completions, performance
```

Drafts never auto-publish. Turning an automation live is always an explicit act, same as in the dashboard.

## Analytics and Content Insights

```bash
sociahive insights --weeks 8    # what's working: winners by format, day, and topic
```

The insights digest is computed from your accounts' actual post performance — the same data that feeds the [Autopilot](/blog/social-media-automation-with-ai-agents-2026) planner.

## Where the CLI Fits

- **CI/CD content pipelines** — publish release announcements from GitHub Actions
- **Cron jobs** — schedule a weekly digest from a data source without opening a browser
- **Scripting** — anything you can express in bash: bulk operations, backups of flow configs, reporting. For application code, the [social media API](/blog/social-media-api) and its Node and Python SDKs cover the same actions
- **AI coding agents** — [Claude Code](/integrations/claude-code) and [OpenAI Codex](/integrations/openai-codex) can drive the same commands, or skip the shell entirely and use the [MCP server](/mcp/social-media) directly

## How It Works Underneath

Every CLI command is a JSON-RPC `tools/call` against SociaHive's MCP endpoint (`/api/mcp`) — the identical tool registry AI assistants connect to. Destructive operations (publish now, delete) return a short-lived confirmation token first; `--yes` completes the two-step confirm. Meta platform compliance, OAuth token refresh, and rate limits are handled server-side, so a shell script can't get your account restricted.

## Frequently Asked Questions

### Is there an official Instagram CLI from Meta?

No. Meta provides no command-line tool for Instagram. Anything advertising direct Instagram CLI posting either wraps an approved platform's API (compliant) or automates a browser session (against Instagram's terms, ban risk).

### Can I schedule Instagram posts from a cron job?

Yes — `sociahive posts create` + `posts schedule` in any cron script. The scheduler runs server-side, so your machine doesn't need to be online at publish time.

### Does the CLI work with other platforms?

Yes. The same commands target Facebook, LinkedIn, X/Twitter, Threads, TikTok, YouTube, Bluesky, and Pinterest — pass a different platform in `--platforms`.
