How to Retrieve User-Specific Workflows or Programmatically Generate API Keys in Self-Hosted n8n?

Hi all,

We’re building AI-powered internal dashboards on top of our self-hosted n8n instance. These dashboards are meant to provide each user with personalized insights, such as active workflows, successful executions, and other workflow metrics.

While exploring the the n8n API playground at /api/v1/docs/, we’ve encountered a challenge: there doesn’t seem to be a straightforward way to retrieve workflows or executions scoped to individual users. From what we’ve found, the only way to access user-specific data is by using that user’s personal API key (available at /settings/api in the UI).

To streamline this process and improve the user experience, we want to avoid requiring users to manually generate and enter their API keys.

Our question is: Is there a way to either (1) retrieve user-specific workflows and executions directly via the API, or (2) programmatically generate or retrieve users’ API keys?

Any suggestions or best practices on how to approach this securely and efficiently would be greatly appreciated.

Thanks!

Information on your n8n setup

  • n8n version: 1.86.1
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Linux

If your dashboard “service” is running where it has access to the n8n database (user and user_api_key tables), and has access to the n8n config (either the N8N_ENCRYPTION_KEY environment variable or the /home/node/.n8n/config file, then you should be able to put those things together and find/retrieve/decrypt a user’s API key value. The source code for how n8n works with encryption can be found somewhat easily in the n8n Github repo.

You will find that the API, CLI, and workflow nodes (n8n node, read file node, etc.) block access to those things wherever possible for security reasons.

You would be writing your own (back-end) utility for this, so be sure you’re staying within what is allowed by the license.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.