Skip to main content
Test and debug inbound email routing locally using the AhaSend CLI’s WebSocket-based route listener. Before running the examples, log in with a full API key, use your verified sender domain, and replace YOUR_RESOURCE_ID with a resource UUID from your test account. Create any named template, recipient, attachment, or JSON files first. Shell examples use Bash; examples that read JSON with jq need jq installed. Sends use sandbox mode.

Overview

The CLI provides tools for:
  • Listening to inbound email events in real-time using WebSocket connection
  • Using existing routes or creating temporary routes with recipient patterns
  • Forwarding events to local endpoints for development
  • Displaying events in full or slim output format
  • Handling disconnections with buffered event replay
  • Triggering test route events

Route Listener

Basic Usage

Temporary routes need a domain in your account with its AhaSend MX records configured. An existing route must be enabled to emit events. For a disabled test route, start its listener, then run ahasend routes update YOUR_RESOURCE_ID --enabled in another terminal; disable it again before stopping the listener. Temporary listeners are enabled automatically.
  • 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 headers and format, with the full secret as raw UTF-8 bytes.

Event Type

  • message.routing - Triggered when an inbound email matches a route

Event Forwarding

Forward to Local Server

Event Headers

Forwarded requests include standard webhook headers:
  • webhook-id - Unique message identifier
  • webhook-timestamp - Unix timestamp
  • webhook-signature - HMAC signature for verification

Triggering Test Events

Development Testing

Finding Route IDs

Integration Testing

Development Workflow

Output Formats

Standard Output

Slim Output

Common Flags

Use Cases

Testing Inbound Email Processing

Support Ticket System

Email-to-Task Integration

Best Practices

  1. Use Temporary Routes for Testing: Create temporary routes with wildcards during development
  2. Verify Signatures: Always validate webhook signatures in production
  3. Use listeners for development: Configure a real route URL for production
  4. Test with Trigger Command: Use trigger to test without sending real emails
  5. Use Slim Output for Monitoring: Reduce console clutter when monitoring events

Troubleshooting

WebSocket Connection Failed: Check network connectivity and firewall settings Events Not Received: Verify the route pattern matches the recipient address Signature Verification Failed: The listener prints its signing secret when it starts. Store that secret in your local handler’s configuration; use the full string as the raw UTF-8 HMAC key. Do not base64-decode it. See signature verification. The command automatically generates a webhook secret using the Standard Webhooks headers and format, with the full secret as raw UTF-8 bytes Route Not Found: Check route ID with ahasend routes list

Next Steps