{
  "nodes": [
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "action",
              "type": "any"
            },
            {
              "name": "workflowId"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -640,
        220
      ],
      "id": "b437afb7-5435-4ce9-8128-cd642bf0beb3",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {},
      "id": "89035b0d-afda-40b6-ad8f-c26503b8bb40",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [
        260,
        420
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "action",
              "value": "={{ $json.action }}"
            },
            {
              "name": "workflowId",
              "value": "={{ $json.workflowId }}"
            }
          ]
        },
        "options": {}
      },
      "id": "efe06994-dc14-42fb-ba50-2273fbec5062",
      "name": "Extract Action1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -340,
        220
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.action }}",
              "value2": "list"
            }
          ]
        }
      },
      "id": "73000c3a-defe-4fa6-80fe-5f0c52e592eb",
      "name": "IF List1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        -140,
        120
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.action }}",
              "value2": "get"
            }
          ]
        }
      },
      "id": "51f13950-c9bd-4880-a1eb-65b22f8080aa",
      "name": "IF Get1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        -140,
        320
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.action }}",
              "value2": "create"
            }
          ]
        }
      },
      "id": "8a524e96-15e6-47fe-9b21-b258eb323e67",
      "name": "IF Create1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        -140,
        520
      ]
    },
    {
      "parameters": {
        "url": "http://localhost:5678/api/v1/workflows",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "74023c57-93e1-4774-b71e-24b1a9d10685",
      "name": "List Workflows1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        60,
        20
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "=http://localhost:5678/api/v1/workflows/{{ $json.workflowId }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "504a3e25-366e-4adf-939f-373d3bb4efe9",
      "name": "Get Workflow1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        60,
        220
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:5678/api/v1/workflows",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($('When Executed by Another Workflow').item.json.workflow) }}",
        "options": {}
      },
      "id": "e001ab9a-53f1-4faf-8679-6ebcaabce097",
      "name": "Create Workflow1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        60,
        420
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.action }}",
              "value2": "update"
            }
          ]
        }
      },
      "id": "24a7ad61-4625-432c-9a01-3b21cbc029d4",
      "name": "IF Update1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        -140,
        720
      ]
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "=http://localhost:5678/api/v1/workflows/{{ $json.workflowId }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($('When Executed by Another Workflow').item.json.workflow) }}",
        "options": {}
      },
      "id": "91949af7-a557-45db-b51c-0083948eb29e",
      "name": "Update Workflow1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        60,
        620
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.action }}",
              "value2": "execute"
            }
          ]
        }
      },
      "id": "c3499260-3679-49a1-8b3a-39522e18589f",
      "name": "IF Execute1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        -140,
        920
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=http://localhost:5678/api/v1/workflows/{{ $json.workflowId }}/execute",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ data: $('When Executed by Another Workflow').item.json.data || {} }) }}",
        "options": {}
      },
      "id": "3eae8ac9-2536-40c8-890b-c5a1d843a77d",
      "name": "Execute Workflow1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        60,
        820
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Extract Action1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Action1": {
      "main": [
        [
          {
            "node": "IF List1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF List1": {
      "main": [
        [
          {
            "node": "List Workflows1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF Get1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Get1": {
      "main": [
        [
          {
            "node": "Get Workflow1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF Create1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Create1": {
      "main": [
        [
          {
            "node": "Create Workflow1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF Update1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Workflows1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Workflow1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Workflow1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Update1": {
      "main": [
        [
          {
            "node": "Update Workflow1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF Execute1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Workflow1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Execute1": {
      "main": [
        [
          {
            "node": "Execute Workflow1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}