nextauthjs/next-auth · error · Error

Postmark error: + JSON.stringify(await res.json())

Error message

Postmark error: + JSON.stringify(await res.json())

What it means

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.

Source

Thrown at packages/core/src/providers/postmark.ts:34

      const res = await fetch("https://api.postmarkapp.com/email", {
        method: "POST",
        headers: {
          Accept: "application/json",
          "Content-Type": "application/json",
          "X-Postmark-Server-Token": provider.apiKey,
        },
        body: JSON.stringify({
          From: provider.from,
          To: to,
          Subject: `Sign in to ${host}`,
          TextBody: text({ url, host }),
          HtmlBody: html({ url, host, theme }),
          MessageStream: "outbound",
        }),
      })

      if (!res.ok)
        throw new Error("Postmark error: " + JSON.stringify(await res.json()))
    },
    options: config,
  }
}

View on GitHub (pinned to a1a16a5a77)

Solutions

  1. Verify POSTMARK_API_KEY is set correctly in your environment (.env) and matches a valid server API token.
  2. Confirm the 'from' address in the provider config is a verified Sender Signature or belongs to a verified domain in your Postmark account.
  3. Check that the MessageStream (default 'outbound') exists for your Postmark server.
  4. Read the embedded JSON in the error message — Postmark's ErrorCode (e.g. 401 unauthorized, 300 invalid sender) identifies the exact cause.

Example fix

// before
from: process.env.EMAIL_FROM // "no-reply@myapp.com" — domain not verified in Postmark
// after
// Verify myapp.com in Postmark first, then:
from: "no-reply@myapp.com"
provider: Postmark({ apiKey: process.env.POSTMARK_API_KEY })
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.POSTMARK_API_KEY) throw new Error("POSTMARK_API_KEY is not set")
// Also verify the from address is a verified sender in your Postmark account before configuring the provider.

Type guard

function isPostmarkErrorBody(body: unknown): body is { ErrorCode: number; Message: string } {
  return typeof body === "object" && body !== null && "ErrorCode" in body && "Message" in body
}

Try / catch

try {
  await signIn("email", { email })
} catch (err) {
  // err.message starts with "Postmark error: " + JSON body
  const body = JSON.parse((err as Error).message.replace("Postmark error: ", ""))
  console.error(`Postmark ${body.ErrorCode}: ${body.Message}`)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nextauthjs/next-auth@a1a16a5a77 (2026-08-28). Data as JSON: /api/errors/f25625f2b33aa654. Report an issue: GitHub.