Skip to content

Add a calendar

Google Apps Script has a built-in CalendarApp class, a library for working with Google Calendar.

This article explains how to use the CalendarApp class to create a new calendar and add it to your account.

Because GAS accesses Google Calendar, you need to grant permissions the first time you run the script.

To add a calendar, use the following method.

Method details
CalendarApp.createCalendar([calendar name], [options (optional)]);

Use the createCalendar method provided by CalendarApp.

When you pass a calendar name as the argument, a new calendar owned by the user running the script is created.

The second argument, options, is optional. You can specify location (location), description (description), timeZone (time zone), color (color), hidden (whether to hide the calendar in the UI), and selected (whether to show the calendar’s events in the UI).

The method returns the calendar object it created, so you can start working with the calendar right after creating it.

Create a new calendar
function myFunction() {
const calendar = CalendarApp.createCalendar('New calendar');
console.log(
`A calendar named "${calendar.getName()}" was created. Its ID is ${calendar.getId()}.`
);
}

When you run it, a new calendar is added to your Google Calendar.