### List Event Types Response Example Source: https://developer.calendly.com/api-docs/xw6pnig9z79mo-scheduling-link-examples An example of a truncated response from the GET /event_types API call, showing the structure of event type data. ```json { "collection": [ { "...": "...", "uri": "http://api.calendly.com/event_types/88323028-5ef5-448b-9776-bc0c71b062a4", "name": "15 Minute Meeting", "scheduling_url": "https://calendly/com/acmesales", "pooling_type": "round_robin", "...": "..." } ] } ``` -------------------------------- ### Use ngrok for Local Development Source: https://developer.calendly.com/api-docs/adf83e8f05e54-webhook-examples Use ngrok to tunnel connections for local development. After starting ngrok, update the `webhook_url` in the receiver example. ```bash $ ngrok http 4567 ``` -------------------------------- ### User Resource Details Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions Example of the JSON response when retrieving user details using their URI. ```json { "resource": { "avatar_url": null, "created_at": "2020-04-20T20:44:29.052644Z", "email": "john.doe@fakeaddress.com", "name": "John Doe", "scheduling_url": "https://www.calendly.com/john-doe", "slug": "john-doe", "timezone": "America/New_York", "updated_at": "2020-09-08T19:11:15.831274Z", "uri": "https://api.calendly.com/users/ABC123XYZ789" } } ``` -------------------------------- ### List Event Type Available Times Response Example Source: https://developer.calendly.com/api-docs/xw6pnig9z79mo-scheduling-link-examples An example of a truncated response from the GET /event_type_available_times API call, showing the structure of available time data. ```json { "collection": [ { "...": "...", "status": "available", "start_time": "2024-02-16T24:00:00.000000Z", "...": "..." } ] } ``` -------------------------------- ### Event Types Request Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions Example of a GET request to retrieve event types. The response is deterministic and based solely on the request parameters, not the user's role. ```http // GET /event_types?user= { collection: [ { "uri": "https://api.calendly.com/event_types/A", ... }, { "uri": "https://api.calendly.com/event_types/B", ... }, { "uri": "https://api.calendly.com/event_types/C", ... } ], ... } ``` -------------------------------- ### Pre-fill User Info and Custom Answers Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Example of pre-populating John Doe's contact information and answers to invitee questions. ```javascript ``` -------------------------------- ### Calendly Event Payload Example Source: https://developer.calendly.com/api-docs/2d6c9df9b89de-notifying-the-parent-window This is an example of the message payload structure for Calendly events posted to the parent window. ```json { event: "calendly.profile_page_viewed", payload: {} } ``` -------------------------------- ### Filter Organization Memberships by User URI Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions When calling `GET /organization_memberships`, pass the URI of a user to filter results by that user. ```http GET /organization_memberships?user=https://api.calendly.com/users/ABC123XYZ789 ``` -------------------------------- ### Retrieve Available Times for an Event Type Source: https://developer.calendly.com/api-docs/xw6pnig9z79mo-scheduling-link-examples Fetches available time slots for a given event type within a specified date range. Requires the event type URI, start time, and end time. The time range cannot exceed 7 days. ```ruby require 'faraday' require 'uri' params = { :event_type => event_type_uri, # Chosen from previous API response :start_time => '2024-02-16T24:00:00.000000Z', :end_time => '2024-02-20T24:00:00.000000Z' } headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{token}" } res = Faraday.get( 'http://api.calendly.com/event_type_available_times', params, headers ) ``` -------------------------------- ### Retrieve Event Types Source: https://developer.calendly.com/api-docs/xw6pnig9z79mo-scheduling-link-examples Fetches a collection of event types for a user. Use this to get scheduling URLs and pooling types. Requires an OAuth token and user UUID. ```ruby require 'faraday' require 'uri' token = '' user = "https://api.calendly.com/users/" params = { user: user } headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{token}" } res = Faraday.get( 'https://api.calendly.com/event_types', params, headers ) if res.status == 200 event_types = JSON.parse(res.body)['collection'] scheduling_uri = event_types[0]['scheduling_uri'] pooling_type = event_types[0]['pooling_type'] end ``` -------------------------------- ### Event Type Response with Owner URI Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions When calling `GET /event_types`, the `owner` attribute in the response contains a URI referencing the owner resource. ```json { "collection": [ { "profile": { "name": "John Doe", "owner": "https://api.calendly.com/users/ABC123XYZ789", "type": "User" }, ... } ], ... } ``` -------------------------------- ### HTTP 429 Too Many Requests Response Source: https://developer.calendly.com/api-docs/edca8074633f8-api-rate-limits When you exceed your allowed rate limit, the Calendly API will respond with a 429 status code. This snippet shows an example of such a response, including relevant rate limit headers. ```http HTTP/2 429 Too Many Requests Date: Wed, 10 Jan 2024 12:00:00 GMT Content-Type: application/json X-RateLimit-Limit: {your limit} X-RateLimit-Remaining: 0 X-RateLimit-Reset: 60 ``` -------------------------------- ### Create a Webhook Subscription Source: https://developer.calendly.com/api-docs/adf83e8f05e54-webhook-examples Subscribe to `invitee.created` and `invitee.canceled` events. Replace placeholders with your account's specific values. ```ruby require 'faraday' require 'json' token = '' org = 'https://api.calendly.com/organizations/' user = 'https://api.calendly.com/users/' webhook_url = '' base_url = 'https://api.calendly.com' conn = Faraday.new( url: base_url, headers: { 'Content-Type' => 'application/json', 'Authorization' => 'Bearer #{token}' } ) response = conn.post '/webhook_subscriptions' do |req| req.body = { url: webhook_url, events: ['invitee.created', 'invitee.canceled'], organization: org, user: user, scope: 'user', }.to_json end ``` -------------------------------- ### Pre-fill User Information Structure Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Defines the structure for pre-filling user name and email in the booking form. ```javascript "prefill": { "name": "email": "customAnswers": } ``` -------------------------------- ### Retrieve User Details by URI Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions To access more data for an owner, make a request to the URI provided in the `owner` attribute of a response. ```http GET /users/ABC123XYZ789 ``` -------------------------------- ### Auto-Load Inline Widget with Prefill/UTM Source: https://developer.calendly.com/api-docs/6a743888e5649-getting-started-with-embeds Configure an inline Calendly widget to auto-load while pre-filling questions or setting UTM parameters. This method uses HTML attributes and a JavaScript initialization. ```html
``` -------------------------------- ### Authentication Source: https://developer.calendly.com/api-docs/d7755e2f9e5fe-calendly-api Authenticate your API requests using Bearer Auth with personal access tokens or OAuth 2.0. Personal access tokens should be included in the `Authorization` header. ```APIDOC ## Security ### Bearer Auth Put the access token in the `Authorization: Bearer ` header Provide your bearer token in the Authorization header when making requests to protected resources. Example: `Authorization: Bearer 123` ### OAuth 2.0 Additional Information about OAuth 2.0 authentication can be found in the Getting Started guide. ``` -------------------------------- ### Map UTM Parameters in Embed Code Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Manually set UTM parameters within the embed code to track sources. These will overwrite parameters from the parent window. ```javascript Calendly.initInlineWidget({ "url": 'https://calendly.com/YOUR_LINK/30min', "utm": { "utmCampaign": "Spring Sale 2019", "utmSource": "Facebook", "utmMedium": "Ad", "utmContent": "Shoe and Shirts", "utmTerm": "Spring" } }); ``` -------------------------------- ### Pre-fill Custom Answers Structure Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Defines the structure for pre-filling answers to custom invitee questions. ```javascript "prefill": { "customAnswers": { "a1": "a2": "a3": } } ``` -------------------------------- ### Admin Role: Organization Webhooks Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions An admin user can successfully request organization webhooks. This demonstrates permission-based access. ```http // Current User Role: "admin" // GET /webhook_subscriptions?scope=organization&organization= Status: 200 OK ``` -------------------------------- ### Calendly Link Widget Resources Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Include these CSS and Javascript resources to enable a Calendly pop-up scheduler without visible clickable text. These are necessary for the custom button functionality. ```html ``` -------------------------------- ### Paginated Response with No More Pages Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions If there are no more resources to retrieve, the `next_page` attribute within the `pagination` object will be `null`. ```json { collection: [...], pagination: { "count": 10, "next_page": null } } ``` -------------------------------- ### Permission-Based Access Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions While responses are deterministic, access to data is controlled by user roles and permissions. Different roles may have varying levels of access to resources. ```APIDOC ## GET /webhook_subscriptions ### Description Retrieves webhook subscriptions. Access to this endpoint and the data returned is dependent on the requester's role and permissions. ### Method GET ### Endpoint /webhook_subscriptions ### Parameters #### Query Parameters - **scope** (string) - Required - The scope of the webhook subscriptions to retrieve (e.g., 'organization'). - **organization** (string) - Required - The organization identifier for which to retrieve webhook subscriptions. ### Request Example ```json { "example": "// Current User Role: \"admin\"\n// GET /webhook_subscriptions?scope=organization&organization=" } ``` ### Response #### Success Response (200) - Returns webhook subscription details if the user has the necessary permissions. #### Error Response (403) - **Permission Denied** - Returned if the user does not have the required permissions to access the requested resource. ``` -------------------------------- ### Paginated Response with Next Page Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions When a collection has more resources, the `pagination` object includes a `next_page` URL for retrieving the subsequent set of resources. ```json { collection: [...], pagination: { "count": 20, "next_page": "https://api.calendly.com/scheduled_events?count=5&page_token=nODUpzeh8eNPGLrNaBoMK1HijZiO6H1t&user=https%3A%2F%2Fapi.calendly.com%2Fusers%2FAFEHBEDFE6WUE2R7" } } ``` -------------------------------- ### Initialize Inline Calendly Widget Source: https://developer.calendly.com/api-docs/6a743888e5649-getting-started-with-embeds Use the Calendly JavaScript API to create an inline embed on demand. This allows for delayed appearance or pre-filling of the booking form. ```javascript Calendly.initInlineWidget({ "url": 'https://calendly.com/YOURLINK', "parentElement": document.getElementById('SAMPLEdivID'), "prefill": {}, "utm": {} }); ``` -------------------------------- ### Receive and Filter Webhook Events Source: https://developer.calendly.com/api-docs/adf83e8f05e54-webhook-examples This Sinatra application receives webhook events from Calendly and filters them by a specific event type. Save this as `webhook_receiver.rb` and run with `ruby webhook_receiver.rb`. ```ruby require 'sinatra' EVENT_TYPE_FILTER = 'https://api.calendly.com/event_types/' post '/webhook' do request.body.rewind payload = JSON.parse(request.body.read) event_type = payload['scheduled_event']['event_type'] if event_type == EVENT_TYPE_FILTER puts '--Received webhook event from Calendly--' pp payload else puts '--Skipping webhook event--' end status :ok end ``` -------------------------------- ### User Role: Organization Webhooks Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions A user role may not have permission to access organization webhooks, resulting in a permission denied error. This highlights role-based access control. ```http // Current User Role: "user" // GET /webhook_subscriptions?scope=organization&organization= Status: 403 Permission Denied ``` -------------------------------- ### API Base URL Source: https://developer.calendly.com/api-docs/d7755e2f9e5fe-calendly-api The base URL for making requests to the Calendly API. Use the Live Server URL for production environments and the Mock Server URL for testing. ```APIDOC ## API Base URL Live Server: `https://api.calendly.com` Mock Server: `https://stoplight.io/mocks/calendly/api-docs/395` ``` -------------------------------- ### Verify Webhook Signature in Ruby Source: https://developer.calendly.com/api-docs/4c305798a61d3-webhook-signatures This Ruby code snippet demonstrates how to verify an incoming Calendly webhook signature. It extracts the timestamp and signature from the header, constructs the signed payload, and compares the computed HMAC signature against the provided signature. Ensure your webhook signing key is set as an environment variable. ```Ruby require 'OpenSSL' # Your application's webhook signing key webhook_signing_key = ENV['WEBHOOK_SIGNING_KEY'] # Extract the timestamp and signature from the header calendly_signature = request.headers['Calendly-Webhook-Signature'] signature_hash = Hash[*calendly_signature.split(/[,\=]/)] t = signature_hash['t'] # UNIX timestamp signature = signature_hash['v1'] raise 'Invalid Signature' if t.nil? || signature.nil? # Create the signed payload by concatenating the timestamp (t), the character '.', and the request body's JSON payload. signed_payload = t + '.' + request.body.read digest = OpenSSL::Digest::SHA256.new hmac = OpenSSL::HMAC.new(webhook_signing_key, digest) # Determine the expected signature by computing an HMAC with the SHA256 hash function. expected_signature = (hmac << signed_payload).to_s if expected_signature != signature # Signature is invalid! raise 'Invalid Signature' end ### Prevent replay attacks ### ``` -------------------------------- ### Add Dynamic Query String for UTM Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Embed a Calendly URL with a dynamic query string to capture UTM parameters from the parent site's URL. ```html
``` -------------------------------- ### Deterministic Responses Source: https://developer.calendly.com/api-docs/ZG9jOjE1MDE3NzI-api-conventions The API ensures responses are based solely on the request made, not on the requester's role or permissions. This means users must be explicit about the data they are requesting. ```APIDOC ## GET /event_types ### Description Retrieves a list of event types. The response is deterministic and based solely on the request parameters, not the requester's role. ### Method GET ### Endpoint /event_types ### Parameters #### Query Parameters - **user** (string) - Required - The user identifier for whom to retrieve event types. This parameter ensures the response is specific to the requested user. ### Request Example ```json { "example": "// GET /event_types?user=" } ``` ### Response #### Success Response (200) - **collection** (array) - A list of event types. - **uri** (string) - The URI of the event type. ``` -------------------------------- ### Make Mobile Schedule Fullscreen Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Ensure the Calendly widget appears full screen on mobile devices by adding this meta tag to your page's source code. This improves the mobile viewing experience. ```html ``` -------------------------------- ### Hardcode UTM Parameter in Embed Code Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Hardcode a specific UTM parameter directly into the embed code for distinct page views based on click source. ```html
``` -------------------------------- ### Filter Event Types by Name Source: https://developer.calendly.com/api-docs/xw6pnig9z79mo-scheduling-link-examples Filters the collection of event types to find a specific event by its name. ```ruby event_types = JSON.parse(res.body)['collection'] event_types.find { |obj| obj['name'] == 'my_event_name' } ``` -------------------------------- ### Listen to Calendly Events in JavaScript Source: https://developer.calendly.com/api-docs/2d6c9df9b89de-notifying-the-parent-window This JavaScript code snippet demonstrates how to listen for messages from an embedded Calendly page and log specific Calendly events to the console. Ensure the `isCalendlyEvent` function is defined to filter messages. ```javascript function isCalendlyEvent(e) { return e.data.event && e.data.event.indexOf('calendly') === 0; }; window.addEventListener( 'message', function(e) { if (isCalendlyEvent(e)) { console.log(e.data); } } ); ``` -------------------------------- ### Hide Event Details on Profile/Team Page Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Use this URL parameter to hide event details like account picture, name, or location when embedding a profile or team page link. ```text ?hide_landing_page_details=1 ``` -------------------------------- ### Trigger Pop-up Scheduler with Button Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Add this Javascript code to an HTML element to trigger the Calendly pop-up scheduler when the element is clicked. Replace 'YOUR_SCHEDULING_LINK' with your actual Calendly URL. ```javascript onclick="Calendly.initPopupWidget({url:'YOUR_SCHEDULING_LINK'});return false;" ``` -------------------------------- ### Filter Event Types by Pooling Type Source: https://developer.calendly.com/api-docs/xw6pnig9z79mo-scheduling-link-examples Filters the collection of event types to return only those matching a specified pooling type. Supported types are 'round_robin' and 'collective'. ```ruby event_types = JSON.parse(res.body)['collection'] event_types.find { |obj| obj['pooling_type'] == 'round_robin' } ``` -------------------------------- ### Include Calendly Widget Script Source: https://developer.calendly.com/api-docs/6a743888e5649-getting-started-with-embeds Include the Calendly external widget JavaScript file on your site. This script is required for all embed functionalities. ```html ``` -------------------------------- ### Validate Webhook Timestamp Tolerance Source: https://developer.calendly.com/api-docs/4c305798a61d3-webhook-signatures This Ruby code snippet checks if a webhook's timestamp is within a defined tolerance (3 minutes) to prevent replay attacks. If the timestamp is older than the tolerance, it raises an error. ```ruby three_minutes = 180 tolerance = three_minutes if Time.at(t.to_i) < Time.now - tolerance # Signature is invalid! # The signature's timestamp is outside of the tolerance zone defined above. raise 'Invalid Signature. The signature\'s timestamp is outside of the tolerance zone.' end ``` -------------------------------- ### Hide Event Details on Event Type Page Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Use this URL parameter to hide event details when embedding an event type-specific link. This parameter removes redundant information from the event type page. ```text ?hide_event_type_details=1 ``` -------------------------------- ### Left Align Pop-up Widget Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Align the Calendly pop-up widget to the left side of the webpage by adding this CSS code. Adjust the 'left' value for desired spacing. ```css ``` -------------------------------- ### Center Align Pop-up Widget Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Center the Calendly pop-up widget on your webpage using this CSS code. The 'margin-left' value is calculated to center the widget. ```css ``` -------------------------------- ### Set Inline Widget Height Source: https://developer.calendly.com/api-docs/19a0a0497b436-embed-recipes Adjust the height of the Calendly inline widget to prevent scroll bars. Modify the 'height' style attribute in this code snippet to control the widget's dimensions. ```html
``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.