You can use this snippet to create a new watcher (or webhook) using the Watcher API. Once the watcher is created, Agendize platform will notify the subscribed URL (your third-party system: CRM, ERP...) and send the JSON structure each time a specific event is triggered.
Here is an example to create an Appointment watcher (for each appointment booked):
<?php $apiKey = ""; $token = ""; $companyId = ""; //create a new cURL resource $ch = curl_init("https://app.agendize.com/api/2.1/scheduling/companies/$companyId/appointments/watch?apiKey=$apiKey&token=$token"); //setup request to send json via POST $data = array( 'address' => "https://webhook.site/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" // or: 'address' => "https://hooks.zapier.com/hooks/catch/yyyyyyy/xxxxxx/" ); $payload = json_encode($data); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); //set the content type to application/json curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); //execute the POST request $result = curl_exec($ch); //close cURL resource curl_close($ch); ?>
You can also apply templating to the JSON format to map the data to your own JSON properties. Here is an example: https://agendize.freshdesk.com/support/discussions/topics/4000345023
Connexion ou S'inscrire pour poster un commentaire