<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->

# API Reference — Implementing Email Gateway Rules

## Agent Script

### Commands

| Command | Description |
|---|---|
| `node agent.js generate-rule --type <type>` | Generate gateway rule config |
| `node agent.js list-rules --platform <plat>` | List available rule templates |
| `node agent.js quarantine-report --days <n>` | Generate quarantine review commands |
| `node agent.js validate --platform <plat>` | Generate validation commands |

### Rule Types

| Type | Description |
|---|---|
| `external-banner` | External email warning banner |
| `block-attachments` | Block dangerous attachment types |
| `safe-links` | URL rewriting and sandboxing |
| `impersonation-protection` | Executive impersonation detection |
| `dmarc-reject` | DMARC hard fail rejection |

### Examples

```bash
# Generate external email banner rule
node agent.js generate-rule --type external-banner

# List all M365 rule templates
node agent.js list-rules --platform m365

# Generate quarantine review commands for last 7 days
node agent.js quarantine-report --days 7

# Validate current M365 gateway configuration
node agent.js validate --platform m365
```

## M365 PowerShell Modules

| Module | Command |
|---|---|
| ExchangeOnlineManagement | `Connect-ExchangeOnline` |
| Transport Rules | `Get-TransportRule`, `New-TransportRule` |
| Safe Links | `Get-SafeLinksPolicy`, `New-SafeLinksPolicy` |
| Safe Attachments | `Get-SafeAttachmentPolicy` |
| Anti-Phishing | `Get-AntiPhishPolicy` |
| Quarantine | `Get-QuarantineMessage`, `Release-QuarantineMessage` |
