Run n8n on MIOSA
~15 min TypeScript PythonWhat you’re building: Self-host the workflow platform and run its AI agents.
Primitives you’ll use: Sandbox, Postgres, Redis
Agent prompt
Start with your coding agent
Choose how you will use it. The brief installs and runs the real tool on MIOSA, then shapes it for your team or your customers. Copy it into OSA, Claude Code, Codex, or Cursor.
Template coming soon1 What are you building?
Leave it empty and your agent will propose 3 names, pick one, and use it for resources, the domain and branding.
3 Configure
Reference tool
n8n, by n8n GmbH (https://n8n.io): a source-available workflow-automation platform with a native AI agent node and standalone agents.
How it works: You build a workflow visually (or in code) from triggers and nodes; the AI Agent node reasons over tools, memory and a knowledge base, and standalone agents run with sub-agents, channels and schedules.
Key capabilities:
Visual workflows that can drop into code
An AI Agent node with tools, memory and knowledge
Standalone agents with sub-agents and schedules
Human-approval steps and per-run history
You will install and RUN the real n8n (source-available (Sustainable Use License); you self-host it). Read its docs first: https://docs.n8n.io/hosting/installation/npm/. Every install command below comes from them; if the docs and this brief disagree, the docs win.
How it runs on MIOSA
Where it runs -> a MIOSA sandbox (an isolated Linux workspace)
State and files -> Workflows, credentials and execution history live in the n8n database; point n8n at managed Postgres so they survive a pause.
Model -> your own provider key, never a MIOSA platform key
Its web port 5678 -> a MIOSA preview URL (`miosa preview create`)
Your customers -> one workspace each, isolated from each other
Goal
Install and run n8n on a MIOSA sandbox, so it can serve my customers. Each customer is isolated in its own workspace; I meter usage and bill them.
Product name: propose 3 product names, pick one, and use it for resource names, the domain and branding. Until you pick, <product-name> stands for it in the commands below.
Scale: a prototype.
Set up
npm i -g @miosa/cli
miosa login && miosa whoami
miosa api-key create <product-name>-key --preset agent
export MIOSA_API_KEY="msk_u_..."
miosa org
Resources
Sandbox: the agent's isolated Linux workspace
miosa create <product-name>-box --wait
Managed Postgres
miosa api POST /databases -d '{"name":"<product-name>-db","engine":"postgresql"}'
Managed Redis (cache and sessions)
miosa api POST /databases -d '{"name":"<product-name>-cache","engine":"redis"}'
Auth and tenancy
Your organization is the platform; customers never get a MIOSA account, they sign into YOUR product. One workspace per customer, created as they onboard, isolates their machines, runs and data.
miosa workspace create <product-name>-customer-1
Tag every machine and run with the customer id in `metadata`, and never query across customers. Meter usage per customer with GET /api/v1/usage and set who pays with PUT /api/v1/bill-to (/docs/platform/usage-and-billing).
Install n8n
Run these inside the sandbox (for example `miosa exec <product-name>-box -- bash -lc '<command>'`), in order. The commands are from the official docs.
node --version # Node.js 20.19 or later (22.12+ is best) is required
npm install -g n8n
Check: the install finishes without errors; the next sections configure and start it.
Configure
Set your own model provider key in the n8n UI (Credentials) for the AI Agent node; MIOSA platform keys are never used.
Queue mode needs Redis and Postgres: create them in the workspace, then set DB_TYPE=postgresdb, DB_POSTGRESDB_* and QUEUE_BULL_REDIS_* before you start.
Model: Anthropic (Claude). Calls use my own provider key (ANTHROPIC_API_KEY); MIOSA platform keys are never used.
export ANTHROPIC_API_KEY="..." # set it in the process environment, or the Secrets API; never write it into files you commit
Run it
Start it and prove it works.
n8n start
Scripted, non-interactive use (what a product or a queue would call):
n8n execute --file workflow.json # run one workflow without the editor
Check: a headless task completes and prints a result.
Persistence and access
Workflows, credentials and execution history live in the n8n database; point n8n at managed Postgres so they survive a pause.
It listens on port 5678. Run it as a background process so it outlives your shell, then open a preview:
miosa preview create <product-name>-box 5678 --name web
Check: the preview URL answers, and still answers after the machine pauses and resumes (previews wake it on request).
Make it a product
Run one n8n per customer workspace, keyed to that customer's Redis and Postgres, behind your own login; meter executions per customer.
Limits and costs
Pin the version you tested and update deliberately; these tools change quickly.
Give the tool only the credentials it needs, as secrets, not baked into files.
Prototype: keep it to one machine at the default size, skip replicas and custom hostnames you do not need, and delete everything when you are done.
Acceptance checks
n8n runs on a MIOSA sandbox and answers a real task.
State survives a pause and resume.
Each customer has its own workspace and its own instance; nothing is shared between them.
Everything it created can be deleted with nothing left running.
What your choices added
- Build a product. a workspace per customer, per-customer metering and bill-to
- Agent suggests a name. proposes 3 product names and picks one; commands use <product-name>
- Model: Anthropic. your own provider key
- Prototype. one small machine, no extras, easy to delete
- Postgres. already part of this guide
What you're building
a source-available workflow-automation platform with a native AI agent node and standalone agents Modelled on n8n, by n8n GmbH.
You build a workflow visually (or in code) from triggers and nodes; the AI Agent node reasons over tools, memory and a knowledge base, and standalone agents run with sub-agents, channels and schedules.
Primitives you'll use: Sandbox · Postgres · Redis
- Visual workflows that can drop into code
- An AI Agent node with tools, memory and knowledge
- Standalone agents with sub-agents and schedules
- Human-approval steps and per-run history
You install and run the real n8n on MIOSA. Read the official docs first: docs.n8n.io/hosting/installation/npm/. Every install command below comes from them; if the docs and this guide disagree, the docs win. n8n is source-available (Sustainable Use License); you self-host it.
What you need on MIOSA
Each row is one thing to create before you start. The number matches the step that uses it.
- Organization and API key Scopes every call; a workspace key is all a worker needs.
miosa api-key create app-key --preset agentDocs - Sandbox The isolated Linux workspace the agent writes code and runs commands in.
miosa create app-box --template nextjs --waitDocs - Postgres Managed relational data, injected as DATABASE_URL in the machine and in production.
miosa api POST /databases -d '{"name":"app-db","engine":"postgresql"}'Docs - Redis Managed cache and session store, injected as REDIS_URL.
miosa api POST /databases -d '{"name":"app-cache","engine":"redis"}'Docs - A workspace per customer Isolates each customer’s machines, deployments, and data as they onboard.
miosa workspace create customer-1Docs - Branding and white-label Your name and slug on previews, deployments, and the desktop; customers never see MIOSA.
miosa orgDocs - Usage metering and bill-to Usage per customer, and which account pays for new machines.
miosa org billDocs
Architecture
How it runs on MIOSA
Where it runs -> a MIOSA sandbox (an isolated Linux workspace)
State and files -> Workflows, credentials and execution history live in the n8n database; point n8n at managed Postgres so they survive a pause.
Model -> your own provider key, never a MIOSA platform key
Its web port 5678 -> a MIOSA preview URL (`miosa preview create`)
Your customers -> one workspace each, isolated from each other
Auth and tenancy
Your organization is the platform; customers never get a MIOSA account, they sign into YOUR product. One workspace per customer, created as they onboard, isolates their machines, runs and data.
miosa workspace create n8n-customer-1Tag every machine and run with the customer id in `metadata`, and never query across customers. Meter usage per customer with GET /api/v1/usage and set who pays with PUT /api/v1/bill-to (/docs/platform/usage-and-billing).
Install n8n
Run these inside the sandbox (for example `miosa exec n8n-box -- bash -lc '<command>'`), in order. The commands are from the official docs.
node --version # Node.js 20.19 or later (22.12+ is best) is requirednpm install -g n8nCheck: the install finishes without errors; the next sections configure and start it.
Configure
Set your own model provider key in the n8n UI (Credentials) for the AI Agent node; MIOSA platform keys are never used.
Queue mode needs Redis and Postgres: create them in the workspace, then set DB_TYPE=postgresdb, DB_POSTGRESDB_* and QUEUE_BULL_REDIS_* before you start.
Model: Anthropic (Claude). Calls use my own provider key (ANTHROPIC_API_KEY); MIOSA platform keys are never used.
export ANTHROPIC_API_KEY="..." # set it in the process environment, or the Secrets API; never write it into files you commitRun it
Start it and prove it works.
n8n startScripted, non-interactive use (what a product or a queue would call):
n8n execute --file workflow.json # run one workflow without the editorCheck: a headless task completes and prints a result.
Persistence and access
Workflows, credentials and execution history live in the n8n database; point n8n at managed Postgres so they survive a pause.
It listens on port 5678. Run it as a background process so it outlives your shell, then open a preview:
miosa preview create n8n-box 5678 --name webCheck: the preview URL answers, and still answers after the machine pauses and resumes (previews wake it on request).
Make it a product
Run one n8n per customer workspace, keyed to that customer's Redis and Postgres, behind your own login; meter executions per customer.
Limits and costs
Pin the version you tested and update deliberately; these tools change quickly.
Give the tool only the credentials it needs, as secrets, not baked into files.
Prototype: keep it to one machine at the default size, skip replicas and custom hostnames you do not need, and delete everything when you are done.
Acceptance checks
n8n runs on a MIOSA sandbox and answers a real task.
State survives a pause and resume.
Each customer has its own workspace and its own instance; nothing is shared between them.
Everything it created can be deleted with nothing left running.