CLI
mcapi is a command-line client for the Marketing API. Every resource in the API reference has a matching subcommand, so you can call an endpoint, inspect a response, or script a sequence of calls without writing a request by hand. Use it for testing requests, automation, and one-off scripts; use a client library for application code.
Install
To build from source instead, install the Rust toolchain and run:
Authenticate
The CLI reads your API key from an environment variable. See Authentication for how to generate one.
A .env file in the working directory works too; the CLI loads it on startup.
Quick start
lists every resource. Each resource is a subcommand:
Run mcapi <resource> --help to see the methods available on that resource, and pass parameters as flags or as a JSON body:
Command reference
Every command maps to one API endpoint; the full set is in the API reference. The groups below cover the commands you’ll reach for most often.
Health check
Audiences and contacts
Campaigns and automations
Reports
Webhooks
See Webhooks for how Mailchimp delivers webhook events; the CLI only creates and manages the subscription, it doesn’t receive events.
Batch operations
See Batch operations for how batching works.
Common flags
These flags work on every command:
Commands on paginated endpoints also accept --page-all to auto-paginate and stream results as NDJSON, --page-limit <n> to cap the number of pages (default 10), and --page-delay <ms> to set the delay between page fetches (default 100).
Generate shell completions with:
Typical workflow
Export an audience’s contacts and pipe the result through jq:
To pull every member instead of one page, add --page-all:
Next steps
If you’re making your first call to the API, Send your first API request walks through the same Ping request shown above using a client library instead.