Events: import

Imports an event. This operation is used to add a private copy of an existing event to a calendar. Try it now or see an example.

Request

HTTP request

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

Parameters

Parameter name Value Description
Path parameters
calendarId string Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
Optional query parameters
conferenceDataVersion integer Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0. Acceptable values are 0 to 1, inclusive.
supportsAttachments boolean Whether API client performing operation supports event attachments. Optional. The default is False.

Authorization

This request requires authorization with at least one of the following scopes:

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

For more information, see the authentication and authorization page.

Request body

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

Property name Value Description Notes
Required Properties
end nested object The (exclusive) end time of the event. For a recurring event, this is the end time of the first instance.
iCalUID string Event unique identifier as defined in RFC5545. It is used to uniquely identify events accross calendaring systems and must be supplied when importing events via the import method.

Note that the iCalUID and the id are not identical and only one of them should be supplied at event creation time. One difference in their semantics is that in recurring events, all occurrences of one event have different ids while they all share the same iCalUIDs. To retrieve an event using its iCalUID, call the events.list method using the iCalUID parameter. To retrieve an event using its id, call the events.get method.

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 (deprecated). Optional. The default is False. writable
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.

Required when adding an attachment.

writable
attendees[] list The attendees of the event. See the Events with attendees guide for more information on scheduling events with other calendar users. Service accounts need to use domain-wide delegation of authority to populate the attendee list. 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[].email string The attendee's email address, if available. This field must be present when adding an attendee. It must be a valid email address as per RFC5322.

Required when adding an attendee.

writable
attendees[].optional boolean Whether this is an optional attendee. Optional. The default is False. writable
attendees[].resource boolean Whether the attendee is a resource. Can only be set when the attendee is added to the event for the first time. Subsequent modifications are ignored. Optional. The default is False. writable
attendees[].responseStatus string The attendee's response status. Possible values are:
  • "needsAction" - The attendee has not responded to the invitation (recommended for new events).
  • "declined" - The attendee has declined the invitation.
  • "tentative" - The attendee has tentatively accepted the invitation.
  • "accepted" - The attendee has accepted the invitation.
writable
attendeesOmitted boolean Whether attendees may have been omitted from the event's representation. When retrieving an event, this may be due to a restriction specified by the maxAttendee query parameter. When updating an event, this can be used to only update the participant's response. Optional. The default is False. 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
conferenceData nested object The conference-related information, such as details of a Google Meet conference. To create new conference details use the createRequest field. To persist your changes, remember to set the conferenceDataVersion request parameter to 1 for all event modification requests. writable
description string Description of the event. Can contain HTML. 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 RFC3339). 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
focusTimeProperties nested object Focus Time event data. Used if eventType is focusTime. writable
gadget.display string The gadget's display mode. Deprecated. Possible values are:
  • "icon" - The gadget displays next to the event's title in the calendar view.
  • "chip" - The gadget displays when the event is clicked.
writable
gadget.height integer The gadget's height in pixels. The height must be an integer greater than 0. Optional. Deprecated. writable
gadget.preferences object Preferences. writable
gadget.title string The gadget's title. Deprecated. writable
gadget.type string The gadget's type. Deprecated. writable
gadget.width integer The gadget's width in pixels. The width must be an integer greater than 0. Optional. Deprecated. writable
guestsCanInviteOthers boolean Whether attendees other than the organizer can invite others to the event. Optional. The default is True. writable
guestsCanModify boolean Whether attendees other than the organizer can modify the event. Optional. The default is False. writable
guestsCanSeeOtherGuests boolean Whether attendees other than the organizer can see who the event's attendees are. Optional. The default is True. writable
location string Geographic location of the event as free-form text. Optional. writable
organizer object The organizer of the event. If the organizer is also an attendee, this is indicated with a separate entry in attendees with the organizer field set to True. To change the organizer, use the move operation. Read-only, except when importing an event. writable
organizer.displayName string The organizer's name, if available. writable
organizer.email string The organizer's email address, if available. It must be a valid email address as per RFC5322. 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 RFC3339). 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
outOfOfficeProperties nested object Out of office event data. Used if eventType is outOfOffice. writable
recurrence[] list List of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event, as specified in RFC5545. Note that DTSTART and DTEND lines are not allowed in this field; event start and end times are specified in the start and end fields. 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. The maximum number of override reminders is 5. writable
reminders.overrides[].method string The method used by this reminder. Possible values are:
  • "email" - Reminders are sent via email.
  • "popup" - Reminders are sent via a UI popup.

Required when adding a reminder.

writable
reminders.overrides[].minutes integer Number of minutes before the start of the event when the reminder should trigger. Valid values are between 0 and 40320 (4 weeks in minutes).

Required when adding a reminder.

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. The URL scheme 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 RFC3339). 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. Possible values are:
  • "confirmed" - The event is confirmed. This is the default status.
  • "tentative" - The event is tentatively confirmed.
  • "cancelled" - The event is cancelled (deleted). The list method returns cancelled events only on incremental sync (when syncToken or updatedMin are specified) or if the showDeleted flag is set to true. The get method always returns them.

    A cancelled status represents two different states depending on the event type:

    1. Cancelled exceptions of an uncancelled recurring event indicate that this instance should no longer be presented to the user. Clients should store these events for the lifetime of the parent recurring event.

      Cancelled exceptions are only guaranteed to have values for the id, recurringEventId and originalStartTime fields populated. The other fields might be empty.

    2. All other cancelled events represent deleted events. Clients should remove their locally synced copies. Such cancelled events will eventually disappear, so do not rely on them being available indefinitely.

      Deleted events are only guaranteed to have the id field populated.

    On the organizer's calendar, cancelled events continue to expose event details (summary, location, etc.) so that they can be restored (undeleted). Similarly, the events to which the user was invited and that they manually removed continue to provide details. However, incremental sync requests with showDeleted set to false will not return these details.

    If an event changes its organizer (for example via the move operation) and the original organizer is not on the attendee list, it will leave behind a cancelled event where only the id field is guaranteed to be populated.

writable
summary string Title of the event. writable
transparency string Whether the event blocks time on the calendar. Optional. Possible values are:
  • "opaque" - Default value. The event does block time on the calendar. This is equivalent to setting Show me as to Busy in the Calendar UI.
  • "transparent" - The event does not block time on the calendar. This is equivalent to setting Show me as to Available in the Calendar UI.
writable
visibility string Visibility of the event. Optional. Possible values are:
  • "default" - Uses the default visibility for events on the calendar. This is the default value.
  • "public" - The event is public and event details are visible to all readers of the calendar.
  • "private" - The event is private and only event attendees may view event details.
  • "confidential" - The event is private. This value is provided for compatibility reasons.
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.

import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.Event;
import com.google.api.services.calendar.model.EventAttendee;
import com.google.api.services.calendar.model.EventDateTime;
import com.google.api.client.util.DateTime;

import java.util.Date;
// ...

// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
    .setApplicationName("applicationName").build();

// Create and initialize a new event (could also retrieve an existing event)
Event event = new Event();
event.setICalUID("originalUID");

Event.Organizer organizer = new Event.Organizer();
organizer.setEmail("organizerEmail");
organizer.setDisplayName("organizerDisplayName");
event.setOrganizer(organizer);

ArrayList<EventAttendee> attendees = new ArrayList<EventAttendee>();
attendees.add(new EventAttendee().setEmail("attendeeEmail"));
// ...
event.setAttendees(attendees);

Date startDate = new Date();
Date endDate = new Date(startDate.getTime() + 3600000);
DateTime start = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
event.setEnd(new EventDateTime().setDateTime(end));

// Import the event into a calendar
Event importedEvent = service.events().calendarImport('primary', event).execute();

System.out.println(importedEvent.getId());

Python

Uses the Python client library.

event = {
  'summary': 'Appointment',
  'location': 'Somewhere',
  'organizer': {
    'email': 'organizerEmail',
    'displayName': 'organizerDisplayName'
  },
  'start': {
    'dateTime': '2011-06-03T10:00:00.000-07:00'
  },
  'end': {
    'dateTime': '2011-06-03T10:25:00.000-07:00'
  },
  'attendees': [
    {
      'email': 'attendeeEmail',
      'displayName': 'attendeeDisplayName',
    },
    # ...
  ],
  'iCalUID': 'originalUID'
}

imported_event = service.events().import_(calendarId='primary', body=event).execute()

print imported_event['id']

PHP

Uses the PHP client library.

$event = new Google_Service_Calendar_Event();
$event->setSummary('Appointment');
$event->setLocation('Somewhere');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2011-06-03T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2011-06-03T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('attendeeEmail');
// ...
$attendees = array($attendee1,
                   // ...,
                  );
$event->attendees = $attendees;
$organizer = new Google_Service_Calendar_EventOrganizer();
$organizer->setEmail('organizerEmail');
$organizer->setDisplayName('organizerDisplayName');
$event->setOrganizer($organizer);
$event->setICalUID('originalUID');
$importedEvent = $service->events->import('primary', $event);

echo $importedEvent->getId();

Ruby

Uses the Ruby client library.

event = Google::Apis::CalendarV3::Event.new(
  summary: 'Appointment',
  location: 'Somewhere',
  organizer: {
    email: 'organizerEmail',
    display_name: 'organizerDisplayName'
  },
  start: {
    date_time: '2011-06-03T10:00:00.000-07:00'
  },
  end: {
    date_time: '2011-06-03T10:25:00.000-07:00'
  },
  attendees: [
    {
      email: 'attendeeEmail',
      display_name: 'attendeeDisplayName',
    },
    # ...
  ],
  i_cal_uid: 'originalUID'
)
result = client.import_event('primary', event)
print result.id

Try it!

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