Webhook path - Dynamic URL

Hi,

I’m working with a provider that sends webhook requests to my n8n webhook URL, but the final part of the path varies each time.

For example:

Base URL: https://n8n.server.com/webhook/provider/api

The provider sends requests like this:

https://n8n.server.com/webhook/provider/api/340e9195-eeed-4049-b7ed-d5ffa4f35f59

Where the last segment is a system-generated UUID.

How can I handle this dynamic URL structure in n8n?

Thank You!

Information on your n8n setup

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

Hey @ezz , you can use URL parameters. In your case your webhook URL would be something like https://n8n.server.com/webhook/provider/api/:uuid where :uuid is the parameter called uuid. That mean the incoming payload will include the following structure

"params": {
   "uuid": "340e9195-eeed-4049-b7ed-d5ffa4f35f59"
}

That is, the parameter :uuid can be replaced with any value in the call to your webhook.

@ihortom Thank You! I tried the use of ::uuid but then N8N adds workflowId back to my webhook. My Base URL is then:

https://n8n.server.com/webhook/548a8de5-a2e6-4707-bac0-cc2feeac4963/providerA/api/media/:uuid

I need to use the same base URL in two workflows.

Workflow A: https://n8n.server.com/webhook/providerA
Workflow B: https://n8n.server.com/webhook/providerA

for workflowA they are appending api/session/metadatamedia so my path is:

https://n8n.server.com/webhook/providerA/api/session/metadatamedia

For workflowB, it is api/media/{sessionID} so https://n8n.server.com/webhook/providerA/api/media/{sessionID}

Workflow A runs series of tasks and returns SessionID as the webhook response. When providerA gets the SessionID, it will then make an API call to https://n8n.server.com/webhook/providerA/api/media/{sessionID}

Can I handle this in N8N?

Hey @ezz , indeed I can see that once the parameter is added n8n inserts the webhook random UUID too. I think it might be a bug (or not). However, that UUID is constant once set, you simply have inconvinience of longer webhook URL. Otherwise you still should be able to go ahead with this implemantation but use longer URL.

@ihortom but that will create two different webhook. I basically want to utilize same Base URL for two different workflows in n8n,

I am guessing I cannot use regular expression in “Path”, correct? Basically, somehow telling N8N to accept any path after “/api/media” something like “/api/media/*”

Thanks!

You can have two webhooks on the very same workflow. This way you can have the common base URL.

In your case the base URL will include some UUID generated automatically by n8n. I checked and it is not a bug when you use parameters (UUID is inserted on purpose).

Assuming n8n assigned the UUID 7e6f47aa-0e93-48f6-93bd-536e9e2bef83, your base URL will be http://<N8N_INSTANCE>/webhook/7e6f47aa-0e93-48f6-93bd-536e9e2bef83/providerA/api/. Then the webhooks in the very same workflow (it has to be the same workflow) would be as shown below

1 Like

ahh… I didnt think of two webhooks in the same workflow. Thanks @ihortom

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