# BMC Hub v2.2.36 - Helpdesk SAG Routing

**Release Date:** 2. marts 2026

## ✨ New Features

### Helpdesk email → SAG automation
- Incoming emails from known customer domains now auto-create a new SAG when no `SAG-<id>` reference is present.
- Incoming emails with `SAG-<id>` in subject or threading headers now auto-update the related SAG.
- Emails from unknown domains remain in `/emails` for manual handling.

### Email threading support for routing
- Added migration `141_email_threading_headers.sql`.
- `email_messages` now stores `in_reply_to` and `email_references` to support robust SAG threading lookup.

### /emails quick customer creation improvements
- Quick create customer modal now includes `email_domain`.
- Customer create API now accepts and persists `email_domain`.

## 🔧 Technical Changes

- Updated `app/services/email_service.py` to parse and persist `In-Reply-To` and `References` from IMAP/EML uploads.
- Updated `app/services/email_workflow_service.py` with system-level helpdesk SAG routing logic.
- Updated `app/emails/backend/router.py` to include `customer_name` in email list responses.
- Updated `app/customers/backend/router.py` and `app/emails/frontend/emails.html` for `email_domain` support.

## 📋 Deployment Notes

- Run database migration 141 before processing new inbound emails for full header-based routing behavior.
- Existing workflow/rule behavior is preserved; new routing runs as a system workflow.
