{"record":{"id":"84a23fa6518501dc","repo":"payloadcms/payload","slug":"error-sending-email-statuscode","errorCode":null,"errorMessage":"Error sending email: ${statusCode}","messagePattern":"Error sending email: (.+?)","errorType":"http","errorClass":"APIError","httpStatus":null,"severity":"error","filePath":"packages/email-resend/src/index.ts","lineNumber":69,"sourceCode":"        headers: {\n          Authorization: `Bearer ${apiKey}`,\n          'Content-Type': 'application/json',\n        },\n        method: 'POST',\n      })\n\n      const data = (await res.json()) as ResendResponse\n\n      if ('id' in data) {\n        return data\n      } else {\n        const statusCode = data.statusCode || res.status\n        let formattedError = `Error sending email: ${statusCode}`\n        if (data.name && data.message) {\n          formattedError += ` ${data.name} - ${data.message}`\n        }\n\n        throw new APIError(formattedError, statusCode)\n      }\n    },\n  })\n\n  return adapter\n}\n\nfunction mapPayloadEmailToResendEmail(\n  message: SendEmailOptions,\n  defaultFromAddress: string,\n  defaultFromName: string,\n): ResendSendEmailOptions {\n  return {\n    // Required\n    from: mapFromAddress(message.from, defaultFromName, defaultFromAddress),\n    subject: message.subject ?? '',\n    to: mapAddresses(message.to),\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/email-resend/src/index.ts#L51-L87","documentation":"Thrown by the Resend email adapter when the Resend API response has no 'id' (success marker) and therefore represents an error. The adapter formats the upstream statusCode (and, if present, name + message) into an APIError thrown back to the caller. Root cause is in the Resend response: auth failure (401/403), validation (422), rate limit (429), or a Resend server error (5xx).","triggerScenarios":"Calling payload.sendEmail with the Resend adapter when the Resend API rejects the request — bad/revoked API key, invalid from-address, unverified sending domain, rate-limited, or a malformed message.","commonSituations":"Resend API key rotated but not updated in env; sending from an address whose domain is not verified in Resend; hitting Resend rate limits during bulk sends; transient Resend 5xx.","solutions":["Inspect the formatted error (it appends name + message) for the Resend-specific reason and address it (verify domain, fix from-address, etc.).","Confirm the RESEND_API_KEY / configured key is valid and has not been revoked.","For 429, back off and retry with exponential backoff; for 5xx, retry after a delay.","Verify the 'from' domain is verified in Resend and the recipient address is valid."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async function resendReachable(adapter) {\n  // send a no-op/before-send hook check or verify domain via Resend API\n}","typeGuard":null,"tryCatchPattern":"async function sendWithRetry(payload, msg, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await payload.sendEmail(msg) }\n    catch (err) {\n      const retryable = /429|5\\d\\d/.test(err.message) || err.statusCode >= 500\n      if (!retryable || i === attempts - 1) throw err\n      await new Promise(r => setTimeout(r, 2 ** i * 500))\n    }\n  }\n}","preventionTips":["Keep the Resend API key in a secret manager and rotate without code changes.","Verify sending domains in Resend before deploying.","For bulk sends, throttle to stay under Resend rate limits."],"tags":["email","resend","network","api"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}