Skip to main content

Prerequisites

Install

npm install -g @autoposting.ai/cli
Both autoposting and ap (short alias) are available after install.

Setup

1

Authenticate

Set your API key via environment variable or browser login:
export AUTOPOSTING_API_KEY=sk-social-your-key
Add to your shell profile (~/.zshrc, ~/.bashrc) for persistence.
Auth priority:
--api-key flag  >  AUTOPOSTING_API_KEY env  >  ~/.config/autoposting/credentials.json
The CLI talks to https://app.autoposting.ai/api-proxy by default. Override it with the AUTOPOSTING_BASE_URL environment variable (or ap auth login --base-url) for staging or self-hosted backends.
2

Verify

ap doctor
Checks CLI version, Node.js version, authentication, and API connectivity.
ap whoami
Shows which auth method is active and the associated workspace.
3

Shell Completions (optional)

ap completion zsh >> ~/.zshrc
source ~/.zshrc

CI/CD Usage

For CI/CD pipelines, use the AUTOPOSTING_API_KEY environment variable with --json and --quiet flags:
# GitHub Actions
- name: Announce release
  run: |
    npm install -g @autoposting.ai/cli
    ap posts create \
      --brand my-brand \
      --text "v${{ github.ref_name }} is live!" \
      --platforms x,linkedin \
      --json
  env:
    AUTOPOSTING_API_KEY: ${{ secrets.AUTOPOSTING_API_KEY }}

Exit Codes

CodeMeaning
0Success
1General error
2Authentication error
3Validation error
4Not found
5Rate limited
6Server error

Commands

Full command reference with flags and examples.

MCP Setup

Connect AI assistants to your account.

TypeScript SDK

Programmatic API access in Node.js.

API Reference

Explore the REST API directly.