-
Notifications
You must be signed in to change notification settings - Fork 46k
feat: Add workflow execute endpoint to public API #20304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Add 'execute' operation to workflow API key resource permissions - Implement POST /workflows/:id/execute endpoint - Add API key scope validation for workflow execution - Emit workflow-pre-execute event on execution - Add OpenAPI specification for execute endpoint 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Adds integration tests for the new POST /workflows/:id/execute endpoint covering: - API key authentication (missing and invalid keys) - Non-existing workflow handling - Successful execution of owned workflows - Owner access to member workflows - Permission denial for unauthorized access Also removes manual workflow-pre-execute event emission as it's already handled by WorkflowExecutionService.executeManually() through lifecycle hooks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
from #20234 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 5 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="packages/cli/test/integration/public-api/workflows.test.ts">
<violation number="1" location="packages/cli/test/integration/public-api/workflows.test.ts:1644">
`execute` returns 404 with message `Workflow with ID "999" not found.` from the scope middleware, but the test asserts `'Not Found'`, so the test will fail. Please update the expectation to match the actual message returned by the endpoint.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
Hey @samir-abis, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: Regarding new nodes: If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach. About review timelines: Thank you again for contributing to n8n. |
…eters<typeof mock<T>>[0]
I would really appreciate it if this feature were implemented. |
This PR adds a new
POST /workflows/:id/execute
endpoint to the n8n public API, enabling programmatic workflow execution via API keys. This addresses a long-standing gap in the public API where workflows could be created, updated, activated,and deactivated, but not executed directly by ID.
What Changed:
execute
operation to workflow resource permissions for API keysPOST /workflows/:id/execute
that:workflow:execute
scopeWorkflowExecutionService.executeManually()
workflow-pre-execute
event for tracking/hooksWhy This Matters:
Before this PR, users had to either:
/rest/workflows/run
(discouraged)After this PR, users can simply execute any workflow by ID:
Expected response:
Use Cases:
Related Linear tickets, Github issues, and Community forum posts
Closes #14002 - API call errors with workflow execution endpoint (reported 404 errors)
Community Forum Discussions:
These discussions show users have been requesting this functionality for years, with the official recommendation being to use webhooks as a workaround.
Review / Merge checklist
Notes for Reviewers:
Note
Introduces a public API endpoint to execute a workflow by ID and grants API keys the
workflow:execute
scope.POST /workflows/{id}/execute
inworkflows.handler.ts
usingWorkflowExecutionService.executeManually()
; validatesworkflow:execute
scope and project access; returns execution info; handles 400/401/404/500.openapi.yml
and spec filehandlers/workflows/spec/paths/workflows.id.execute.yml
documenting response shape.execute
to API keyworkflow
resource in@n8n/permissions/constants.ee.ts
.Written by Cursor Bugbot for commit 56dd8d0. This will update automatically on new commits. Configure here.