Understanding n8n when executed by another workflow?
n8n when executed by another workflow can run using the built-in Execute Workflow node or by calling a webhook. The Execute Workflow node is the simplest option for workflows on the same instance. This guide shows Docker setup, examples, and a quick Node.js call.
What You Need
- Docker and docker-compose installed.
- An n8n Docker image (n8nio/n8n).
- Basic familiarity with the n8n editor.
- Node.js installed for optional HTTP call examples.
How n8n when executed by another workflow works
The parent workflow triggers the child workflow. Use the Execute Workflow node for same-instance calls. Use a webhook for cross-instance or external calls. Both pass JSON data between workflows.
Step 1: Run n8n in Docker
Start a simple n8n container with basic auth enabled. Create a docker-compose.yml file and run it.
version: '3'
services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=strongpassword
Run the stack:
docker-compose up -d
Step 2: Create the child workflow
In the n8n editor create a workflow that accepts input. Add a Webhook or simple Set node and save the workflow. Note the workflow ID from the URL or the workflow settings.
Example child workflow logic:
1. Webhook node to receive POST input.
2. Set node to transform data.
3. Return or store results.
Step 3: Use Execute Workflow node in the parent workflow
Create a parent workflow. Add nodes that prepare data. Add the Execute Workflow node. Configure it with the child workflow ID. Map input fields to the Execute Workflow node parameters.
Example numbered logic for the parent:
1. Trigger (Cron, Webhook, or other).
2. Prepare data with Set or Function node.
3. Execute Workflow node calls the child by ID and passes data.
Step 4: Alternative using webhook and HTTP calls
If you prefer HTTP calls, use the child webhook URL and call it with curl or Node.js. This works across instances or from external systems.
# Call webhook with curl
curl -X POST "http://localhost:5678/webhook/child-webhook-path" \
-H "Content-Type: application/json" \
-d '{"name":"Alice","id":42}'
Node.js example using fetch:
const fetch = require('node-fetch');
async function callWebhook(){
const res = await fetch('http://localhost:5678/webhook/child-webhook-path', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'Alice', id: 42 })
});
const data = await res.json();
console.log(data);
}
callWebhook();
Update
To update n8n pull the latest image and restart the container. Keep workflow data on a persistent volume. Example commands:
docker pull n8nio/n8n:latest
docker-compose down
docker-compose up -d
Security
Protect webhooks and execution endpoints. Use basic auth or an API key. Limit network access to the n8n UI and webhook paths. Use HTTPS and secrets for sensitive data.
Useful environment examples:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=strongpassword
- WEBHOOK_URL=http://your-domain.com
Also validate and sanitize incoming data in the child workflow before using it.
Done
You now know how to run n8n when executed by another workflow. Use the Execute Workflow node for same-instance calls or webhooks for external calls. Test and secure your endpoints before production.