Error creating netlify webhooks


I’m trying to use the netlify API to create a webhook and I’m running up against a wall. The following curl request returns an error and I can’t decipher what it means or how to fix it:

curl -X POST -d '{"hook":{"event":"deploy_building", "url": "","type":"slack"}}'\?site_id=REDACTED -H "Authorization: Bearer REDACTED"

The error I receive is:

{"url":["is not a valid URL"]}. I get this error regardless of what I put in the body of the request (including an empty request) and I don’t know how to get Netlify to accept my POST.

Any help would be greatly appreciated! Thanks.

Hi, @jt.white. My best recommendation would be to make these hooks in the web UI and then look at the browser devtools to see how the data is formatted. When I see this, I see this format:

    "site_id": "5092fde1-c045-4222-86f3-bef6d75b1575",
    "event": "deploy_building",
    "type": "url",
    "data": {
        "url": ""
    "form_id": null

In your example, the data is quite different:

    "hook": {
        "event": "deploy_building",
        "url": "",
        "type": "slack"

Also, please note, for a HTTP or HTTPS URL to be a URL it must have at least a path of /.

This is a URL:
This is not a URL:

The second example has no path so it isn’t a valid URL.

The HTTP specification always requires a least a path of /. It is not optional. Browsers won’t always show it but it is always there. (Browsers often hide or otherwise distort the reality of what they do. For example, Chrome now hides the www before apex domains regardless of if it is there or not.)

​Please let us know if there are other questions about this.

Hi Luke!

Thanks for your quick response. My problem was indeed that my payload was shaped incorrectly - using the proposed shape does make it through the API. I actually had a second issue where my CuRL request didn’t have a “Content-Type: application/json” header, which explained why I would get an error regardless of payload.

As a small FYI, in case you encounter this issue with someone else - it looks like the “url” part of the “data” object doesn’t get validated at all. I can send through something like “this is not a url” and the API will accept it.



1 Like

Thanks for sharing, @jt.white. Glad it is working now :netliconfetti: