Cloing workflows via N8N API - getting error 400

Hi there,
love your product!

I ended up with a use-case where we need to clone a workflow for each new client we bring on.

The scenario:

  • New client signs up, provides their calendly Personal Access Token
  • Each meeting set up on their calendly gets reported to us and stored in our db
  • Thus, I need a new calendly trigger with a new credential on each client signup = more workflows

Happy to hear if you think my thinking above is invalid and we can save on the number of workflows somehow.

But in case the above seems like a good way forward, I’d like help in understanding what is going wrong when creating this workflow via the API.

I have from a Set node inserted the expressions, as strings, supposed to be processed at runtime of the workflow. I’m not getting any JSON formatting issues but rather a error code 400.

Does it have to do with webhooks needing unique IDs?

I wish there were more documentation on this part of N8N. Thanks for spending time on this

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

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hey @revhuntr,

It is likely down to the data you are sending, When creating a workflow with the API we expect 5 fields

name (required)
nodes (required)
connections (required)
settings (required)
staticData (optional)

In the settings there are only 7 options that can be used which are…

saveExectionProgress
saveManualExecutions
saveDataErrorExecution
saveDataSuccessExecution
executionTimeout
errorWorkflow
timezone

Looking at what you are sending you have some settings and other options that we are not expecting and that is causing the issue. If you update your json data to include only what we are after you should be all good.

The information on this can be found here: API reference | n8n Docs

Hi Jon,
you were right, unsurprisingly. Thanks for the swift response.

For anyone else seeing this, this was my approach:

  • I downloaded the workflow I wanted to create via API
  • asked chatgpt to list and escape all expressions
  • set up the expressions in a Set node, set to text, not expression
  • added nodes and properties one by one so as to know exactly what was causing the status 400

took me a few hours but now this works great!

1 Like