An n8n API key lets a script, another app or n8n itself control your n8n through its REST API, without your password. Since n8n 2.14, every key can be limited to the scopes it needs, so a key that only reads workflows can’t change or delete anything.
This guide creates a key for one small job, a report that lists your workflows. You give it just two scopes, set it to expire, and test it from Terminal with one curl command.
Every screen and output on this page is real, run with n8n 2 in Docker on macOS.
What You’ll Have
A key named Workflow report that can list and read workflows for 7 days and nothing else, and a curl command that proves it works.
Prerequisites
- n8n 2.14 or newer, signed in. On n8n Cloud, the API isn’t available during the free trial.
- curl in Terminal, to test the key. macOS includes it.
Step 1: Open the API Settings
Click your name at the bottom of the left sidebar, then Settings, and choose n8n API under Integrations. Click Create API key.
Step 2: Name the Key and Choose When It Expires
Type a Label that says what the key is for, here Workflow report. Under Expiration, choose 7 days, and n8n shows the date the key stops working. The other choices are 30, 60 and 90 days, a custom date, or Never. Pick the shortest time the job needs: you can always make a new key.
Step 3: Give the Key Only the Scopes It Needs
A scope is one thing the key may do, such as listing workflows. Under Scopes, choose Custom. n8n lists all 119 scopes, grouped by what they work on. Type workflow in the search box and tick two:
- workflow:list to see the list of workflows.
- workflow:read to read each one.
Both are marked read, so the key can’t change anything:

All would give the key every scope, and Read only gives it the 37 read scopes, including executions and users. Custom keeps it to what the report needs. Click Save.
Step 4: Copy the Key
n8n shows the key once and never again. Click the copy button, keep the key somewhere safe, such as a password manager, and click Done:

The key is in the list now, with its 2 scopes and its expiry date. From now on, n8n shows only the end of it:

Step 5: Test the Key with curl
n8n reads the key from a header named X-N8N-API-KEY. This command asks your n8n for its workflows. Replace YOUR_API_KEY with your key:
curl -H "X-N8N-API-KEY: YOUR_API_KEY" http://localhost:5678/api/v1/workflows
curl sends a request to the address at the end, and -H adds the header with your key. The address is your n8n followed by /api/v1/workflows. n8n answers with its workflows as JSON, here the one workflow on this n8n, Say hello:
{"data":[{"id":"qVR4wwvJk2ixjoeN","name":"Say hello","active":false, … }],"nextCursor":null}
Step 6: See the Scopes at Work
Now ask for something the key may not see, the list of executions:
curl -H "X-N8N-API-KEY: YOUR_API_KEY" http://localhost:5678/api/v1/executions
{"message":"Forbidden"}
n8n refuses it, because the key has no execution scopes. The key does its one job and nothing more. Without any key at all, n8n answers {"message":"Unauthorized"}.
Clean Up
When you no longer need a key, revoke it. In Settings › n8n API, click ⋯ on its row, then Revoke, and Revoke again to confirm. Anything still using the key stops working at once and gets Unauthorized, and revoking can’t be undone.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Choosing All for every key | A leaked key can change or delete anything on your n8n | Choose Custom with only the scopes the job needs |
| Clicking Done before copying the key | n8n never shows the key again | Revoke it and create a new one |
| Choosing Never for a key you only need for a while | The key keeps working long after its job is over | Pick the shortest expiry that fits the job |
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
{"message":"Unauthorized"} | No key, a wrong key, or a key that was revoked | Send the key in the X-N8N-API-KEY header; create a new key if the old one was revoked |
{"message":"Forbidden"} | The key has no scope for that request | Create a key that has the scope the request needs |
| No n8n API page in Settings on n8n Cloud | The API isn’t available during the free trial | Use it on a paid Cloud plan or on self-hosted n8n |
FAQ
Can I see an API key again later?
No. n8n shows a key once, when you create it, and afterwards only its last characters. If you lose it, revoke it and create a new one.
What is the address of the n8n API?
Your n8n’s address followed by /api/v1, such as http://localhost:5678/api/v1 for n8n on your computer. Each kind of data has its own path after that, such as /workflows.
Can I use an API key inside an n8n workflow?
Yes. The n8n node reads and changes your workflows, executions and credentials through the same API. You save the key once as an n8n API credential, and the node uses it.
Conclusion
An n8n API key takes a minute to make: a label, an expiry and the scopes the job needs. Choosing Custom with only those scopes means a key that leaks can do very little, and the expiry date means it stops on its own. One curl command tells you it works.
Additional Resources
- Authentication for the n8n API (opens in a new tab) (n8n docs)
- n8n API reference (opens in a new tab) (n8n docs)
Related
n8n and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by n8n GmbH.
0 comments