// guides · n8n error index

n8n API 401 Unauthorized or 403 Forbidden: API key fixes, tested

n8n public API returning 401 or 403? Tested on 2.43.7: X-N8N-API-KEY header, scopes, expired keys, /rest vs /api/v1, N8N_PATH and read-only active.

Updated 2026-10-30 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. How we tested, and what is real

    On 30 October 2026 we ran throwaway n8n 2.43.7 instances in Docker (the official n8nio/n8n:2.43.7 image), created API keys with and without scopes, and called the public API with curl in every wrong way we could think of: no key, a wrong key, the key as a Bearer token, an expired key, a key missing a scope, the wrong URL path, a custom N8N_PATH, and the API switched off. Every status code and message below is copied from those runs.

  2. Quick answer: which error do you have?

    What you getCauseFix
    401 {"message":"Unauthorized"}No key, wrong key, expired key, key sent as Authorization: Bearer, or the public API is disabled.Send the key in the X-N8N-API-KEY header to /api/v1/...; create a new key if it may have expired.
    403 {"message":"Forbidden"}The key is valid but lacks the scope for this call (for example only workflow:read when creating a workflow).Create a key with the needed scopes.
    401 {"status":"error","message":"Unauthorized"}You called /rest/..., the editor's internal API. API keys do not work there.Use /api/v1/....
    200 with an HTML page, or Unexpected token <You called /api/workflows without v1 and got the editor page.Add /v1.
    400 request/body/active is read-onlyYou sent "active": true when creating or updating a workflow.Remove it and call POST /api/v1/workflows/{id}/activate.
    400 request/body must have required property 'settings'The workflow body has no settings.Send "settings": {}.
    404 {"message":"Not Found"}Unknown workflow id.Check the id in the workflow URL.

  3. 401 Unauthorized: send the key the right way

    The public API only accepts the key in the X-N8N-API-KEY header. In our runs no key, a wrong key and the right key sent as Authorization: Bearer <key> all returned the same plain 401 {"message":"Unauthorized"}. The header name is not case sensitive (lowercase x-n8n-api-key worked). A key whose expiry date has passed also returns exactly the same 401, with no word about expiry, so if a key that used to work suddenly fails, check its expiration in Settings > n8n API and create a new one.

    curl -H "X-N8N-API-KEY: $N8N_API_KEY" https://n8n.example.com/api/v1/workflows

  4. 403 Forbidden: the key is missing a scope

    A 403 means the key itself was accepted. In n8n 2.x every API key has scopes, and creating a key without any was refused (scopes Required). Our key with only workflow:read and workflow:list could list workflows but got 403 {"message":"Forbidden"} when creating one. The scopes are grouped by resource, such as workflow:*, credential:*, execution:*, dataTable:* and communityPackage:*. Make a new key that includes the action you need (create, update, delete, activate) and swap it in. So 401 is about the key, 403 is about its scopes.

  5. Wrong URL: /rest, missing v1, or N8N_PATH

    Three URL mistakes looked like auth problems in our tests. Calling /rest/workflows with an API key returned 401 {"status":"error","message":"Unauthorized"}, because /rest is the editor's own API and only takes a browser login. Calling /api/workflows (no v1) returned HTTP 200 with the editor's HTML page, which shows up as Unexpected token < or HTML in an HTTP Request node. With N8N_PATH=/n8n/ the API moved to /n8n/api/v1/, and /api/v1 at the root returned 401. When you set up the n8n API credential in n8n itself, the base URL must also include /api/v1 and any N8N_PATH prefix.

  6. API key settings missing, or the docs page is 404

    With N8N_PUBLIC_API_DISABLED=true the API key settings were gone (creating a key returned 404) and every /api/v1 request got 401. Remove that variable and restart to get the API back. With N8N_PUBLIC_API_SWAGGERUI_DISABLED=true only the interactive docs at /api/v1/docs turned into 404; by default that page loads as an HTML playground and the API itself keeps working.

  7. 400 errors when creating or activating a workflow

    Creating a workflow with "active": true in the body returned 400 request/body/active is read-only. Leave it out and activate with POST /api/v1/workflows/{id}/activate. A body without settings returned 400 request/body must have required property 'settings'; an empty "settings": {} is enough. Activating a workflow with no trigger returned 400 Workflow cannot be activated because it has no trigger node. At least one trigger, webhook, or polling node is required. More activation errors are in n8n workflow could not be activated.

    curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" -H "Content-Type: application/json" \
      -d '{"name":"From API","nodes":[],"connections":{},"settings":{}}' \
      https://n8n.example.com/api/v1/workflows

All test results

Real runs on n8n 2.43.7 in Docker, 30 October 2026.

TestResult
No X-N8N-API-KEY header401 {"message":"Unauthorized"}
Wrong key401 {"message":"Unauthorized"}
Right key as Authorization: Bearer401 {"message":"Unauthorized"}
Lowercase x-n8n-api-key headerWorks
Expired key401 {"message":"Unauthorized"} (no expiry wording)
Key with workflow:read + workflow:list, POST /api/v1/workflows403 {"message":"Forbidden"}
Create a key without scopesRefused: scopes Required
API key on /rest/workflows401 {"status":"error","message":"Unauthorized"}
/api/workflows (no v1)200 text/html editor page
N8N_PATH=/n8n/, request to /api/v1401; API is at /n8n/api/v1/
N8N_PUBLIC_API_DISABLED=trueKey settings 404, /api/v1 401
N8N_PUBLIC_API_SWAGGERUI_DISABLED=true/api/v1/docs 404 (default 200)
Create workflow with "active": true400 request/body/active is read-only
Create workflow without settings400 request/body must have required property 'settings'
Activate workflow without trigger400 Workflow cannot be activated because it has no trigger node.
GET unknown workflow id404 {"message":"Not Found"}

Checklist

Good to know

What we did not test

n8n Cloud, the API behind a reverse proxy that strips custom headers, and every scope one by one. If a proxy is in front of n8n and the right key still gets 401, test the same curl against n8n directly on its port.

FAQ

Why does the n8n API return 401 Unauthorized with a valid API key?

The key must go in the X-N8N-API-KEY header to /api/v1/... In our tests a Bearer header, a wrong key, an expired key, a /rest URL and a disabled public API all gave 401. A custom N8N_PATH also moves the API to /your-path/api/v1/.

What is the difference between 401 and 403 in the n8n API?

401 means the key was not accepted. 403 Forbidden means the key works but is missing the scope for that action, so create a key with that scope.

Why does the n8n API return HTML instead of JSON?

You probably called /api/workflows without v1. n8n answers that with the editor page and HTTP 200. Use /api/v1/workflows.

How do I fix "request/body/active is read-only" in n8n?

Remove "active" from the workflow body and activate it afterwards with POST /api/v1/workflows/{id}/activate.

How do I fix "must have required property 'settings'" in the n8n API?

Add "settings": {} to the workflow body when you create it.

Related guides

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.