API 身份验证(API authentication)#
n8n 使用 API 密钥对 API 调用进行身份验证。
🌐 n8n uses API keys to authenticate API calls.
功能可用性
在免费试用期间,n8n API 无法使用。请升级以访问此功能。
API 作用域(API Scopes)#
企业实例 的用户可以通过作用域限制密钥可以访问的资源和操作。API 密钥作用域允许你指定密钥为其预期用途所需的精确访问级别。
🌐 Users of enterprise instances can limit which resources and actions a key can access with scopes. API key scopes allow you specify the exact level of access a key needs for its intended purpose.
非企业级 API 密钥拥有对账户所有资源和功能的完全访问权限。
🌐 Non-enterprise API keys have full access to all the account's resources and capabilities.
创建 API 密钥(Create an API key)#
- 登录到 n8n
- 转到 设置 > n8n API。
- 选择 创建 API 密钥。
- 选择一个标签并为密钥设置到期时间。
- 如果使用企业计划,请选择要授予密钥的范围。
- 复制 我的 API 密钥 并使用此密钥来验证你的调用。
使用你的密钥调用 API(Call the API using your key)#
在你的 API 调用中,将 API 密钥作为名为 X-N8N-API-KEY 的请求头发送。
🌐 Send the API key in your API call as a header named X-N8N-API-KEY.
例如,假设你想获取所有活动的工作流。你的 curl 请求将如下所示:
🌐 For example, say you want to get all active workflows. Your curl request will look like this:
1 2 3 4 5 6 7 8 9 10 11 | |
删除 API 密钥(Delete an API key)#
- 登录到 n8n
- 转到 设置 > n8n API。
- 选择要删除密钥旁边的删除。
- 通过选择 永久删除 来确认删除。