Cannot create a Webhook triggered automation programatically

I can’t import via CLI or API a workflow that is triggered by a webhook

TL;DR

I need to import a workflow that will be triggered only via a webhook.
The webhook returns 404 until I update the workflow on n8n UI.
Once I do that, it works properly.

But I need it to be programmatically.

Does anyone has a workaround about this ?

Original version:

I have pulled a bunch of my hair on this one.

I am in the exact same situation as @dingo-dev in his post trying to build a CI/CD pipeline and automating workflow creation.

I need to run integration tests from Github Actions (hence the need for zero UI intervention) that would call an automation via webhook and assert the result, before committing the workflow to the GitHub repository.

I tried:

  • Importing via CLI then activating via CLI
  • Importing via CLI then activating via API
  • Importing via CLI then activating I then deactivating then reactivating via API
  • Importing via CLI then making a PUT on the workflow via API
  • Importing via API , then activating via API

The webhook won’t work until I touch it via the UI

Does anybody know any workaround ?
Even if it is triggering a workflow programmatically with another way than webhook

Information on your n8n setup

  • n8n version: 1.84.3,
  • Database: PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 22.04 or Mac OS 15.4

I am exploring the execution via CLI using n8n execute --id <ID> as described in this part of the doocumentation but the execution of the following workflow seems stuck at the User settings loaded from: /home/node/.n8n/config

Here is the workflow (although it is a simple just to test the execution):

hello @RayBBM

Make sure the id of the webhook is unique (fields webhookId and path).

And can you share the workflow which you are trying to run via automation?

Yes so far it is the only workflow with a webhook:

Here it is, it is only to make it work before move on

I didn’t have any issues with programmatic webhook. Check that you have a proper webhookId field in the payload. I suppose it should be a valid GUID

1 Like

Thank you,

it turns out that the webhookId was the missing part in the workflow I wanted to import:

"name": "Webhook Workflow 1",
    "active": false,
    "nodes": [
      {
        "parameters": {
          "httpMethod": "POST",
          "path": "workflow",
          "responseMode": "lastNode",
          "responseData": "allEntries",
          "options": {}
        },
        "type": "n8n-nodes-base.webhook",
        "typeVersion": 1,
        "position": [
          250,
          300
        ],
        "id": "webhook-node",
        "webhookId": "56d7c763-8c1c-4037-bd3a-77abe8e930e2", // THIS WAS MISSING
        "name": "Webhook",
        "credentials": {
          "httpBasicAuth": {
            "user": "",
            "password": ""
          }
        }
      },
...
]
...}

Thank you

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.