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.
Method to use
Section titled “Method to use”To add a calendar, use the following method.
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.
Sample code
Section titled “Sample code”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.