Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: treat Resend sending-only API keys as healthy in email integration check

aashu9cfd5440f9e4
diff --git a/packages/ee/src/email/hooks.server.ts b/packages/ee/src/email/hooks.server.ts
index e32eb88640..1bb777d836 100644
--- a/packages/ee/src/email/hooks.server.ts
+++ b/packages/ee/src/email/hooks.server.ts
@@ -14,8 +14,9 @@ const logger = getLogger("ee", "email");
* provider without actually sending a message:
*
* - `resend`: hits `GET https://api.resend.com/domains` with the API key.
- * A 2xx means the key is valid and has read access; anything else means
- * the credentials are wrong or the account is suspended.
+ * A 2xx means the key is valid and has read access; a 401
+ * `restricted_api_key` means a valid "Sending access" key, also healthy.
+ * Anything else means the credentials are wrong or the account is suspended.
* - `smtp`: dynamically imports `nodemailer`, builds a transport from the
* stored host/port/username/password/secure and calls `.verify()`, which
* performs a handshake without sending mail.
@@ -49,7 +50,16 @@ export async function emailHealthcheck(
Authorization: `Bearer ${data.apiKey}`
}
});
- return response.ok;
+ if (response.ok) return true;
+ // A "Sending access" key is refused here with `restricted_api_key`, but
+ // sending is all the integration uses it for.
+ if (response.status === 401) {
+ const body = (await response.json().catch(() => null)) as {
+ name?: string;
+ } | null;
+ return body?.name === "restricted_api_key";
+ }
+ return false;
}
if (data.provider === "smtp") {