I’m trying to create a workflow to create other workflows using the n8n API. When the nodes of the workflow that I want to create by the API doesn’t have expressions everything works fine, but when I add an expression to a node parameter it will [ERROR: invalid syntax]
I want to be able to use dynamic values so I need to use expressions. How do I add expressions within a workflow object?
You can use expressions when creating workflows via the n8n API, but they must be sent as plain strings inside the workflow JSON, correctly escaped. n8n only evaluates expressions after the workflow is saved and executed. Most “ERROR: invalid syntax” issues come from incorrect JSON escaping or mixing JavaScript syntax with JSON.
What characters need escaping & what to do when it does contain javascript code. The workflow works when I’m just exporting & importing but it doesn’t work when it’s created via API. I don’t want to go the export & import route since I can’t use dynamic values