Deliverability

Postmark error 403 Forbidden from Cloudflare Workers (WAF)

A 403 Forbidden on a Postmark call from a Cloudflare Worker usually comes from a firewall or WAF rule on the host being called, not from Postmark itself. Log the response body and cf-ray header, find the matching event in Cloudflare Security events, then add a narrow skip rule.

Sohail HussainSohail Hussain10 min read

Short answer

  • A 403 with no Postmark JSON body usually came from a firewall or WAF in front of the URL your Worker called, not from Postmark's API.
  • Log the status, headers and body start inside the Worker, then find the blocked request in that domain's firewall logs and add a narrow skip or allow rule.
  • If the body is Postmark JSON, check the account setting for IP allowlisting on send requests, because Worker egress IPs are not fixed.

Your Worker was sending email through Postmark, nothing in your code changed, and now every call fails with Postmark error: 403 Forbidden. People on Cloudflare's community forum report exactly this. In the thread this page is based on, the fix was in the WAF of the target domain, and another user said they saw 403s outside Cloudflare too. The thread is short, so I can't see the poster's full setup. What follows is the method that finds the source of a 403 whatever the setup is.

What a 403 means here

A 403 means the server understood the request but refused to process it. That is similar to 401, except that re-authenticating makes no difference. So retrying the same request unchanged will keep failing.

The useful question is who refused it. Three layers can answer with a 403:

  • Postmark's API. Its error responses normally carry JSON with an ErrorCode and a Message.
  • A WAF or bot rule on a host you call. This is common when the Worker calls your own relay, proxy or custom domain, or when Postmark posts a webhook to your domain. These responses are often an HTML block page with no JSON.
  • An account-level restriction in Postmark. With IP allowlisting turned on, a send request from any address outside the allowlist is rejected with a 403.

Why it happens

Most common first:

  1. A WAF, managed rule or bot rule on the domain you are calling. Server-to-server POSTs have no browser fingerprint, so bot and managed rules can start blocking them after a ruleset update, even though your code is unchanged. For AWS WAF, a blocked request gets an HTTP 403 by default.
  2. A missing or odd User-Agent, or a changed request shape. Some rules target requests without a user agent. People calling other APIs report that adding one cleared a 403.
  3. IP allowlisting on the Postmark account. Cloudflare Workers do not send from a small, stable address list, so an allowlist can block them. I can't tell you Workers' egress ranges, so don't try to allowlist them; use the other fixes.
  4. A webhook in the other direction. If Postmark is the one calling your endpoint, a 403 from your server is permanent for Postmark. Postmark retries on 5xx, 408 and 429, but treats other 4xx codes like 403 as permanent. Postmark says it has no more detail than that, and the 403 comes from your server.
  5. A wrong or rotated token. I'd expect a 401 for this, but verify rather than assume.

Step-by-step fixes

Fix 1: Work out who sent the 403

Log the status, a few headers and the start of the body inside the Worker. Never log the token.

const res = await fetch(url, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "X-Postmark-Server-Token": env.POSTMARK_TOKEN,
    "User-Agent": "my-app-worker/1.0"
  },
  body: JSON.stringify(payload)
});

if (!res.ok) {
  const text = await res.text();
  console.log(JSON.stringify({
    status: res.status,
    server: res.headers.get("server"),
    cfRay: res.headers.get("cf-ray"),
    contentType: res.headers.get("content-type"),
    body: text.slice(0, 300)
  }));
}

Then read the result:

What you seeLikely sourceNext step
JSON with ErrorCode and MessagePostmarkFix what the message says; check IP allowlisting
HTML block page or "Access denied"WAF or bot rule on the host you calledFix 3
server: cloudflare and a cf-ray on a host you ownYour own Cloudflare zoneFix 3
Empty body, no JSONProxy or gateway in betweenCheck where the URL really points

Also confirm the URL itself. If the Worker calls your own domain that forwards to Postmark, the 403 almost certainly comes from your side of that hop.

Fix 2: Reproduce it outside the Worker

Run the same call from a terminal with the same headers.

curl -i https://api.postmarkapp.com/email \
  -X POST \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "X-Postmark-Server-Token: {your-server-token}" \
  -d '{"From":"sender@example.com","To":"you@example.com","Subject":"Test","TextBody":"Test"}'

If you use a relay, swap in its URL. Then compare:

  1. curl works but the Worker fails: the block depends on something the Worker sends, such as user agent, source IP range, request rate or body. That fits a WAF, bot rule or IP allowlist.
  2. Both fail with the same 403: it is not Worker-specific. Check the token, the sender signature, the account's IP allowlist and the target host's firewall. This matches the report of 403s outside Cloudflare.
  3. Both fail with a different status and JSON: the problem is in the request or the account, not a firewall.

Fix 3: Find the blocking rule in the WAF

If the 403 came from a Cloudflare zone you control:

  1. Open the Cloudflare dashboard and select the zone for the host the Worker calls.
  2. Search the dashboard for Security events. Menu labels move, so use the search box.
  3. Filter by the cf-ray value you logged, or by path and time.
  4. Note the action (Block, Managed Challenge, JS Challenge) and which service fired: managed rules, custom rules, rate limiting or bot protection.
  5. Create a custom rule with the Skip action, scoped to the exact path (for example /email) plus an identifying header or source, and place it above the rule that blocks you.
  6. Retry and confirm the event stops appearing.

Do not switch the WAF off

Disabling protection for the whole zone to clear one 403 leaves every other path exposed. Scope the skip rule to one path and one identifying condition. A server-side fetch cannot solve a challenge, so a challenge rule has to be skipped or changed.

Cloudflare lists Skip among its WAF rule actions, alongside Block, Managed Challenge, JS Challenge and Log, according to a Cloudflare WAF service definition document. For other firewalls the logic is the same: find the request in that product's logs and add an exception for the path. In AWS WAF, rules are evaluated in priority order, lowest number first, so an allow rule must sit before the rule that blocks you.

Fix 4: Check Postmark's IP allowlist

If the response is Postmark JSON, open your Postmark account security settings and look for IP restrictions on sending. Postmark describes this feature in its account security best practices. If an allowlist is on and your Worker's outbound address isn't in it, the send is refused. Options: turn the restriction off for that server, or send through a fixed-IP relay you control and allowlist that address. Make that choice with your security needs in mind.

Fix 5: Check the token and account

Confirm the secret in your Worker is the Server API token for the right Postmark server and hasn't been rotated. If the JSON message mentions your account or sender signature, resolve that with Postmark.

Cause, symptom and fix at a glance

CauseSymptomFix
WAF or bot rule on your relay or webhook domainHTML block page, Ray ID, event in firewall logsScoped skip rule
Missing User-AgentWorks in a browser or Postman, fails from the WorkerSend an explicit User-Agent
Postmark IP allowlistJSON 403 from Postmark, curl from an unlisted network also failsAdjust the allowlist or use a fixed-IP relay
Postmark webhook blocked by your server403 in Postmark's webhook log; no retriesSkip rule for Postmark's requests to that path
Wrong or rotated tokenUsually 401, sometimes confusingRe-copy the Server API token

Webhook direction

If Postmark is calling your Worker or domain and gets a 403, fixing the WAF is not enough on its own. Postmark does not retry a 403, so you will need to resend the missed messages after the rule is fixed.

Checklist before you try again

  • The response body was read and classified as Postmark JSON or not.
  • The URL the Worker calls is the one you expect (direct to Postmark, or your relay).
  • The firewall event for that request was found by Ray ID or time.
  • A narrow skip rule exists and sits above the blocking rule.
  • The request sends an explicit User-Agent.
  • Postmark's IP restriction setting was checked.
  • The token is the current Server API token.

Preventing a repeat

Log status, cf-ray and a short body excerpt on every non-2xx response, so the next 403 takes a minute to classify. Keep a documented skip rule for server-to-server endpoints and review it when managed rulesets change. Where you can, call Postmark directly instead of through an extra hop you also have to protect. For background, see our email API and webhooks guide and the glossary entry on transactional email.

If nothing works

If you have ruled out your own firewall, contact Postmark support. If a Cloudflare rule is at fault and you can't find it, give Cloudflare support the Ray ID and zone name. Include the UTC timestamp, request path, full response headers and body, and whether curl from another network behaves the same.

Subject: 403 Forbidden on POST /email from a Cloudflare Worker

Since {date and time, UTC} our Worker's calls to {endpoint URL} return 403 Forbidden.
Response headers: {paste headers, including cf-ray and server}
Response body (first 300 characters): {paste body}
The same curl request from {network} returns: {status}.
Already checked: server token, sender signature, firewall events on {zone}, IP restrictions on the Postmark server.
Please confirm whether the 403 is generated by Postmark and, if so, which rule applies.

Common questions

Is a 403 from Postmark the same as a 401?

No. A 403 means the server is refusing the request, and unlike a 401 the client's identity is known to the server. In practice a bad token tends to be a 401, while a 403 points to a rule, restriction or firewall.

Why does it work in curl but not in the Worker?

Something in the request differs: the user agent, the source IP or the rate. Compare headers, then check the WAF events and the Postmark IP allowlist.

Will Postmark retry a webhook that got a 403?

Not as a failed-then-retried delivery. Postmark says retries stop immediately on a 403 Forbidden response. Fix the rule, then use Postmark's manual retry for the failed inbound messages.

Can I just allowlist Cloudflare IPs?

I would not rely on it. I can't confirm a stable egress range for Workers, so scope a skip rule by path and a header or similar condition instead.

deliverabilitypostmarkcloudflare-workerserror-codes
Share this article
Sohail Hussain

Sohail Hussain

Founder & CEO at Mailneo

Building Mailneo — AI-powered email marketing for growing businesses.

Related Articles

Deliverability

DMARC Alignment mtasv.net != Domain: Postmark's Second DKIM Signature

A checker showing "DMARC Alignment mtasv.net != mydomain.com" is flagging Postmark's own DKIM signature, which was never meant to align. DMARC passes if any one DKIM signature or SPF result aligns with your From domain. Confirm your own signature aligns, then read your DMARC reports source by source.

Sohail Hussain|8 min read
Deliverability

0x800ccc0e: Outlook Unable to Connect to SMTP Server, Fixed

Outlook error 0x800ccc0e means the app could not open a connection to your outgoing (SMTP) server. Usually the port, encryption setting or password is wrong, or antivirus, a firewall or your ISP is blocking it. Set port 587 with STARTTLS, turn on SMTP authentication, and test again.

Sohail Hussain|10 min read
Deliverability

SocketLabs "421 4.5.1 Too many errors" blacklist: how to fix it

`421 4.5.1 Too many errors, you have been temporarily blacklisted` means a SocketLabs server saw repeated auth or bad-address errors from your IP and paused it. Stop whatever is retrying, fix credentials and invalid recipients, clear the queue, and wait. The block usually lifts within minutes, but returns if retries resume.

Sohail Hussain|9 min read
Deliverability

421-4.7.0 Gmail Has Detected This Message Is Suspicious: Fix

The 421-4.7.0 "suspicious due to the nature of the content and/or the links" error means Gmail's content filter rejected your message after DATA, not an authentication check. Remove click tracking or move it to your own domain, drop URL shorteners, check link reputation, then retest with a plain message.

Sohail Hussain|10 min read

Ready to supercharge your email marketing?

Start sending smarter emails with AI-powered campaigns. No credit card required.

Get Started Free