There's very few post here regarding Calendly so hopefully somebody can help with this issue. Below is the code I'm using and the issue is that Calendly only returns the webhook subscription data, not the actually appointments that customers schedule.
I want to receive data as described on their page here: https://developer.calendly.com/docs/sample-webhook-data but I only get webhook subscription data back, not the scheduled appointments.
$url = 'https://calendly.com/api/v1/hooks';
$webhook_url = 'MY URL HERE';
$curl_data = 'url='.$webhook_url.'&events[]=invitee.created&events[]=invitee.canceled';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTFIELDS,$curl_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"X-TOKEN: MY TOKEN ID HERE"
));
$result = curl_exec($ch);
echo $result;
curl_close($ch);
//print_r(json_decode($result, true));<br><br>
$content = trim(file_get_contents("php://input"));<br>
$decoded = json_decode($content, true);<br><br>
echo $decoded;<br>
{"data":[{"type":"hooks","id":380871,"attributes":{"url":"MY URL HERE","created_at":"2019-04-17T11:07:36Z","events":["invitee.created","invitee.canceled"],"state":"active"}}]}
Once you set up your webhook, Calendly will send a POST request to your webhook URL. In other words, once an invitee books or cancels an invite, your webhook URL will receive the payload from Calendly for that specific event.
Webhooks
are a little different from API endpoints
. An API provides data at the time you send a request; e.g., "Give me a list of all of my users". Conversely, a webhook acts as a listener to some topic and is event-based; e.g., "Tell me when an invitee has booked a meeting (and tell me about the meeting).
Are you looking to get a list of all invitees/meetings? If so, we don't have an API endpoint for that now, but we'd love to hear what you're looking for and how we can help. You can reach out to us here (reference my name and I'll be able to sync up on your request).