{"record":{"id":"f25625f2b33aa654","repo":"nextauthjs/next-auth","slug":"postmark-error-json-stringify-await-res-json","errorCode":null,"errorMessage":"Postmark error: + JSON.stringify(await res.json())","messagePattern":"Postmark error: \\+ JSON\\.stringify\\(await res\\.json\\(\\)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/providers/postmark.ts","lineNumber":34,"sourceCode":"      const res = await fetch(\"https://api.postmarkapp.com/email\", {\n        method: \"POST\",\n        headers: {\n          Accept: \"application/json\",\n          \"Content-Type\": \"application/json\",\n          \"X-Postmark-Server-Token\": provider.apiKey,\n        },\n        body: JSON.stringify({\n          From: provider.from,\n          To: to,\n          Subject: `Sign in to ${host}`,\n          TextBody: text({ url, host }),\n          HtmlBody: html({ url, host, theme }),\n          MessageStream: \"outbound\",\n        }),\n      })\n\n      if (!res.ok)\n        throw new Error(\"Postmark error: \" + JSON.stringify(await res.json()))\n    },\n    options: config,\n  }\n}\n","sourceCodeStart":16,"sourceCodeEnd":39,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/core/src/providers/postmark.ts#L16-L39","documentation":"The Postmark email provider in Auth.js throws this error when the Postmark API responds with a non-OK HTTP status during sendVerificationRequest. The error message embeds the full JSON response body from Postmark, which contains their structured ErrorCode and Message fields explaining the failure (bad API token, invalid sender, etc.). It wraps any API-level rejection — authentication, validation, or rate limiting — into a single Error.","triggerScenarios":"A verification email send via the Postmark provider where fetch() to https://api.postmarkapp.com/email returns res.ok === false: invalid or missing POSTMARK_API_KEY, sender email not verified in Postmark, 'From' address not matching a verified sender signature, or invalid MessageStream.","commonSituations":"Developers forget to set the POSTMARK_API_KEY environment variable, use a sender domain that hasn't been verified in Postmark, or use the wrong MessageStream name (default 'outbound' must exist on the account). Also common in sandbox/test accounts with unverified senders.","solutions":["Verify POSTMARK_API_KEY is set correctly in your environment (.env) and matches a valid server API token.","Confirm the 'from' address in the provider config is a verified Sender Signature or belongs to a verified domain in your Postmark account.","Check that the MessageStream (default 'outbound') exists for your Postmark server.","Read the embedded JSON in the error message — Postmark's ErrorCode (e.g. 401 unauthorized, 300 invalid sender) identifies the exact cause."],"exampleFix":"// before\nfrom: process.env.EMAIL_FROM // \"no-reply@myapp.com\" — domain not verified in Postmark\n// after\n// Verify myapp.com in Postmark first, then:\nfrom: \"no-reply@myapp.com\"\nprovider: Postmark({ apiKey: process.env.POSTMARK_API_KEY })","handlingStrategy":"validation","validationCode":"if (!process.env.POSTMARK_API_KEY) throw new Error(\"POSTMARK_API_KEY is not set\")\n// Also verify the from address is a verified sender in your Postmark account before configuring the provider.","typeGuard":"function isPostmarkErrorBody(body: unknown): body is { ErrorCode: number; Message: string } {\n  return typeof body === \"object\" && body !== null && \"ErrorCode\" in body && \"Message\" in body\n}","tryCatchPattern":"try {\n  await signIn(\"email\", { email })\n} catch (err) {\n  // err.message starts with \"Postmark error: \" + JSON body\n  const body = JSON.parse((err as Error).message.replace(\"Postmark error: \", \"\"))\n  console.error(`Postmark ${body.ErrorCode}: ${body.Message}`)\n}","preventionTips":["Keep POSTMARK_API_KEY in validated env config checked at startup.","Verify your sender domain/signature in Postmark before deploying.","Monitor Postmark's bounce and spam-complaint webhooks to catch deliverability issues early.","Use the correct MessageStream name ('outbound' by default) for transactional email."],"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"}