|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +# mautic-cli |
| 4 | + |
| 5 | +**CLI for Mautic marketing automation - built for humans and AI agents.** |
| 6 | + |
| 7 | +[](LICENSE) |
| 8 | +[](https://python.org) |
| 9 | +[](https://mautic.org) |
| 10 | + |
| 11 | +[Quick Start](#quick-start) · [Commands](#commands) · [Output Formats](#output-formats) · [AI Agents](#ai-agents) |
| 12 | + |
| 13 | +</div> |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## What it does |
| 18 | + |
| 19 | +| Category | Capabilities | |
| 20 | +|----------|-------------| |
| 21 | +| **Contacts** | List, search, create, edit, delete, points, segments, campaigns, activity | |
| 22 | +| **Segments** | List, create, edit, delete, add/remove contacts | |
| 23 | +| **Emails** | List, create, edit, send to contact, send to segment | |
| 24 | +| **Campaigns** | List, create, edit, delete, clone (7+), add/remove contacts | |
| 25 | +| **Auth** | Basic Auth, OAuth2 Client Credentials, multiple profiles | |
| 26 | +| **Output** | JSON, colored tables, CSV, NDJSON streaming | |
| 27 | + |
| 28 | +## Quick Start |
| 29 | + |
| 30 | +```bash |
| 31 | +# Install (pick one) |
| 32 | +uv tool install mautic-cli # recommended |
| 33 | +pip install mautic-cli # or with pip |
| 34 | +pipx install mautic-cli # or with pipx |
| 35 | + |
| 36 | +# Authenticate |
| 37 | +mautic auth setup |
| 38 | + |
| 39 | +# Use it |
| 40 | +mautic contacts list --limit 5 |
| 41 | +mautic --format table emails list |
| 42 | +``` |
| 43 | + |
| 44 | +## Commands |
| 45 | + |
| 46 | +### Contacts |
| 47 | + |
| 48 | +```bash |
| 49 | +mautic contacts list --search "email:*@company.com" --limit 50 |
| 50 | +mautic contacts get 42 |
| 51 | +mautic contacts create --json '{"firstname":"Ana","email":"ana@example.com"}' |
| 52 | +mautic contacts edit 42 --json '{"lastname":"Silva"}' |
| 53 | +mautic contacts delete 42 |
| 54 | +mautic contacts add-points 42 10 |
| 55 | +mautic contacts add-to-segment 42 5 |
| 56 | +mautic contacts activity 42 |
| 57 | +``` |
| 58 | + |
| 59 | +### Segments |
| 60 | + |
| 61 | +```bash |
| 62 | +mautic segments list |
| 63 | +mautic segments get 1 |
| 64 | +mautic segments contacts 1 |
| 65 | +mautic segments create --json '{"name":"Newsletter Q1","isPublished":true}' |
| 66 | +``` |
| 67 | + |
| 68 | +### Emails |
| 69 | + |
| 70 | +```bash |
| 71 | +mautic emails list |
| 72 | +mautic emails get 1 |
| 73 | +mautic emails send 1 --contact 42 |
| 74 | +mautic emails send-to-segment 1 |
| 75 | +``` |
| 76 | + |
| 77 | +### Campaigns |
| 78 | + |
| 79 | +```bash |
| 80 | +mautic campaigns list |
| 81 | +mautic campaigns get 1 |
| 82 | +mautic campaigns contacts 1 |
| 83 | +mautic campaigns clone 1 # Mautic 7+ only |
| 84 | +``` |
| 85 | + |
| 86 | +<details> |
| 87 | +<summary><strong>All write commands accept JSON from inline, file, or stdin</strong></summary> |
| 88 | + |
| 89 | +```bash |
| 90 | +mautic contacts create --json '{"email":"test@example.com"}' |
| 91 | +mautic contacts create --json @contact.json |
| 92 | +cat contact.json | mautic contacts create --json @- |
| 93 | +``` |
| 94 | +</details> |
| 95 | + |
| 96 | +## Output Formats |
| 97 | + |
| 98 | +**Table** - colored, aligned columns with total count (powered by [rich](https://github.com/Textualize/rich)): |
| 99 | + |
| 100 | +``` |
| 101 | + Showing 5 of 274,528 |
| 102 | +id firstname lastname email points dateAdded |
| 103 | +66515 Lidia Duarte lidia@example.com 0 2024-09-27 |
| 104 | +26698 Claudia Preis claudia@example.com 0 2024-08-25 |
| 105 | +``` |
| 106 | + |
| 107 | +```bash |
| 108 | +mautic --format table contacts list --limit 5 |
| 109 | +``` |
| 110 | + |
| 111 | +**JSON** (default) - full API response, pretty-printed in terminal: |
| 112 | + |
| 113 | +```bash |
| 114 | +mautic contacts list --limit 5 |
| 115 | +``` |
| 116 | + |
| 117 | +**CSV** - same key fields, pipe to file: |
| 118 | + |
| 119 | +```bash |
| 120 | +mautic --format csv contacts list > contacts.csv |
| 121 | +``` |
| 122 | + |
| 123 | +**NDJSON** - one JSON object per line, auto-paginating through all results: |
| 124 | + |
| 125 | +```bash |
| 126 | +mautic --page-all contacts list | jq '.fields.all.email' |
| 127 | +``` |
| 128 | + |
| 129 | +## Global Flags |
| 130 | + |
| 131 | +Global flags go **before** the resource group: |
| 132 | + |
| 133 | +```bash |
| 134 | +mautic --format table --published-only emails list |
| 135 | +``` |
| 136 | + |
| 137 | +| Flag | Description | |
| 138 | +|----------|-------------| |
| 139 | +| `--format json\|table\|csv` | Output format (default: json) | |
| 140 | +| `--pretty` | Pretty-print JSON | |
| 141 | +| `--page-all` | Auto-paginate, output NDJSON per record | |
| 142 | +| `--dry-run` | Show HTTP request without executing | |
| 143 | +| `--verbose` | Show HTTP request/response details | |
| 144 | +| `--published-only` | Filter to published items only | |
| 145 | +| `--no-verify-ssl` | Skip SSL certificate verification | |
| 146 | +| `--profile <name>` | Use a named config profile | |
| 147 | + |
| 148 | +## Authentication |
| 149 | + |
| 150 | +### Interactive Setup |
| 151 | + |
| 152 | +```bash |
| 153 | +mautic auth setup # Prompts for URL, method (basic/oauth2), credentials |
| 154 | +mautic auth test # Verify connection and detect Mautic version |
| 155 | +``` |
| 156 | + |
| 157 | +Supports **Basic Auth** and **OAuth2 Client Credentials** grant. |
| 158 | + |
| 159 | +### Environment Variables |
| 160 | + |
| 161 | +```bash |
| 162 | +export MAUTIC_BASE_URL=https://mautic.example.com |
| 163 | +export MAUTIC_USERNAME=admin |
| 164 | +export MAUTIC_PASSWORD=secret |
| 165 | +``` |
| 166 | + |
| 167 | +### Profiles |
| 168 | + |
| 169 | +Manage multiple Mautic instances with named profiles: |
| 170 | + |
| 171 | +```bash |
| 172 | +mautic auth setup # Profile name: production |
| 173 | +mautic auth setup # Profile name: staging |
| 174 | +mautic auth list # Show all profiles |
| 175 | +mautic auth delete staging # Remove a profile |
| 176 | + |
| 177 | +mautic --profile staging contacts list |
| 178 | +``` |
| 179 | + |
| 180 | +<details> |
| 181 | +<summary><strong>SSL / self-signed certificates (DDEV, local dev)</strong></summary> |
| 182 | + |
| 183 | +```bash |
| 184 | +# Per-command |
| 185 | +mautic --no-verify-ssl contacts list |
| 186 | + |
| 187 | +# Or save the preference during auth setup |
| 188 | +mautic auth setup |
| 189 | +# Skip SSL verification? (for self-signed certs) [y/N]: y |
| 190 | +``` |
| 191 | +</details> |
| 192 | + |
| 193 | +## Search Syntax |
| 194 | + |
| 195 | +The `--search` flag passes through to [Mautic's native search](https://docs.mautic.org/en/5.x/contacts/search.html): |
| 196 | + |
| 197 | +```bash |
| 198 | +mautic contacts list --search "email:*@company.com" |
| 199 | +mautic emails list --search "name:Newsletter" |
| 200 | +mautic --published-only segments list # uses is:published internally |
| 201 | +``` |
| 202 | + |
| 203 | +## Shell Completion |
| 204 | + |
| 205 | +Tab-completion for all commands, subcommands, and options: |
| 206 | + |
| 207 | +```bash |
| 208 | +mautic completion # Shows install instructions for your shell |
| 209 | +``` |
| 210 | + |
| 211 | +## AI Agents |
| 212 | + |
| 213 | +mautic-cli ships with an [agent skill](skills/mautic/SKILL.md) that teaches AI coding agents the full command reference, auth flow, and safety rules for write operations. |
| 214 | + |
| 215 | +Install with [`npx skills`](https://github.com/vercel-labs/skills) (supports Claude Code, Cursor, Codex, Gemini, Windsurf, and [37+ agents](https://add-skill.org/)): |
| 216 | + |
| 217 | +```bash |
| 218 | +npx skills add https://github.com/bloomidea/mautic-cli |
| 219 | +``` |
| 220 | + |
| 221 | +Then ask your agent: *"list my mautic contacts"* or *"send email 5 to contact 42"*. |
| 222 | + |
| 223 | +## License |
| 224 | + |
| 225 | +[MIT](LICENSE) |
0 commit comments