How to create webhooks? I'm an API noob

Hello! I’m brand new to the API and I have been reading through the documentation trying to figure out how to create a new webhook. I’m currently using Postman to help test and format my API calls for learning purposes, but would like to know how to programmatically create new webhooks. I tried using the example post payload given on the API Docs:

{
  "data": {
    "type": "webhook",
    "attributes": {
      "triggers": ["members:create"],
      "uri": "https://www.mywebsite.com/patreonWebhookTest",
    },
    "relationships": {
      "campaign": {
        "data": {"type": "campaign", "id": "mycampaignid"},
      },
    },
  },
}

But every time I try this, the API returns a 400 Bad Request error, saying “The browser (or proxy) sent a request that this server could not understand.”
The URL I am posting to is https://patreon.com/api/oauth2/v2/webhooks, and I have my access token saved as a bearer token.

What am I doing wrong here? Would anyone be willing to give me an example of what I should be doing?

Here is an example webhook from the PHP lib:

And below branch of WP plugin has the upcoming post sync webhooks.

The webhook related function creates a webhook:

Routing function has WP site’s endpoints to receive, verify and process incoming webhook posts:

1 Like

Thanks so much for the reply!
At first I was very confused as the data seemed to match up to mine, then I realized my problem was that I wasn’t escaping the slashes in the uri. When trying it with php, it automatically escaped them and worked.

As a seperate note, I want to create webhooks for the all new ‘posts:publish’ trigger. It’s working great so far! But, is there any way to get the required tiers for a post by it’s post ID?

Unfortunately yet there isnt a way to get the tier of a post. Only that it is patron only. Tier info may be added to api in future.