{"record":{"id":"fd6998df431f5c66","repo":"koala73/worldmonitor","slug":"sendprolaunchbroadcast-resend-api-key-not-set","errorCode":null,"errorMessage":"[sendProLaunchBroadcast] RESEND_API_KEY not set","messagePattern":"\\[sendProLaunchBroadcast\\] RESEND_API_KEY not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"convex/broadcast/sendBroadcast.ts","lineNumber":153,"sourceCode":"/**\n * Send (or schedule) a previously-created Resend Broadcast.\n *\n * `scheduledAt`: ISO 8601 timestamp string OR a natural-language phrase\n * Resend accepts (\"in 2 hours\"). Omit for immediate send.\n *\n * Resend's send endpoint is fire-and-forget — it returns immediately\n * after queueing. Track delivery via the `broadcastEvents` table\n * (populated by webhook events) or the `getBroadcastStats` action.\n */\nexport const sendProLaunchBroadcast = internalAction({\n  args: {\n    broadcastId: v.string(),\n    scheduledAt: v.optional(v.string()),\n  },\n  handler: async (_ctx, { broadcastId, scheduledAt }) => {\n    const apiKey = process.env.RESEND_API_KEY;\n    if (!apiKey) {\n      throw new Error(\"[sendProLaunchBroadcast] RESEND_API_KEY not set\");\n    }\n\n    const body: Record<string, unknown> = {};\n    if (scheduledAt) body.scheduled_at = scheduledAt;\n\n    const res = await fetch(\n      `${RESEND_API_BASE}/broadcasts/${encodeURIComponent(broadcastId)}/send`,\n      {\n        method: \"POST\",\n        headers: {\n          \"Content-Type\": \"application/json\",\n          Authorization: `Bearer ${apiKey}`,\n          \"User-Agent\": USER_AGENT,\n        },\n        body: JSON.stringify(body),\n      },\n    );\n","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/koala73/worldmonitor/blob/ffec79ac339946fd2d24e85845da5755dcaa534b/convex/broadcast/sendBroadcast.ts#L135-L171","documentation":"Thrown by sendProLaunchBroadcast when process.env.RESEND_API_KEY is falsy (undefined or empty string). This is a pre-flight environment check that fires before any HTTP call to Resend. The Convex environment variable must be set in the deployment's environment configuration.","triggerScenarios":"Running sendProLaunchBroadcast in a Convex deployment where the RESEND_API_KEY environment variable was never set. The variable was set in the dev deployment but not in production (or vice versa). The variable name has a typo or trailing whitespace in the Convex dashboard.","commonSituations":"A new Convex deployment was created without copying env vars from the old one. The key was cleared during an environment cleanup. Running against a preview deployment that does not inherit production secrets.","solutions":["Set the variable: `npx convex env set RESEND_API_KEY re_xxxxx` (use the key from the Resend dashboard > API Keys).","Verify it is set in the correct deployment target — run `npx convex env` or check `npx convex dashboard` for the target you are invoking.","Confirm the key has no leading/trailing whitespace or quotes when pasted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertResendKey(): void {\n  if (!process.env.RESEND_API_KEY) {\n    throw new Error(\"RESEND_API_KEY not set — run: npx convex env set RESEND_API_KEY re_xxxxx\");\n  }\n}\n// call before sendProLaunchBroadcast","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set RESEND_API_KEY in every Convex deployment target (prod, staging, preview) via `npx convex env set`.","After setting, verify with `npx convex env` that the variable is present.","Document required env vars in the project's deployment checklist."],"tags":["resend","environment","config","convex","secrets"],"backgroundTag":null,"analyzedSha":"ffec79ac339946fd2d24e85845da5755dcaa534b","analyzedAt":"2026-08-12T11:24:56.012Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}