Google Calendar API

Calendars: insert

Requires authorization

Creates a secondary calendar. Try it now or see an example.

Request

HTTP request

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

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 a Calendars resource with the following properties:

Property name Value Description Notes
Required Properties
summary string Title of the calendar. writable

Response

If successful, this method returns a Calendars 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.

Calendar calendar = new Calendar();

calendar.setSummary("calendarSummary");
calendar.setTimeZone("America/Los_Angeles");

Calendar createdCalendar = service.calendars().insert(calendar).execute();

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

Python

Uses the Python client library.

calendar = {
    'summary': 'calendarSummary',
    'timeZone': 'America/Los_Angeles'
}

created_calendar = service.calendars().insert(body=calendar).execute()

print created_calendar['id']

PHP

Uses the PHP client library.

$calendar = new Calendar();
$calendar->setSummary('calendarSummary');
$calendar->setTimeZone('America/Los_Angeles');

$createdCalendar = $service->calendars->insert($calendar);

echo $createdCalendar->getId();

Ruby

Uses the Ruby client library.

Calendar calendar = new Calendar()
    {
      Summary = "calendarSummary",
      TimeZone = "America/Los_Angeles"
    };

Calendar createdCalendar = service.Calendars.Insert(calendar).Fetch();

Console.WriteLine(createdCalendar.Id);

Try it!

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

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.