Hi Rayma,
[TLDR; The current API will only get you part of the way]
I had a quick look at what you’re trying to accomplish with this integration. As I understand it, there are two (possibly more, depending on how much of that process you want to be able to do on behalf of your user) manual steps that need to be done currently:
- Add Javascript to Script Manager
- Create the web hook integration
On the first one (Javascript), we don’t currently have any API endpoints that allow you to do that - so that would still be something your user would have to do manually.
On the second one (creating that web hook), we do have an endpoint that you can send a POST
to to create web hooks on - it’s sort of in beta at the moment, which is why it’s not documented:
To create a web hook via API:
HTTP POST
to /pages/:page_id/integrations
…with a payload that looks like:
{
"type" : "webhook",
"config" : {
"url" : "https://your.url.com"
}
}
So, for example - using cURL (w/basic auth):
curl -u <api-key>: -X POST https://api.unbounce.com/pages/<page-id>/integrations -H "Content-Type:application/json" -d '{ "type" : "webhook", "config" : { "url" : "http://your.url.com" } }'
If the call is successful, you’ll get a 201 Created
response , and the Location
header will contain the URI of the newly created integration. For example:
Location: https://api.unbounce.com/pages/17be17c9-f444-4b8d-b7ef-b6f5667c5e15/integrations/41c6b1d6-c091-42ac-8503-e0e93381282b
You’ll want to hold onto that URI if you want to perform other operations on that resource.
The /pages/:page_id/integrations/:integration_id
resource also supports:
A GET
on /pages/:page_id/integrations
resource will list all the integrations for a given page.
Hi there! It would be nice to have such important info about webhooks in the documentation)