REGISTER NOW: Supercharge Your Cloud Integrations and Register for our Webinar on 9/26

Kloudless Blog

Tutorials, case studies and how-tos from our experts

RSVP to an event with the Calendar API

Introduction

We are excited to announce that our Unified Calendar API now supports RSVP functionality. Most calendar services like Google Calendar and Outlook Calendar allow users to create an event on their calendar and add guests/attendees. Google and Microsoft will then send invitations via email for people to respond with whether they will attend or not. In this post, we will show you how to use our Unified Calendar API to:

  • Create a calendar event
  • Add guests/attendees
  • RSVP to a calendar event

Preparation

To demonstrate, we need to connect two Google Calendar accounts (Kloudless uses OAuth 2.0). The first account will create an event and invite the second account. 

  • event creator: Shirley <shirley@gmail.com>
  • event attendee: David <david@gmail.com>

Create a calendar event (and add guests)

We begin by making an API request to the Create Event endpoint. The Unified Calendar API allows you to combine creating an event and adding guests by just specifying the attendees in the request body. The attendees field represents a list of attendee objects, and each attendee object should include the name and email fields with values.

For example, Shirley plans to meet with David on 2019-02-07 from 14:00 to 15:00. The request body will look like the following:

The full cURL command and response:

We explain the variables in the cURL command below:

  • BEARER_TOKEN: Access token obtained when authenticating shirley@gmail.com
  • ACCOUNT_ID: Kloudless identifier of shirley@gmail.com. Since the BEARER_TOKEN is provided, you can also substitute me for the ACCOUNT_ID.
  • CALENDAR_ID: Kloudless identifier of the primary calendar associated with shirley@gmail.com.

Here is the response to the API request:

We simplified the response for readability. You can see the status field inside the attendee object, which represents the attendee’s response. The pending value indicates that the attendee has not responded yet.

RSVP to a calendar event

This event will now appear in the attendee’s primary calendar. If we want to RSVP to this event as the attendee, we can make an API request to update the attendee’s status for the event. The calendar service (e.g. Google or Microsoft) will sync the attendee’s response back to event creator’s calendar.

First, let’s make an API request to the List Events endpoint to retrieve the specific Event ID.

We explain the variables in the cURL command below:

  • BEARER_TOKEN: Access token obtained when authenticating david@gmail.com
  • ACCOUNT_ID: Kloudless identifier of david@gmail.com. Since the BEARER_TOKEN is provided, you can also substitute me for the ACCOUNT_ID.
  • CALENDAR_ID: Kloudless identifier of the primary calendar associated with david@gmail.com.

Then, we can make an API request to update the attendee’s status with the specific event ID retrieved from previous step. The request body to provide to the Update Event endpoint is similar to that for the Create Event endpoint except for the following:

  • attendees: This can only have one entry, which is the attendee. The calendar service does not allow you to update the status of other attendees.
  • status: This field can only be one of accepted, declined, or tentative, which is equivalent to accept, decline, and tentatively accept, respectively.

Here is the example request when David RSVP’s to the event saying he’ll attend.

The cURL request and response:

Retrieve the EVENT_ID above from the List Events response above.

You can now see that the attendee’s (David) status has changed from pending to accepted. Similarly, you can also retrieve the event from the event creator’s (Shirley) calendar to see that the attendee’s (David) status has changed.

Congrats! You now know how to use the Kloudless Calendar API to RSVP to a calendar event. If you encounter any obstacles, please read on. Feel free to reach out to us at support@kloudless.com with any feedback or questions!

Troubleshooting

  • The event creator’s event doesn’t sync with the attendee’s response.
    • This depends on the underlying service. Outlook Calendar and Google Calendar only support syncing attendees’ responses on events that are created in the primary calendar.
  • How do I retrieve the CALENDAR_ID of the primary calendar?
    • Currently, you can retrieve the CALENDAR_ID for the primary calendar by making a request to the calendar metadata endpoint with the primary alias. For example: GET cal/calendars/primary . The primary alias will soon be available for all CRUD operations.

Published By

Shirley Lee