Hide

Events: insert

Requires authorization

Creates an event. Try it now or see an example.

Request

HTTP request

POST https://www.googleapis.com/calendar/v3/calendars/calendarId/events

Parameters

Parameter name Value Description
Path parameters
calendarId string Calendar identifier.
Optional query parameters
maxAttendees integer The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
sendNotifications boolean Whether to send notifications about the creation of the new event. Optional. The default is False.
supportsAttachments boolean Whether API client performing operation supports event attachments. Optional. The default is False.

Authorization

This request requires authorization with the following scope (read more about authentication and authorization).

Scope
https://www.googleapis.com/auth/calendar

Request body

In the request body, supply an Events resource with the following properties:

Property name Value Description Notes
Required Properties
attachments[].fileUrl string URL link to the attachment.

For adding Google Drive file attachments use the same format as in alternateLink property of the Files resource in the Drive API.

attendees[].email string The attendee's email address, if available. This field must be present when adding an attendee.
end nested object The (exclusive) end time of the event. For a recurring event, this is the end time of the first instance.
reminders.overrides[].method string The method used by this reminder.

Acceptable values are:
  • "email": Reminders are sent via email.
  • "popup": Reminders are sent via a UI popup.
  • "sms": Reminders are sent via SMS.
reminders.overrides[].minutes integer Number of minutes before the start of the event when the reminder should trigger.
start nested object The (inclusive) start time of the event. For a recurring event, this is the start time of the first instance.
Optional Properties
anyoneCanAddSelf boolean Whether anyone can invite themselves to the event. Optional. The default is False. writable
attendees[] list The attendees of the event. writable
attendees[].additionalGuests integer Number of additional guests. Optional. The default is 0. writable
attendees[].comment string The attendee's response comment. Optional. writable
attendees[].displayName string The attendee's name, if available. Optional. writable
attendees[].optional boolean Whether this is an optional attendee. Optional. The default is False. writable
attendees[].responseStatus string The attendee's response status.

Acceptable values are:
  • "accepted": The attendee has accepted the invitation.
  • "declined": The attendee has declined the invitation.
  • "needsAction": The attendee has not responded to the invitation.
  • "tentative": The attendee has tentatively accepted the invitation.
writable
colorId string The color of the event. This is an ID referring to an entry in the event section of the colors definition (see the colors endpoint). Optional. writable
description string Description of the event. Optional. writable
end.date date The date, in the format "yyyy-mm-dd", if this is an all-day event. writable
end.dateTime datetime The time, as a combined date-time value (formatted according to RFC 3339). A time zone offset is required unless a time zone is explicitly specified in timeZone. writable
end.timeZone string The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) For recurring events this field is required and specifies the time zone in which the recurrence is expanded. For single events this field is optional and indicates a custom time zone for the event start/end. writable
extendedProperties.private object Properties that are private to the copy of the event that appears on this calendar. writable
extendedProperties.shared object Properties that are shared between copies of the event on other attendees' calendars. writable
gadget.display string The gadget's display mode. Optional.

Acceptable values are:
  • "chip": The gadget displays when the event is clicked.
  • "icon": The gadget displays next to the event's title in the calendar view.
writable
gadget.height integer The gadget's height in pixels. Optional. writable
gadget.preferences object Preferences. writable
gadget.title string The gadget's title. writable
gadget.type string The gadget's type. writable
gadget.width integer The gadget's width in pixels. Optional. writable
guestsCanInviteOthers boolean Whether attendees other than the organizer can invite others to the event. Optional. The default is True. writable
guestsCanSeeOtherGuests boolean Whether attendees other than the organizer can see who the event's attendees are. Optional. The default is True. writable
id string Identifier of the event. When creating new single or recurring events, you can specify their IDs. Provided IDs must follow these rules:
  • characters allowed in the ID are those used in base32hex encoding, i.e. lowercase letters a-v and digits 0-9, see section 3.1.2 in RFC2938
  • the length of the ID must be between 5 and 1024 characters
  • the ID must be unique per calendar
Due to the globally distributed nature of the system, we cannot guarantee that ID collisions will be detected at event creation time. To minimize the risk of collisions we recommend using an established UUID algorithm such as one described in RFC4122.
writable
location string Geographic location of the event as free-form text. Optional. writable
originalStartTime.date date The date, in the format "yyyy-mm-dd", if this is an all-day event. writable
originalStartTime.dateTime datetime The time, as a combined date-time value (formatted according to RFC 3339). A time zone offset is required unless a time zone is explicitly specified in timeZone. writable
originalStartTime.timeZone string The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) For recurring events this field is required and specifies the time zone in which the recurrence is expanded. For single events this field is optional and indicates a custom time zone for the event start/end. writable
recurrence[] list List of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event. This field is omitted for single events or instances of recurring events. writable
reminders.overrides[] list If the event doesn't use the default reminders, this lists the reminders specific to the event, or, if not set, indicates that no reminders are set for this event. writable
reminders.useDefault boolean Whether the default reminders of the calendar apply to the event. writable
sequence integer Sequence number as per iCalendar. writable
source.title string Title of the source; for example a title of a web page or an email subject. writable
source.url string URL of the source pointing to a resource. URL's protocol must be HTTP or HTTPS. writable
start.date date The date, in the format "yyyy-mm-dd", if this is an all-day event. writable
start.dateTime datetime The time, as a combined date-time value (formatted according to RFC 3339). A time zone offset is required unless a time zone is explicitly specified in timeZone. writable
start.timeZone string The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) For recurring events this field is required and specifies the time zone in which the recurrence is expanded. For single events this field is optional and indicates a custom time zone for the event start/end. writable
status string Status of the event. Optional.

Acceptable values are:
  • "cancelled": The event is cancelled.
  • "confirmed": The event is confirmed. This is the default status.
  • "tentative": The event is tentatively confirmed.
writable
summary string Title of the event. writable
transparency string Whether the event blocks time on the calendar. Optional.

Acceptable values are:
  • "opaque": The event blocks time on the calendar. This is the default value.
  • "transparent": The event does not block time on the calendar.
writable
visibility string Visibility of the event. Optional.

Acceptable values are:
  • "confidential": The event is private. This value is provided for compatibility reasons.
  • "default": Uses the default visibility for events on the calendar. This is the default value.
  • "private": The event is private and only event attendees may view event details.
  • "public": The event is public and event details are visible to all readers of the calendar.
writable

Response

If successful, this method returns an Events resource in the response body.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

// Refer to the Java quickstart on how to setup the environment:
// https://developers.google.com/google-apps/calendar/quickstart/java
// Change the scope to CalendarScopes.CALENDAR and delete any stored
// credentials.

Event event = new Event()
    .setSummary("Google I/O 2015")
    .setLocation("800 Howard St., San Francisco, CA 94103")
    .setDescription("A chance to hear more about Google's developer products.");

DateTime startDateTime = new DateTime("2015-05-28T09:00:00-07:00");
EventDateTime start = new EventDateTime()
    .setDateTime(startDateTime)
    .setTimeZone("America/Los_Angeles");
event.setStart(start);

DateTime endDateTime = new DateTime("2015-05-28T17:00:00-07:00");
EventDateTime end = new EventDateTime()
    .setDateTime(endDateTime)
    .setTimeZone("America/Los_Angeles");
event.setEnd(end);

String[] recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=2"};
event.setRecurrence(Arrays.asList(recurrence));

EventAttendee[] attendees = new EventAttendee[] {
    new EventAttendee().setEmail("lpage@example.com"),
    new EventAttendee().setEmail("sbrin@example.com"),
};
event.setAttendees(Arrays.asList(attendees));

EventReminder[] reminderOverrides = new EventReminder[] {
    new EventReminder().setMethod("email").setMinutes(24 * 60),
    new EventReminder().setMethod("sms").setMinutes(10),
};
Event.Reminders reminders = new Event.Reminders()
    .setUseDefault(false)
    .setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders);

String calendarId = "primary";
event = service.events().insert(calendarId, event).execute();
System.out.printf("Event created: %s\n", event.getHtmlLink());

Python

Uses the Python client library.

# Refer to the Python quickstart on how to setup the environment:
# https://developers.google.com/google-apps/calendar/quickstart/python
# Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
# stored credentials.

event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2015-05-28T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles',
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles',
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': 'lpage@example.com'},
    {'email': 'sbrin@example.com'},
  ],
  'reminders': {
    'useDefault': False,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'sms', 'minutes': 10},
    ],
  },
}

event = service.events().insert(calendarId='primary', body=event).execute()
print 'Event created: %s' % (event.get('htmlLink'))

PHP

Uses the PHP client library.

// Refer to the PHP quickstart on how to setup the environment:
// https://developers.google.com/google-apps/calendar/quickstart/php
// Change the scope to Google_Service_Calendar::CALENDAR and delete any stored
// credentials.

$event = new Google_Service_Calendar_Event(array(
  'summary' => 'Google I/O 2015',
  'location' => '800 Howard St., San Francisco, CA 94103',
  'description' => 'A chance to hear more about Google\'s developer products.',
  'start' => array(
    'dateTime' => '2015-05-28T09:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'end' => array(
    'dateTime' => '2015-05-28T17:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'recurrence' => array(
    'RRULE:FREQ=DAILY;COUNT=2'
  ),
  'attendees' => array(
    array('email' => 'lpage@example.com'),
    array('email' => 'sbrin@example.com'),
  ),
  'reminders' => array(
    'useDefault' => FALSE,
    'overrides' => array(
      array('method' => 'email', 'minutes' => 24 * 60),
      array('method' => 'sms', 'minutes' => 10),
    ),
  ),
));

$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);

Ruby

Uses the Ruby client library.

# Refer to the Ruby quickstart on how to setup the environment:
# https://developers.google.com/google-apps/calendar/quickstart/ruby
# Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
# stored credentials.

event = {
  'summary' => 'Google I/O 2015',
  'location' => '800 Howard St., San Francisco, CA 94103',
  'description' => 'A chance to hear more about Google\'s developer products.',
  'start' => {
    'dateTime' => '2015-05-28T09:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  },
  'end' => {
    'dateTime' => '2015-05-28T17:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  },
  'recurrence' => [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees' => [
    {'email' => 'lpage@example.com'},
    {'email' => 'sbrin@example.com'},
  ],
  'reminders' => {
    'useDefault' => false,
    'overrides' => [
      {'method' => 'email', 'minutes' => 24 * 60},
      {'method' => 'sms', 'minutes' => 10},
    ],
  },
}

results = client.execute!(
  :api_method => calendar_api.events.insert,
  :parameters => {
    :calendarId => 'primary'},
  :body_object => event)
event = results.data
puts "Event created: #{event.htmlLink}"

.NET

Uses the .NET client library.

// Refer to the .NET quickstart on how to setup the environment:
// https://developers.google.com/google-apps/calendar/quickstart/dotnet
// Change the scope to CalendarService.Scope.Calendar and delete any stored
// credentials.

Event newEvent = new Event()
{
    Summary = "Google I/O 2015",
    Location = "800 Howard St., San Francisco, CA 94103",
    Description = "A chance to hear more about Google's developer products.",
    Start = new EventDateTime()
    {
        DateTime = DateTime.Parse("2015-05-28T09:00:00-07:00"),
        TimeZone = "America/Los_Angeles",
    },
    End = new EventDateTime()
    {
        DateTime = DateTime.Parse("2015-05-28T17:00:00-07:00"),
        TimeZone = "America/Los_Angeles",
    },
    Recurrence = new String[] { "RRULE:FREQ=DAILY;COUNT=2" },
    Attendees = new EventAttendee[] {
        new EventAttendee() { Email = "lpage@example.com" },
        new EventAttendee() { Email = "sbrin@example.com" },
    },
    Reminders = new Event.RemindersData()
    {
        UseDefault = false,
        Overrides = new EventReminder[] {
            new EventReminder() { Method = "email", Minutes = 24 * 60 },
            new EventReminder() { Method = "sms", Minutes = 10 },
        }
    }
};

String calendarId = "primary";
EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
Event createdEvent = request.Execute();
Console.WriteLine("Event created: {0}", createdEvent.HtmlLink);

Go

Uses the Go client library.

// Refer to the Go quickstart on how to setup the environment:
// https://developers.google.com/google-apps/calendar/quickstart/go
// Change the scope to calendar.CalendarScope and delete any stored credentials.

event := &calendar.Event{
  Summary: "Google I/O 2015",
  Location: "800 Howard St., San Francisco, CA 94103",
  Description: "A chance to hear more about Google's developer products.",
  Start: &calendar.EventDateTime{
    DateTime: "2015-05-28T09:00:00-07:00",
    TimeZone: "America/Los_Angeles",
  },
  End: &calendar.EventDateTime{
    DateTime: "2015-05-28T17:00:00-07:00",
    TimeZone: "America/Los_Angeles",
  },
  Recurrence: []string{"RRULE:FREQ=DAILY;COUNT=2"},
  Attendees: []*calendar.EventAttendee{
    &calendar.EventAttendee{Email:"lpage@example.com"},
    &calendar.EventAttendee{Email:"sbrin@example.com"},
  },
}

calendarId := "primary"
event, err = srv.Events.Insert(calendarId, event).Do()
if err != nil {
  log.Fatalf("Unable to create event. %v\n", err)
}
fmt.Printf("Event created: %s\n", event.HtmlLink)

JavaScript

Uses the JavaScript client library.

// Refer to the JavaScript quickstart on how to setup the environment:
// https://developers.google.com/google-apps/calendar/quickstart/js
// Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
// stored credentials.

var event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2015-05-28T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': 'lpage@example.com'},
    {'email': 'sbrin@example.com'}
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'sms', 'minutes': 10}
    ]
  }
};

var request = gapi.client.calendar.events.insert({
  'calendarId': 'primary',
  'resource': event
});

request.execute(function(event) {
  appendPre('Event created: ' + event.htmlLink);
});

Node.js

Uses the Node.js client library.

// Refer to the Node.js quickstart on how to setup the environment:
// https://developers.google.com/google-apps/calendar/quickstart/node
// Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
// stored credentials.

var event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2015-05-28T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles',
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles',
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': 'lpage@example.com'},
    {'email': 'sbrin@example.com'},
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'sms', 'minutes': 10},
    ],
  },
};

calendar.events.insert({
  auth: auth,
  calendarId: 'primary',
  resource: event,
}, function(err, event) {
  if (err) {
    console.log('There was an error contacting the Calendar service: ' + err);
    return;
  }
  console.log('Event created: %s', event.htmlLink);
});

Try it!

Use the APIs Explorer below to call this method on live data and see the response.

Send feedback about...

Google Calendar API