Object reference
Calendar
A calendar holds a set of events. Most scripts use your default calendar, but you can also open another calendar you have access to by its ID.
CalendarApp.CalendarStart here
Get this object first
Get your default calendar, the one that matches your main Google Calendar.
function showDefaultCalendarName() {
const calendar = CalendarApp.getDefaultCalendar();
Logger.log(calendar.getName());
} Then use it
Common actions
Choose an action, then open its example only when you need the code.
List the events for today
This lists the titles of events on the default calendar for today and does not change any of them.
CalendarApp.CalendarCalendarApp.CalendarEventShow example code
function logTodaysEventTitles() {
const calendar = CalendarApp.getDefaultCalendar();
const events = calendar.getEventsForDay(new Date());
const titles = events.map((event) => event.getTitle());
Logger.log(titles.join(', ') || 'No events today');
} Create a timed event (this adds an event)
This adds a new one hour event to the default calendar starting an hour from now. It does not change any existing events.
CalendarApp.CalendarCalendarApp.CalendarEventShow example code
function createUpcomingEvent() {
const calendar = CalendarApp.getDefaultCalendar();
const startTime = new Date(Date.now() + 60 * 60 * 1000);
const endTime = new Date(startTime.getTime() + 60 * 60 * 1000);
const event = calendar.createEvent('Project check-in', startTime, endTime);
Logger.log('Created: ' + event.getTitle());
} Get a calendar by its ID
This opens a calendar you have access to by its ID and reads its name. It does not change the calendar.
CalendarApp.CalendarShow example code
function showCalendarNameById() {
const calendar = CalendarApp.getCalendarById('REPLACE_WITH_CALENDAR_ID');
if (!calendar) throw new Error('No calendar was found for that ID.');
Logger.log(calendar.getName());
} Technical reference
Exact names and signatures
Generated runtime and signature facts stay separate from the beginner actions above. Open method details only when you need them.
At a glance
- Service
- CalendarApp
- Reference symbol
CalendarApp.Calendar- Object
Calendar- Runtime
- From signature data
Methods and signatures
Browse 26 methods
createAllDayEvent
- createAllDayEvent(title: string, date: Date): CalendarApp.CalendarEvent
- createAllDayEvent(title: string, startDate: Date, endDate: Date): CalendarApp.CalendarEvent
- createAllDayEvent(title: string, startDate: Date, endDate: Date, options: CalendarApp.EventOptions): CalendarApp.CalendarEvent
- createAllDayEvent(title: string, date: Date, options: CalendarApp.EventOptions): CalendarApp.CalendarEvent
createAllDayEventSeries
- createAllDayEventSeries(title: string, startDate: Date, recurrence: CalendarApp.EventRecurrence): CalendarApp.CalendarEventSeries
- createAllDayEventSeries(title: string, startDate: Date, recurrence: CalendarApp.EventRecurrence, options: unknown): CalendarApp.CalendarEventSeries
createEvent
- createEvent(title: string, startTime: Date, endTime: Date): CalendarApp.CalendarEvent
- createEvent(title: string, startTime: Date, endTime: Date, options: CalendarApp.EventOptions): CalendarApp.CalendarEvent
createEventFromDescription
- createEventFromDescription(description: string): CalendarApp.CalendarEvent
createEventSeries
- createEventSeries(title: string, startTime: Date, endTime: Date, recurrence: CalendarApp.EventRecurrence): CalendarApp.CalendarEventSeries
- createEventSeries(title: string, startTime: Date, endTime: Date, recurrence: CalendarApp.EventRecurrence, options: unknown): CalendarApp.CalendarEventSeries
deleteCalendar
- deleteCalendar(): void
getColor
- getColor(): string
getDescription
- getDescription(): string
getEventById
- getEventById(id: string): CalendarApp.CalendarEvent | null
getEventSeriesById
- getEventSeriesById(iCalId: string): CalendarApp.CalendarEventSeries
getEvents
- getEvents(startTime: Date, endTime: Date): CalendarApp.CalendarEvent[]
- getEvents(startTime: Date, endTime: Date, options: CalendarApp.EventSearchOptions): CalendarApp.CalendarEvent[]
getEventsForDay
- getEventsForDay(date: Date): CalendarApp.CalendarEvent[]
- getEventsForDay(date: Date, options: CalendarApp.EventSearchOptions): CalendarApp.CalendarEvent[]
getId
- getId(): string
getName
- getName(): string
getTimeZone
- getTimeZone(): string
isHidden
- isHidden(): boolean
isMyPrimaryCalendar
- isMyPrimaryCalendar(): boolean
isOwnedByMe
- isOwnedByMe(): boolean
isSelected
- isSelected(): boolean
setColor
- setColor(color: string): CalendarApp.Calendar
setDescription
- setDescription(description: string): CalendarApp.Calendar
setHidden
- setHidden(hidden: boolean): CalendarApp.Calendar
setName
- setName(name: string): CalendarApp.Calendar
setSelected
- setSelected(selected: boolean): CalendarApp.Calendar
setTimeZone
- setTimeZone(timeZone: string): CalendarApp.Calendar
unsubscribeFromCalendar
- unsubscribeFromCalendar(): void
Need the whole workflow?
Return to a task guide
Task guides cover setup, permissions, expected results, and troubleshooting as well as object methods.
Browse Google Calendar tasks