The nylas agent policy and nylas agent rule commands define guardrails for AI agent email accounts. Set who the agent can email, what triggers are allowed, and what actions to take on inbound messages — all enforced server-side.
What policies and rules do
A policy is a named container for rules. Rules define conditions and actions: "if the sender is external, block" or "if sending to a non-internal domain, require approval." These fire before the agent sees the message, so prompt injection can't bypass them.
Quick Start
nylas agent policy create --name "production-guardrails" --json
nylas agent rule create \
--name "internal-only-outbound" \
--condition "recipient_domain != company.com" \
--action block
Key commands
| Command | What it does |
|---|---|
nylas agent policy list |
List all policies |
nylas agent policy create --name N |
Create a named policy |
nylas agent policy get <id> |
Show policy details |
nylas agent policy delete <id> --yes |
Delete a policy |
nylas agent rule list |
List all rules |
nylas agent rule create --name N --condition C --action A |
Create a rule from flags |
nylas agent rule create --data-file rule.json |
Create from JSON file |
nylas agent rule get <id> |
Show a rule |
nylas agent rule delete <id> --yes |
Delete a rule |
nylas agent account create <email> --policy-id <id> |
Attach policy to agent |
Example: restrict outbound to internal domains only
# Create policy
POLICY=$(nylas agent policy create --name "internal-only" --json | jq -r '.id')
# Add rule: block any outbound to non-company domains
nylas agent rule create \
--policy-id $POLICY \
--name "block-external-send" \
--condition "direction == outbound AND recipient_domain != mycompany.com" \
--action block
# Attach to agent account
nylas agent account create agent@mycompany.nylas.email --policy-id $POLICY
Example: auto-archive marketing emails
nylas agent rule create \
--name "archive-marketing" \
--condition "sender_domain IN (marketing.example.com, promo.example.com)" \
--action archive
Related posts
- I gave my Claude Code agent an email address
- AI agents need email — your MCP setup is incomplete
- 5 Nylas CLI commands every AI agent should have
All commands: Nylas CLI Command Reference
Get started: brew install nylas/nylas-cli/nylas — other install methods
Top comments (0)