Command
nylas agent rule create
Create a rule for an Agent Account policy.
Written by Qasim Muhammad Staff SRE
What does nylas agent rule create do?
The nylas agent rule create command adds a rule that can block, archive, mark, or otherwise control messages for Agent Account workflows. Use --condition for field/operator/value matching, --action for the rule action, and optional flags such as --priority, --trigger, or --match-operator to place the rule in the right policy path.
Usage
nylas agent rule create --condition FIELD,OPERATOR,VALUE --action ACTION [--json]Flags
| Flag | Description |
|---|---|
| --json | Output as JSON |
| --no-color | Disable color output |
| --verbose(-v) | Enable verbose output |
| --config | Custom config file path |
| --help(-h) | Show help for the command |
| --limit | Limit results (most list commands) |
| --yes(-y) | Skip confirmations |
| --condition | Rule condition in field,operator,value form |
| --action | Rule action such as block, archive, or mark_as_read |
| --priority | Rule priority |
| --trigger | Trigger direction such as inbound or outbound |
| --match-operator | How multiple conditions are combined |
| --data | Inline JSON rule data |
| --data-file | Path to a JSON file containing rule data |
| --description | Rule description |
| --disabled | Create the rule in a disabled state |
| --enabled | Create the rule in an enabled state |
| --name | Rule name |
Examples
Block a sender domain
nylas agent rule create \
--condition from.domain,is,example.com \
--action block \
--priority 10 \
--jsonCreate from JSON
nylas agent rule create --data-file rule.json --jsonExample output
✓ Rule created (rule_abc123)
Name: Block Example
Trigger: inbound
Condition: from.domain is example.com
Action: block
Attached to the default agent workspace.Troubleshooting
Unknown action
Use documented action names such as block, archive, mark_as_read, or mark_as_starred. Check the Agent Accounts docs before adding a custom action.
Rule created but not applied
Rules attach to the agent's default workspace automatically. To group the rule under a custom policy, include its ID in the policy body (nylas agent policy create --data) or attach rule IDs to the workspace with nylas workspace update --rules-ids.
Recommended guides
List Fastmail emails from the CLI
List Fastmail emails from the CLI through Nylas IMAP access, using app passwords, inbox filters, JSON output, and Fastmail-specific auth troubleshooting.
Thunderbird vs Nylas: GUI vs CLI email
Thunderbird is a desktop GUI email client with OAuth and calendar built in. Compare it to a scriptable, headless CLI for servers, cron jobs, and AI agents.
Why Cloud Servers Block SMTP Ports
AWS, GCP, and Azure block outbound SMTP port 25 while ports 587 and 465 stay open. Confirm the block and send email over an HTTPS API instead.
Send Email From a Docker Container
Cloud providers block SMTP port 25 from containers. Send email over an HTTPS API on port 443 with one command and no mail daemon at all.
MailerSend vs Nylas: Email Compared
MailerSend sends transactional email from verified domains. Nylas reads and syncs user inboxes across 6 providers. Compare features, pricing, and use cases.
Customer.io vs Nylas: Email Compared
Customer.io sends lifecycle emails to your user base. Nylas reads and sends from real user inboxes via OAuth. Compare use cases, pricing, and AI agent support.
Run nylas agent rule create --help for full help output.