Overview
n8n uses API key authentication to secure its REST API. Each API key can be configured with specific scopes to control access to different resources and operations.Creating an API Key
You can create API keys through the n8n user interface:1
Navigate to Settings
Go to Settings → API in your n8n instance.
2
Create New Key
Click Create API Key and provide:
- A descriptive label
- Selected scopes (permissions)
- Optional expiration date
3
Save the Key
Copy the generated API key immediately. It won’t be shown again for security reasons.
Authentication Methods
API Key Header (Recommended)
Pass your API key in theX-N8N-API-KEY header:
- cURL
- JavaScript (fetch)
- Python (requests)
- Node.js (axios)
Managing API Keys
List API Keys
Retrieve all API keys for your account.API keys in list responses are redacted for security. Only the first few and last few characters are visible.
Create API Key
Generate a new API key with specified permissions.string
required
A descriptive name for the API key
string[]
required
Array of permission scopes for this key
number
default:"null"
Unix timestamp (seconds) when the key expires.
null for no expiration.Update API Key
Modify an existing API key’s label or scopes.string
required
The API key ID
string
New label for the API key
string[]
Updated array of permission scopes
Delete API Key
Revoke an API key permanently.string
required
The API key ID to delete
Get Available Scopes
Retrieve the list of scopes available for your user role.API Key Scopes
Workflow Scopes
scope
Read workflow configurations and metadata
scope
Create new workflows
scope
Modify existing workflows
scope
Delete workflows
scope
Trigger workflow executions
scope
List all accessible workflows
scope
Activate workflows to run automatically
scope
Deactivate active workflows
Credential Scopes
scope
Read credential metadata (not sensitive data)
scope
Create new credentials
scope
Update existing credentials
scope
Delete credentials
scope
List all accessible credentials
Execution Scopes
scope
Read execution data and results
scope
List workflow executions
scope
Retry failed executions
scope
Stop running executions
scope
Delete execution records
Security Best Practices
Rotate Keys Regularly
Rotate Keys Regularly
Generate new API keys periodically and revoke old ones to minimize security risks.
Use Minimum Required Scopes
Use Minimum Required Scopes
Only grant the scopes necessary for your integration. This limits potential damage if a key is compromised.
Set Expiration Dates
Set Expiration Dates
For temporary integrations or testing, set an expiration date on API keys.
Monitor API Usage
Monitor API Usage
Regularly review your API keys and their usage patterns to detect unauthorized access.
Use Environment Variables
Use Environment Variables
Store API keys in environment variables, never hardcode them in your application.
Implement Request Signing (Advanced)
Implement Request Signing (Advanced)
For high-security scenarios, consider implementing request signing or using OAuth where available.
License Requirements
API Key Scopes is an enterprise feature. Without a license, API keys have access to all available scopes for the user’s role.
Common Issues
401 Unauthorized
Problem: Request returns401 Unauthorized
Solutions:
- Verify the API key is correct
- Check that the key hasn’t expired
- Ensure you’re using the correct header name:
X-N8N-API-KEY
403 Forbidden
Problem: Request returns403 Forbidden
Solutions:
- Verify your API key has the required scope for the operation
- Check that the key is active and not revoked
- Ensure you have access to the requested resource
Rate Limiting
Problem: Request returns429 Too Many Requests
Solutions:
- Implement exponential backoff
- Reduce request frequency
- Cache responses when possible
- Contact support for higher limits if needed
Next Steps
Workflows API
Start managing workflows programmatically
Executions API
Monitor and control workflow executions
Credentials API
Manage authentication credentials
API Overview
Return to API overview