koala73/worldmonitor · error · Error

[sendProLaunchBroadcast] RESEND_API_KEY not set

Error message

[sendProLaunchBroadcast] RESEND_API_KEY not set

What it means

Configuration gate in the sendProLaunchBroadcast action: process.env.RESEND_API_KEY is unset on the Convex deployment, so the send request cannot be authenticated. Fails fast before touching the broadcast.

Solutions

  1. Set RESEND_API_KEY in the Convex dashboard environment variables and retry
  2. Verify the env var is set on the specific deployment (preview vs production) being used
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at convex/broadcast/sendBroadcast.ts:153 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21). Data as JSON: /api/errors/fd6998df431f5c66. Report an issue: GitHub.

Appendix: source

Thrown at convex/broadcast/sendBroadcast.ts:153

/**
 * Send (or schedule) a previously-created Resend Broadcast.
 *
 * `scheduledAt`: ISO 8601 timestamp string OR a natural-language phrase
 * Resend accepts ("in 2 hours"). Omit for immediate send.
 *
 * Resend's send endpoint is fire-and-forget — it returns immediately
 * after queueing. Track delivery via the `broadcastEvents` table
 * (populated by webhook events) or the `getBroadcastStats` action.
 */
export const sendProLaunchBroadcast = internalAction({
  args: {
    broadcastId: v.string(),
    scheduledAt: v.optional(v.string()),
  },
  handler: async (_ctx, { broadcastId, scheduledAt }) => {
    const apiKey = process.env.RESEND_API_KEY;
    if (!apiKey) {
      throw new Error("[sendProLaunchBroadcast] RESEND_API_KEY not set");
    }

    const body: Record<string, unknown> = {};
    if (scheduledAt) body.scheduled_at = scheduledAt;

    const res = await fetch(
      `${RESEND_API_BASE}/broadcasts/${encodeURIComponent(broadcastId)}/send`,
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: `Bearer ${apiKey}`,
          "User-Agent": USER_AGENT,
        },
        body: JSON.stringify(body),
      },
    );

View on GitHub (pinned to eeab0a219f)