{"record":{"id":"f437b75989cb31fd","repo":"nextauthjs/next-auth","slug":"resend-error-json-stringify-await-res-json","errorCode":null,"errorMessage":"Resend error: + JSON.stringify(await res.json())","messagePattern":"Resend error: \\+ JSON\\.stringify\\(await res\\.json\\(\\)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/providers/resend.ts","lineNumber":31,"sourceCode":"      const { identifier: to, provider, url, theme } = params\n      const { host } = new URL(url)\n      const res = await fetch(\"https://api.resend.com/emails\", {\n        method: \"POST\",\n        headers: {\n          Authorization: `Bearer ${provider.apiKey}`,\n          \"Content-Type\": \"application/json\",\n        },\n        body: JSON.stringify({\n          from: provider.from,\n          to,\n          subject: `Sign in to ${host}`,\n          html: html({ url, host, theme }),\n          text: text({ url, host }),\n        }),\n      })\n\n      if (!res.ok)\n        throw new Error(\"Resend error: \" + JSON.stringify(await res.json()))\n    },\n    options: config,\n  }\n}\n","sourceCodeStart":13,"sourceCodeEnd":36,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/core/src/providers/resend.ts#L13-L36","documentation":"The Resend email provider in Auth.js throws this error when the Resend API returns a non-OK status while sending a verification email. The response body JSON (which contains Resend's 'name' and 'message' error fields, e.g. validation_error, invalid_api_key) is serialized into the error message. It signals the send request was rejected by Resend before an email could be delivered.","triggerScenarios":"sendVerificationRequest fetch to https://api.resend.com/emails returns res.ok === false: missing/invalid RESEND_API_KEY, 'from' address not on a verified domain in Resend, malformed 'to' address, or exceeding the test-mode restriction (only sending to the account owner's email).","commonSituations":"New Resend accounts in test mode can only email the owner's own address — a very common cause. Others: unverified sending domain (domain verification DNS records not added), typo'd API key, or leaving RESEND_API_KEY unset after deploying.","solutions":["Verify RESEND_API_KEY is present and correct in your environment.","Check the JSON body in the error message — Resend's 'name'/'message' fields state the exact rejection reason.","In test mode, only send to your Resend account's own email address, or verify your sending domain in the Resend dashboard.","Ensure the 'from' address uses a domain verified in Resend (DNS records added and verified)."],"exampleFix":"// before\nfrom: \"onboarding@mycompany.com\" // unverified domain, test mode\n// after\n// In test mode, send only to your own account email:\nfrom: \"onboarding@resend.dev\" // or verify mycompany.com in Resend dashboard","handlingStrategy":"validation","validationCode":"if (!process.env.RESEND_API_KEY) throw new Error(\"RESEND_API_KEY is not set\")\n// In test mode, ensure the recipient is your Resend account's own email address.","typeGuard":"function isResendErrorBody(body: unknown): body is { name: string; message: string } {\n  return typeof body === \"object\" && body !== null && \"name\" in body && \"message\" in body\n}","tryCatchPattern":"try {\n  await signIn(\"email\", { email })\n} catch (err) {\n  const raw = (err as Error).message.replace(\"Resend error: \", \"\")\n  const { name, message } = JSON.parse(raw)\n  console.error(`Resend ${name}: ${message}`)\n}","preventionTips":["Validate RESEND_API_KEY at app startup, not on first email send.","Complete domain verification (DNS records) before switching off resend.dev sender.","Remember test mode restricts sends to your own account email.","Log the full response body on failure to capture Resend's error name."],"tags":["email","http-response","api-key","provider"],"backgroundTag":"email-provider-api-error","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}