N8n Gateway Anthropic node: small requests work, larger code payloads fail with "Forbidden - perhaps check your credentials?"

Describe the problem/error/question

I use the Anthropic node on n8n Cloud, billed through n8n Gateway credits (model claude-sonnet-5-5). A tiny synthetic prompt works. Larger requests that embed a block of Python source fail immediately with:

Forbidden - perhaps check your credentials?

What is the error message (if any)?

Only that string. The node surfaces no HTTP status, headers or response body, so I can’t tell which layer rejected the call (Gateway, upstream provider, a size cap or a content rule). No answer and no token usage are returned for the failed calls. I stopped retrying after three failures.

What I have verified

  • The same workflow, model and Gateway balance succeed for the small prompt (about 380 input tokens), so a plain invalid credential looks unlikely.
  • I have not shown that request size or the code content is the cause. That is a guess.
  • I do not know whether the failed calls used any credits.

Questions

  1. Does the Gateway Anthropic node enforce a request size limit or a content rule that returns 403 / “Forbidden”?
  2. How do you capture the upstream status and headers for this node (continue on fail, a raw HTTP Request node, something else), so failures can be classified instead of guessed?
  3. Were credits deducted for your failed calls?

I have also emailed n8n support and will post whatever they confirm here.

Information on your n8n setup

  • n8n Cloud
  • Anthropic node using n8n Gateway credits
  • Model: claude-sonnet-5-5

Hey @Alejandro_Duran, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@fahmiiireza, @mohamed3nan - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

Hi @Alejandro_Duran

Continue on Fail won’t expose the Anthropic node’s raw response headers. If you have your own Anthropic key, HTTP Request can capture a direct response: under Response, enable Include Response Headers and Status and Never Error, and select Response Format → Text. That bypasses Gateway and bills your Anthropic account, so it’s a separate comparison.

The Gateway docs don’t specify a size or content rule explaining this 403. Add the three failed execution IDs and timestamps with timezone to your existing support ticket, and ask for the actual Gateway response and any request ID.

For credits, check Cloud console → Gateway credits, select the relevant time range and group spend by workflow. Missing token usage doesn’t prove the calls were free; ask support to confirm the charge, if any, for each failed execution.

Hi Alejandro,

Good troubleshooting so far. Since the small prompt succeeds with the same model and Gateway balance, I agree that an invalid credential alone is less likely, although it isn’t completely ruled out.

I’d isolate the failure in a few steps before attributing it to payload size or code content:

  1. Increase the prompt size gradually using synthetic text, without Python code, to check whether failure correlates with payload size.

  2. Keep the payload size similar but replace the code block with neutral synthetic text to help distinguish a size-related issue from a content-related one.

  3. If possible, inspect the failed node’s execution details and error object. A raw HTTP Request node may help compare behavior only if it can access the same Gateway endpoint and authentication path; it may not reproduce the Anthropic node’s exact request.

The most useful evidence from n8n support would be the actual HTTP status, Gateway/upstream error body, request-size limits, and confirmation of whether failed requests consume credits.

Until those details are available, I’d treat the cause as unconfirmed rather than assuming it’s a credential, payload limit, or content-policy issue.

Please share what support confirms—I’d be interested in the findings.

Thanks @Anshul_Namdev and @Shital_Katre, that was a good plan. I ran
it today (Oct 21, 14:08 to 14:10 UTC): same workflow, same Anthropic
node, same Gateway credential, same model (claude-sonnet-5-5),
synthetic content only, one call each, no retries.

  • 300 characters of plain prose: OK (454 input tokens)
  • 8,000 characters of plain prose: OK (2,877 input tokens)
  • 1,000 characters of Python: OK (881 input tokens)
  • 8,000 characters of Python: OK (4,565 input tokens)

So neither size nor code-like content on its own reproduces the 403
today. The October 16 failures were real source files, and the smaller
excerpt of that same source also failed.

That leaves two candidates: something specific in that source tripping
a filter (n8n support mentioned Cloudflare edge protection as a
working theory, which would fit content-specific matching), or a
transient Gateway problem that day. I’m sending support the failed
execution IDs and timestamps and asking for the edge or Gateway log
for those requests. I’ll post what they confirm.

Alejandro

Thanks for running these tests and sharing the results. The successful synthetic tests make a general payload-size or code-content limit less likely. Comparing the failed requests against the Gateway or edge-protection logs should help distinguish source-specific filtering from a transient issue. It will be useful to see what support confirms.

The node’s “Forbidden - perhaps check your credentials?” is a catch-all for whatever 4xx the API call returned, so the first move is to see the real status and body: reproduce the same request in an HTTP Request node (or curl) against the Messages endpoint using the same Gateway credential. That gives you the actual error JSON, and it is what the Gateway or edge logs should be compared against.

Two things that reproduction is worth aiming at, given 8k characters of synthetic Python passes: resend the exact failing source file rather than another excerpt, so content-specific filtering is the only variable left; and skim that file for anything shaped like a secret - API keys, tokens, connection strings. Payload filters that reject “looks like a credential” content usually answer with a 403 and zero token usage, which is your symptom exactly.

If the body names a challenge or abuse filter, that is the layer to argue with. If it is an entitlement or spend message instead, it is a Gateway credit or quota block rather than the node - and a plain Anthropic API key in a second copy of the workflow separates those two cases in one run.

Thanks @HomelabAgent and @Shital_Katre, that’s useful.

The point about credential-shaped content fits the symptom well: 403, zero token usage, and only the real source files fail while synthetic Python of the same size passes. Next I’ll do three things:

  1. Read through the October 16 source for anything that looks like a key, token or connection string.
  2. Send that exact file through an HTTP Request node to the Messages endpoint with the same Gateway credential, so I get the real status and error body instead of the node’s catch-all message.
  3. If that’s still unclear, run a copy of the workflow with a plain Anthropic API key to separate a Gateway or edge filter from a credit or quota block.

I’ll add the result to the support ticket alongside the failed execution IDs and post here what comes back.

Alejandro

Swap the node for an HTTP Request call to the API with your own key and the same payload. That shows the real status code and response body, which the node hides. Then halve the payload until it passes, so you know if it’s size or content before you chase support.

@Alejandro_Duran Since 8k characters of synthetic text pass but real Python source fails with a 403 and zero token usage, an edge WAF or Cloudflare rule in front of the Gateway is almost certainly flagging a string pattern in your code rather than hitting a payload size ceiling. To locate the offending pattern quickly without waiting on support logs, perform a binary split: cut the failing Python file in half, send each half through the node, and repeat on whichever half errors. In three or four test runs, you’ll isolate the exact line, comment, or variable name triggering the filter (common culprits are dummy bearer tokens, connection strings, or eval/exec constructs). If you must pass the raw source code unchanged and the filter is a false positive, a reliable workaround is to base64-encode the file in an upstream Code node and instruct Claude in your system prompt to decode it before analysis. I haven’t tested your specific Gateway tier setup, but this pattern consistently bypasses edge WAF false positives. Were you able to run the split test on the October 16 file?

Thanks @BenRon and @operantsolo.

Update for anyone who lands here: I switched to a plain HTTP Request node calling the Anthropic Messages API directly with my own API key (predefined Anthropic credential, anthropic-version header). That route has been working reliably in a daily scheduled workflow.

I haven’t yet re-run the original large code payloads through the direct route, so I can’t confirm the edge filter theory either way. I’ll post back once I’ve tested those specific files.

The latest tests are useful because they make a general payload-size limit less likely.

I agree that the next step is to compare the exact failing request with the Gateway or edge logs and inspect the real HTTP response body. That should help distinguish content-specific filtering from a transient Gateway issue or an entitlement problem.

One important point: I’d avoid treating Base64 encoding as a confirmed workaround until it has been tested and its security implications reviewed. It may change how the payload is inspected, but it doesn’t establish the root cause.

Thanks for sharing the test results. I’m interested to see what support confirms.

running into canvas file not found errors usually happens when relative file paths resolve against a temporary launch process rather than the persistent workspace root. opening your project directory directly from an absolute canonical path without symbolic links typically clears the asset registration issue.

in our automated release documentation workflows, passing exported canvas assets and release changelogs through blotato keeps our devlog announcements synchronized across community channels without missing file reference errors.

are you running cursor inside a multi-root workspace or executing from a single folder root?

Two separate things, and the 403 is probably not what it looks like. First, large payloads: the Gateway or its front proxy will answer 403 when it truncates or rewrites the body before it reaches Anthropic, so check the request as received at the gateway (what Content-Length and the auth header actually arrived). Second, the canvas file not found is a path problem, not auth: the asset pipeline resolves relative paths against a temp launch dir, so point the workflow at an absolute canonical path with no symlinks so it resolves against your project root. Fix the path first and the 403 usually disappears once the body arrives intact.

@Alejandro_Duran Good to hear the direct HTTP Request route is stable. When you re-run the large files through it, that’s a clean test: if they pass directly but fail through the Gateway, the block is in front of the Gateway, not in your payload. @Shital_Katre fair point on base64. I should have framed it as something to test, not a confirmed workaround.