Skip to main content
The Mailofly CLI is the official command-line interface for Mailofly. It covers the full API surface and is built for developers, AI agents, and CI/CD pipelines.

Installation

Authentication

The CLI resolves your API key using the following priority chain: If no key is found from any source, the CLI errors with code auth_error.

mailofly login

Authenticate by storing your API key locally. The key is validated against the Mailofly API before being saved.
In a terminal, the command prompts for your key via masked input. In non-interactive environments (CI, pipes), use the --key flag:
Credentials are saved to your configuration directory (~/.config/mailofly/credentials.json on macOS/Linux or %APPDATA%\mailofly\credentials.json on Windows).

mailofly logout

Remove your saved API key and profile:

Switch between profiles

If you work across multiple Mailofly teams or accounts, switch between profiles without logging in and out:
Use the global --profile flag on any command to run it with a specific profile:
Other profile management commands:

Emails

Send, retrieve, cancel, and manage email delivery.

mailofly emails send

Send an email. Provide all options via flags for scripting, or pass template variables and attachments.
* Not required when using --template, which provides them.

Examples

mailofly emails batch

Send up to 100 emails in a single API request from a JSON file:
Each email in the JSON array supports the same fields as mailofly emails send:
emails.json

Other email commands

Receiving

Process inbound emails and attachments:

Domains

Manage your sending and receiving domains.

API Keys

Create, list, and revoke API keys for programmatic access.

Broadcasts

Create and send broadcast campaigns to target audience segments.

Contacts

Manage contacts and segment memberships.

Segments

Group contacts into targetable segments for broadcasts and automated sends.

Templates

Create and manage reusable email templates.

Logs

View API request logs and delivery audit trails.

Webhooks

Register endpoints and listen for email delivery events.

mailofly webhooks create

Register a webhook endpoint:

Other webhook commands

Automations

Manage workflow automations, execution runs, and DAG step pipelines.

mailofly automations list

List all automations with their current status, trigger type, and step count:

mailofly automations get <id>

Inspect details of a workflow automation, including triggers, step definitions, and DAG connections:

mailofly automations create

Create a new automation workflow directly or from a JSON DAG definition:

mailofly automations stop <id>

Deactivate an automation and cancel any currently pending runs:

mailofly automations duplicate <id>

Clone an existing automation into a new draft workflow:

mailofly automations delete <id>

Permanently remove an automation:

Execution runs

Inspect execution history, status, and step logs for an automation:

Events

Publish custom business events to trigger workflow automations or satisfy wait-for-event steps.

mailofly events send

Publish an event into Mailofly:

Other event commands

Utility

Diagnose your environment and inspect authentication status.

mailofly doctor

Run environment and connectivity diagnostics. Verifies your CLI version, API key, credential storage, and domain connection status.
Exits 0 when all checks pass or warn. Exits 1 if any check fails.

Other utility commands

Global options

These flags work on every command:

Output behavior

The CLI has two output modes that switch automatically: Pipe to another command and JSON output activates automatically:
Errors always exit with code 1 and output structured JSON in machine mode:

CI/CD

Set MAILOFLY_API_KEY as an environment variable, with no mailofly login needed:

Configuration

API Reference

Explore the full Mailofly REST API documentation and endpoints.