How to get the Webhook URL from a dynamically created workflow using the n8n API?

Describe the problem/error/question

Hello everyone,

I’ve created a “factory” workflow that dynamically generates and activates new AI chat agent workflows using the n8n API node. The process works perfectly for creating and activating the new workflow.

However, my goal is to retrieve the final, public-facing Webhook URL of the When chat message received trigger from the newly created workflow. I need to return this URL in my API response so the external service knows where to send messages.

My issue is that after the Create a workflow and Activate a workflow nodes run, the webhookId (and the full URL) is not available in the output data. The field is empty. How can I reliably get the webhook URL after the new workflow is active?

What is the error message (if any)?

There is no explicit error message. The webhookId field is simply empty or null in the output of the final node.

Please share your workflow

Here is the JSON for the factory workflow that creates the agents:

Here is the workflow created and activated from the creation

Share the output returned by the last node

{
  "workflow": {
    "id": "t0gOgkoZ4SiylUm6",
    "name": "chat agent | name 001 long one",
    "active": true,
    "archived": false,
    "version": "800d0996-bd97-4a7d-aa98-315892193894",
    "webhookId": ""
  }
}

Information on your n8n setup

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

Hi @beltrd

You need to add the webhookId key to your workflow JSON, specifically to the “When chat message received” node

"webhookId": "your-webhook-path"

like this:

If you don’t add it, you won’t receive it in the response..

3 Likes

Thank you so much this worked!

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