> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mallary.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Automation

> Use Mallary CLI in scripts, CI, and automated toolchains.

## JSON Output

Human-readable output is the default.

Use `--json` for scripting:

```bash theme={null}
mallary posts list --json
```

Output rules:

* direct API wrapper commands emit the API response body
* convenience flows like `upload` emit CLI-specific JSON
* when local file uploads happen before submission, `posts create` emits CLI-specific JSON

## Exit Codes

* `0`: success
* `1`: local CLI, config, or input failure
* `2`: remote API or upload failure

## Shell Automation Example

```bash theme={null}
#!/usr/bin/env bash
set -euo pipefail

export MALLARY_API_KEY="${MALLARY_API_KEY:?missing}"

UPLOAD_JSON="$(mallary upload ./hero.png --json)"
MEDIA_URL="$(printf '%s' "$UPLOAD_JSON" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>console.log(JSON.parse(s).uploads[0].media_url))')"

mallary posts create \
  --message "Deployed via CI" \
  --platform facebook \
  --platform linkedin \
  --media "$MEDIA_URL" \
  --json
```

## GitHub Actions Example

```yaml theme={null}
- name: Install Mallary CLI
  run: npm install -g @mallary/cli

- name: Publish post
  env:
    MALLARY_API_KEY: ${{ secrets.MALLARY_API_KEY }}
  run: |
    mallary posts create \
      --message "Release shipped." \
      --platform facebook \
      --platform linkedin
```

## AI Agent Notes

If you are using the CLI in an automated agent workflow:

* prefer `--json`
* prefer `mallary posts create --file payload.json` for complex payloads


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.