CLI

Use the Rankhog CLI for agent-safe scripts, JSON output, and the same public API capabilities.

The Rankhog CLI calls the public REST API. It is designed for humans and AI agents.

Configure

export RANKHOG_API_BASE_URL="https://api.rankhog.com"
export RANKHOG_OUTPUT="json"

Agents should prefer --json or RANKHOG_OUTPUT=json.

Sign In

The CLI uses Better Auth device authorization.

rankhog login

For non-interactive agents, print the code without polling:

rankhog --json login --no-poll --no-open

You can also provide a bearer token directly:

export RANKHOG_ACCESS_TOKEN="..."

Device tokens are stored in the CLI YAML config with file mode 0600. RANKHOG_ACCESS_TOKEN always takes precedence for ephemeral agent runs.

Find Workspace IDs

rankhog --json workspaces list

Set defaults for scripts:

export RANKHOG_ORGANIZATION_ID="org_..."
export RANKHOG_WEBSITE_ID="web_..."
export RANKHOG_MANAGED_REDDIT_ACCOUNT_ID="acct_..."

Common Commands

rankhog --json reddit rules SaaS
rankhog --json reddit activity SaaS --max-posts 25 --max-comments 25
rankhog --json reddit actions status job_...
rankhog --json browser status
rankhog --json strategy plan
rankhog --json analytics summary --period week
rankhog --json jobs planned --organization-id "$RANKHOG_ORGANIZATION_ID"

Reddit Actions

Use reddit actions to store, execute, and poll real Reddit writes through Rankhog Desktop. Supported action types are post, comment, reply, upvote, and join_subreddit.

Create a comment action:

rankhog --json reddit actions create \
  --type comment \
  --target-url "https://www.reddit.com/r/SaaS/comments/examplepost/example/" \
  --body "We saw better activation after asking users for one setup action instead of showing a long checklist." \
  --risk-summary "Contextual reply with no link and no promotional claim." \
  --idempotency-key "action-comment-2026-06-17-001"

Create a post with flair:

rankhog --json reddit actions create \
  --type post \
  --subreddit SaaS \
  --title "What actually improved your SaaS activation?" \
  --body-file ./reddit-post.md \
  --flair "Discussion" \
  --risk-summary "Discussion prompt, no link, and relevant to SaaS operators." \
  --idempotency-key "action-post-2026-06-17-001"

Execute an approved action. The response means the work is queued.

rankhog --json reddit actions execute act_... \
  --acknowledge \
  --idempotency-key "execute-action-2026-06-17-001"

Queued response:

{
  "status": "queued",
  "executionId": "job_...",
  "jobId": "job_...",
  "plannedRedditActionId": "act_...",
  "statusUrl": "/agent/v1/reddit-action-executions/status?executionId=job_..."
}

Poll status:

rankhog --json reddit actions status job_...

Possible statuses:

queued
running
succeeded
failed
blocked
cancelled
verification_required

verification_required means Reddit may have accepted the final submit, but Rankhog could not prove it. Do not blindly execute the same planned action again.

Duplicate execute calls with the same planned action and idempotency key return the existing execution instead of posting twice.

Drafts

Drafts are still available for manual workflows. Create a draft from stdin:

draft.json:

{
  "subreddit": "SaaS",
  "title": "A useful Reddit-safe title",
  "body": "A helpful draft body."
}
cat draft.json | rankhog --json drafts create \
  --input - \
  --idempotency-key "draft-2026-06-17-001"

Agent Behavior

The CLI avoids prompts and spinners in JSON mode. Errors are machine-readable and use stable exit codes:

  • 0: success.
  • 1: command or API failure.
  • 3: authentication is required.

Next: read the API reference for HTTP automation or MCP for OAuth tool calls.

On this page