Hey team,
I’d like to create a new webhook using the v2 API to send updates about new Posts published on my campaign. I’ve already created a new App Integration and I’m able to send requests to the API.
However, the API isn’t fully documented, how to create a webhook.
curl -H 'Authorization: Bearer xxxx
’ -X POST -H ‘Content-Type: application/json’ --location https://www.patreon.com/api/oauth2/v2/webhooks -d ‘{“uri”: “https://xxxxx ”, “triggers”: [“posts:publish”, “posts:update”, “posts:delete”]", “paused”: “false”}’ | jq
Gets back a 400 response. I’ve tried multiple combinations of the fields documented, but without success.
Could you help me setting this up please?
You dont need to create a webhook programmatically. You can just use the webhooks page for that:
The problem is that it does not allow me to set the post triggers. On the website it does not show me the „post:…“ triggers only members etc.
How am I supposed to use them when they don’t show up in the UI and the API calls don’t work?
Yes, they may not be supported in the interface yet. You will need to create that hook programmatically. Check out how the WP plugin does it for posts trigger:
}
return false;
}
public function get_post( $post_id ) {
return $this->__get_json( 'posts/' . $post_id . '?fields[post]=title,content,is_paid,is_public,published_at,url,embed_data,embed_url,app_id,app_status' );
}
public function add_post_webhook( $params = array() ) {
// Contacts api to create or refresh client
// Only uses v2
if ( !isset( $params['campaign_id'] ) ) {
$params['campaign_id'] = get_option( 'patreon-campaign-id', false );
}
// Site url with forced https
1 Like
Awesome, that worked! Thank you
1 Like