diff --git a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt
index 100000a6..66a899ac 100644
--- a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt
+++ b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt
@@ -1 +1 @@
-376
+377
diff --git a/src/Backend/AutopilotMonitor.Functions/Functions/Rules/PreviewWhitelistFunction.cs b/src/Backend/AutopilotMonitor.Functions/Functions/Rules/PreviewWhitelistFunction.cs
index 414352cb..f87e97fd 100644
--- a/src/Backend/AutopilotMonitor.Functions/Functions/Rules/PreviewWhitelistFunction.cs
+++ b/src/Backend/AutopilotMonitor.Functions/Functions/Rules/PreviewWhitelistFunction.cs
@@ -208,6 +208,7 @@ public class PreviewWhitelistFunction
///
/// POST /api/preview/send-welcome-email/{tenantId}
/// Sends (or resends) the Private Preview welcome email. Galactic Admin only.
+ /// Accepts optional { email } in body — if provided, saves it to tenant config before sending.
///
[Function("SendPreviewWelcomeEmail")]
[Authorize]
@@ -219,6 +220,16 @@ public class PreviewWhitelistFunction
// Authentication + GalacticAdminOnly authorization enforced by PolicyEnforcementMiddleware
var tenantConfig = await _tenantConfigurationService.GetConfigurationAsync(tenantId);
+
+ // If the caller provides an email in the body, save it first
+ var body = await req.ReadFromJsonAsync();
+ var bodyEmail = body?.Email?.Trim();
+ if (!string.IsNullOrWhiteSpace(bodyEmail))
+ {
+ tenantConfig.PreviewNotificationEmail = bodyEmail;
+ await _tenantConfigurationService.SaveConfigurationAsync(tenantConfig);
+ }
+
var email = tenantConfig.PreviewNotificationEmail;
if (string.IsNullOrWhiteSpace(email))
diff --git a/src/Web/autopilot-monitor-web/app/admin-configuration/components/TenantManagementSection.tsx b/src/Web/autopilot-monitor-web/app/admin-configuration/components/TenantManagementSection.tsx
index 85d5518f..d56d8977 100644
--- a/src/Web/autopilot-monitor-web/app/admin-configuration/components/TenantManagementSection.tsx
+++ b/src/Web/autopilot-monitor-web/app/admin-configuration/components/TenantManagementSection.tsx
@@ -170,7 +170,7 @@ export function TenantManagementSection({
}
};
- const handleSendWelcomeEmail = async (tenantId: string) => {
+ const handleSendWelcomeEmail = async (tenantId: string, email?: string) => {
try {
setSendingWelcomeEmail(true);
setError(null);
@@ -179,7 +179,11 @@ export function TenantManagementSection({
const response = await authenticatedFetch(
`${API_BASE_URL}/api/preview/send-welcome-email/${tenantId}`,
getAccessToken,
- { method: "POST" }
+ {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ email: email || "" }),
+ }
);
if (!response.ok) {
@@ -531,7 +535,7 @@ export function TenantManagementSection({
className="flex-1 px-3 py-2 border border-gray-300 rounded-lg text-sm text-gray-900 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-colors"
/>