Learn how to configure the n8n API with an API key, enabling streamlined workflow automation for your cloud or self-hosted instance. This guide will take you through the steps to set up, configure, and verify your API key properly while also discussing important caveats related to scopes on lower subscription plans.
prerequisites
- A functioning n8n account (cloud or self-hosted).
- Access to account settings in n8n.
- A paid plan (API key creation is not available on the free tier).
Steps to Configure the n8n API with an API Key
Follow these steps to set up an API key for your n8n instance and link it to your workflows:
steps
Log into n8n.
Start by logging into your n8n account (either cloud or self-hosted).Access account settings.
Click on the three dots next to your account name in the upper-right corner and select Settings from the dropdown.Navigate to the 'n8n API' section.
On the side panel of the settings page, find and click n8n API.Create a new API key.
- Provide a meaningful name for the key.
- (Optional) Set an expiration date or use "No Expiration."
- Click Save to generate the key.
Save the API key value.
- Copy the generated API key securely.
- Never share your API key publicly, as it grants access to your instance.
Determine the base URL of your n8n instance.
- For cloud instances, the URL will look something like
https://your-instance-name.n8n.cloud/v1. - For self-hosted setups, it should match your deployment domain with the appended path
/v1.
- For cloud instances, the URL will look something like
Input credentials in the NAND node.
Open a workflow that requires the n8n API. Inside the NAND node settings:- In Credentials, select "Create New Credential."
- Paste the API key and base URL into the corresponding fields.
Save and test the setup.
- Save the credentials and run a basic workflow (e.g., fetching workflows or schema) to ensure proper configuration.
Common Mistakes During n8n API Setup
Verification of API Key Setup
To ensure your API key integration is successful, perform the following steps:
steps
Test the integration with a sample workflow.
Create or open a workflow in n8n and configure it to use the recently added credentials in a NAND node.Fetch and verify data.
- For example, configure the NAND node to fetch the first five workflows or another dataset.
- Run the workflow and inspect the output JSON. Confirm it matches the expected data from your account.
Troubleshoot if issues arise.
- Verify the expiration date of the API key.
- Double-check that the base URL and API key were entered correctly.
- Review error messages, as they often provide hints about misconfigurations.
Scopes Limitations on Lower n8n Plans
Tips for Using n8n API with Multiple Accounts
FAQ
How do I get my n8n API key?
To get your n8n API key, log into your n8n account, open the account settings, go to the "n8n API" section, create a new key, and copy the generated value.
Can I use customized API key permissions?
API key scope customization is available only with an enterprise plan. Lower plans have default scopes that cannot be changed.
Can I use the n8n API for both cloud and self-hosted accounts?
Yes, the n8n API and its API key configuration work on both cloud-hosted and self-hosted setups, provided you use the correct base URL for each instance.
What is the base URL for my n8n instance?
For cloud users, the base URL will resemble https://your-instance-name.n8n.cloud/v1. For self-hosted setups, it depends on the domain you've configured, followed by /v1.
Official reference: n8n documentation.