Skip to content

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.Calendar

Start here

Get this object first

Get your default calendar, the one that matches your main Google Calendar.

Code.gs
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.CalendarEvent
Show example code
Code.gs
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.CalendarEvent
Show example code
Code.gs
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.Calendar
Show example code
Code.gs
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

From signature data Google source
  • 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

From signature data Google source
  • createAllDayEventSeries(title: string, startDate: Date, recurrence: CalendarApp.EventRecurrence): CalendarApp.CalendarEventSeries
  • createAllDayEventSeries(title: string, startDate: Date, recurrence: CalendarApp.EventRecurrence, options: unknown): CalendarApp.CalendarEventSeries

createEvent

From signature data Google source
  • createEvent(title: string, startTime: Date, endTime: Date): CalendarApp.CalendarEvent
  • createEvent(title: string, startTime: Date, endTime: Date, options: CalendarApp.EventOptions): CalendarApp.CalendarEvent

createEventFromDescription

From signature data Google source
  • createEventFromDescription(description: string): CalendarApp.CalendarEvent

createEventSeries

From signature data Google source
  • 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

From signature data Google source
  • deleteCalendar(): void

getColor

From signature data Google source
  • getColor(): string

getDescription

From signature data Google source
  • getDescription(): string

getEventById

From signature data Google source
  • getEventById(id: string): CalendarApp.CalendarEvent | null

getEventSeriesById

From signature data Google source
  • getEventSeriesById(iCalId: string): CalendarApp.CalendarEventSeries

getEvents

From signature data Google source
  • getEvents(startTime: Date, endTime: Date): CalendarApp.CalendarEvent[]
  • getEvents(startTime: Date, endTime: Date, options: CalendarApp.EventSearchOptions): CalendarApp.CalendarEvent[]

getEventsForDay

From signature data Google source
  • getEventsForDay(date: Date): CalendarApp.CalendarEvent[]
  • getEventsForDay(date: Date, options: CalendarApp.EventSearchOptions): CalendarApp.CalendarEvent[]

getId

From signature data Google source
  • getId(): string

getName

From signature data Google source
  • getName(): string

getTimeZone

From signature data Google source
  • getTimeZone(): string

isHidden

From signature data Google source
  • isHidden(): boolean

isMyPrimaryCalendar

From signature data Google source
  • isMyPrimaryCalendar(): boolean

isOwnedByMe

From signature data Google source
  • isOwnedByMe(): boolean

isSelected

From signature data Google source
  • isSelected(): boolean

setColor

From signature data Google source
  • setColor(color: string): CalendarApp.Calendar

setDescription

From signature data Google source
  • setDescription(description: string): CalendarApp.Calendar

setHidden

From signature data Google source
  • setHidden(hidden: boolean): CalendarApp.Calendar

setName

From signature data Google source
  • setName(name: string): CalendarApp.Calendar

setSelected

From signature data Google source
  • setSelected(selected: boolean): CalendarApp.Calendar

setTimeZone

From signature data Google source
  • setTimeZone(timeZone: string): CalendarApp.Calendar

unsubscribeFromCalendar

From signature data Google source
  • 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