> ## Documentation Index
> Fetch the complete documentation index at: https://ahasend.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Routes

> Manage inbound email routes for processing incoming messages

# Routes Command

Manage inbound email routes for processing incoming messages through webhooks.

## Overview

```bash theme={null}
ahasend routes [subcommand] [flags]
```

Available subcommands:

* `list` - List all inbound email routes
* `create` - Create a new inbound email route
* `get` - Get detailed information about a specific route
* `update` - Update an existing inbound email route
* `delete` - Delete an inbound email route
* `listen` - Listen for inbound email events in real-time
* `trigger` - Trigger route events for testing

Routes enable you to:

* Process inbound emails through webhooks
* Filter emails by recipient patterns
* Control attachment handling and formatting
* Group messages by conversation threads
* Strip reply content for cleaner processing

## List Routes

```bash theme={null}
ahasend routes list
```

## Create Route

```bash theme={null}
# Basic route
ahasend routes create \
  --match-recipient "support@example.com" \
  --forward-to "https://your-app.com/webhooks/inbound"

# With recipient pattern filtering
ahasend routes create \
  --match-recipient "*@help.example.com" \
  --forward-to "https://api.example.com/email-handler" \
  --description "Help desk routing"

# Advanced route with options
ahasend routes create \
  --match-recipient "support-*@example.com" \
  --forward-to "https://support.example.com/webhook" \
  --strip-replies \
  --group-by-conversation \
  --description "Support ticket routing"
```

## Get Route Details

```bash theme={null}
ahasend routes get route_1234567890abcdef
```

## Update Route

```bash theme={null}
# Update webhook URL
ahasend routes update route_1234567890abcdef \
  --forward-to "https://new-api.example.com/webhook"

# Update recipient pattern
ahasend routes update route_1234567890abcdef \
  --match-recipient "new-pattern@example.com"

# Update processing options
ahasend routes update route_1234567890abcdef \
  --strip-replies \
  --group-by-conversation
```

## Delete Route

```bash theme={null}
ahasend routes delete route_1234567890abcdef
```

## Listen for Events (Development)

Listen for inbound email routing events in real-time using WebSocket connection. This command establishes a WebSocket connection to receive inbound email events and can forward them to a local endpoint for development.

```bash theme={null}
# Listen with existing route
ahasend routes listen --route-id abcd1234-5678-90ef-abcd-1234567890ab

# Listen with recipient pattern (backend creates temporary route)
ahasend routes listen --recipient "*@example.com"

# Forward events to local endpoint
ahasend routes listen \
  --recipient "support-*@example.com" \
  --forward-to http://localhost:3000/webhook

# Slim output (minimal event display)
ahasend routes listen --route-id abc123 --slim-output

# Skip SSL verification for local endpoints
ahasend routes listen \
  --route-id abc123 \
  --forward-to https://localhost:3000/webhook \
  --skip-verify
```

### Listen Flags

| Flag            | Description                                                 |
| --------------- | ----------------------------------------------------------- |
| `--route-id`    | Use existing route instead of creating temporary one        |
| `--recipient`   | Recipient pattern for temporary route (e.g., \*@domain.com) |
| `--forward-to`  | Local endpoint to forward events to                         |
| `--slim-output` | Slim down the payload for printing to the console           |
| `--skip-verify` | Skip SSL certificate verification for local endpoints       |

<Note>
  * Attachment data is not sent over WebSocket for performance reasons. Only email metadata and content are transmitted.
  * The command generates a webhook secret for signing forwarded events using the standard-webhooks specification.
  * The command handles disconnections with buffered event replay.
</Note>

## Trigger Test Events (Development)

Manually trigger route events for testing:

```bash theme={null}
ahasend routes trigger route_1234567890abcdef
```

<Warning>
  This is a development-only feature and may not be available in production environments.
</Warning>

## Next Steps

* [Configure webhooks](/cli/commands/webhooks)
* [View statistics](/cli/commands/stats)
