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:Create New Key
Click Create API Key and provide:
- A descriptive label
- Selected scopes (permissions)
- Optional expiration date
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.A descriptive name for the API key
Array of permission scopes for this key
Unix timestamp (seconds) when the key expires.
null for no expiration.Update API Key
Modify an existing API key’s label or scopes.The API key ID
New label for the API key
Updated array of permission scopes
Delete API Key
Revoke an API key permanently.The API key ID to delete
Get Available Scopes
Retrieve the list of scopes available for your user role.API Key Scopes
Workflow Scopes
Read workflow configurations and metadata
Create new workflows
Modify existing workflows
Delete workflows
Trigger workflow executions
List all accessible workflows
Activate workflows to run automatically
Deactivate active workflows
Credential Scopes
Read credential metadata (not sensitive data)
Create new credentials
Update existing credentials
Delete credentials
List all accessible credentials
Execution Scopes
Read execution data and results
List workflow executions
Retry failed executions
Stop running executions
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