Skip to main content

Overview

Create a new workflow in your n8n instance. Workflows are created in an inactive state by default. You must activate them separately using the update-partial endpoint.
Workflows require at least one trigger node to be executable. Common triggers include Webhook, Schedule, Manual Trigger, or integration-specific triggers.

Endpoint

POST /workflows

Request Body

name
string
required
Human-readable workflow name. Must be unique within your instance.Example: "Customer Onboarding Flow"
nodes
array
required
Array of workflow nodes. Each node represents a step in your automation.
connections
object
required
Workflow connections object. Keys are source node names (not IDs), values define output connections.Structure:
{
  "Source Node Name": {
    "main": [
      [
        {
          "node": "Target Node Name",
          "type": "main",
          "index": 0
        }
      ]
    ]
  }
}
settings
object
Workflow execution settings

Response

success
boolean
Operation success status
data
object
Created workflow information
message
string
Success message with workflow ID

Error Codes

VALIDATION_ERROR
string
Causes:
  • Missing required fields (name, nodes, connections)
  • Invalid node type format (use FULL form: n8n-nodes-base.*)
  • Duplicate node names
  • Invalid connection references
  • Missing workflow metadata
Resolution: Use validate_workflow tool before creating
API_ERROR
string
Causes:
  • n8n API not configured (missing N8N_API_URL or N8N_API_KEY)
  • Network connectivity issues
  • n8n instance unavailable
Resolution: Verify API credentials with n8n_health_check
DUPLICATE_NAME
string
Cause: Workflow name already existsResolution: Use a unique name or delete the existing workflow

Examples

{
  "name": "Simple Webhook Handler",
  "nodes": [
    {
      "id": "webhook-1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [250, 300],
      "parameters": {
        "path": "test-webhook",
        "httpMethod": "POST",
        "responseMode": "onReceived"
      }
    },
    {
      "id": "set-1",
      "name": "Process Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [450, 300],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "message",
              "value": "Data received successfully"
            }
          ]
        }
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Process Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Best Practices

Before Creating Workflows:
  1. Use search_nodes to find the right nodes for your use case
  2. Use get_node to get parameter schemas and examples
  3. Use validate_node to verify node configurations
  4. Use validate_workflow to check the complete workflow
Common Pitfalls:
  • Using SHORT form node types (nodes-base.*) instead of FULL form (n8n-nodes-base.*)
  • Referencing node IDs instead of names in connections
  • Missing typeVersion on nodes
  • Duplicate node names within a workflow
  • Invalid connection structure
Conceived by Romuald Członkowski - www.aiadvisors.pl/en

Build docs developers (and LLMs) love