The Google Apps Calendar Resource API allows Google Apps administrators to retrieve and manage the Google Calendar resources of their domains in the form of Google Data API feeds.
You can add resources that users in your domain will be able to schedule on their calendars, such as conference rooms, projectors, or company vehicles.
The Calendar Resource API supports the Google Data API protocol. The Google Data API conforms to the Atom Publishing Protocol (AtomPub) publishing and editing model. The AtomPub HTTP requests use the Representational Set Transfer (RESTful) design approach to web services. For more information, see the Google Data APIs Overview.
This document is intended for programmers who want to write client applications that can modify and retrieve information about their domain's Google Calendar resources. It provides examples of the basic Calendar Resource API interactions using raw XML and HTTP.
This document assumes that you understand the general ideas behind the Google Data API protocol, and that you are familiar with administering Google Calendar resources. For more information about creating a calendar resource in the control panel, see Scheduling calendar resources.
The Calendar Resource API is enabled for the Google Apps Premier and Education Editions. You may want to sign up for a Premier Edition account for testing purposes. For more information about which APIs are enabled for each Google Apps product edition, see the Google Apps APIs Getting Started.
When you are creating and updating a calendar resource, you need a flexible naming strategy for your resource names, descriptions, and categories. Descriptive resource information helps users schedule the resource, and helps calendar administrators manage resources over time. We have assembled a few suggestions to consider when building your resources:
A suggested naming pattern is:
Since conference rooms are the most common resource, this example includes a special conference room recommendation which groups your conference room listings together.
The suggested pattern for a conference room is:
The suggested pattern for a general resource type is:
Access to the Calendar Resource API is limited to domain administrators who have authenticate each request. The Calendar Resource API feed is private, and unauthenticated requests are not accepted. Before retrieving or changing calendar resource properties, your client must authenticate using the ClientLogin authentication system. To use this system, you submit the email address and password of the domain administrator making the request. The authentication service returns an authentication token that your client can then send to the Calendar Resource API service along with every subsequent request.
For more information about authentication with Google Data APIs in general, see the authentication documentation.
The samples in this document assume you are providing the appropriate authentication.
To request an authentication token using the ClientLogin mechanism, send a
POST request to the following URL:
https://www.google.com/accounts/ClientLogin
The POST request contains the following Content-type header:
Content-type: application/x-www-form-urlencoded
The POST body contains a set of query parameters that look like parameters passed by an HTML form. These are:
HOSTED_OR_GOOGLE account type. This type is authenticated first as a hosted account. If this attempt fails, the administrator or user is authenticated as a Google account. This allows for the primary and secondary administrators to log in to this account.admin%40example.comapps, a Google Apps service. For other service names, see the service name list.The POST body contains the following string with each parameter's name-value pair:
POST &Email=yourAdminEmail&Passwd=yourAdminPassword&accountType=HOSTED_OR_GOOGLE&service=apps
&source=companyName-applicationName-versionID
For more information about ClientLogin parameters, see the Authentication for Installed Applications document.
If the authentication request fails, then the server returns an HTTP 403 Forbidden status code.
If the request succeeds, then the server returns an HTTP 200 OK
status code, plus three long alphanumeric codes in the body of the
response: SID, LSID, and Auth. The SID is the session ID valid for the life of the session. The Auth value is the authorization token that you'll send to the Calendar Resource service with each of your subsequent API requests. Google recommends keeping the authorization token in memory rather than writing it to a file. In the context of this guide, you can ignore the SID and LSID values.
Since all requests to the Calendar Resource service require authentication, set the Content-type and Authorization headers in all service requests using the following format:
Content-type: application/atom+xml Authorization: GoogleLogin auth=yourAuthToken
Where yourAuthToken is the Auth string returned from the ClientLogin POST request. Use this token for all requests in a given session. A new token is not required for each Calendar Resource request.
Note: Tokens are valid for 24 hours. If an authenticated request fails, it may mean you need to acquire another token by posting the administrator's or user's credentials to the ClientLogin URL again.
For more information about ClientLogin authentication, including sample requests and responses, see the Authentication for Installed Applications documentation.
If you get a CAPTCHA error with your request, the error response will return a CAPTCHA token and URL:
CaptchaToken=captchaToken CaptchaUrl=Captcha?ctoken=captchaToken Error=cr Url=https://www.google.com/a/example.com/ErrorMsg?Email=adminLogin
%40yourDomainName&service=apps&id=cr&timeStmp=1222898074&secTok=theCAPTCHAtoken
For information about handling a CAPTCHA challenge, see the CAPTCHA FAQ.
To create a calendar resource, use the following POST request:
POST https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain
The following XML shows a sample request to create a new calendar resource, the Boardroom conference room in NYC:
<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
<apps:property name='resourceId' value='CR-NYC-14-12-BR'/>
<apps:property name='resourceCommonName' value='Boardroom'/>
<apps:property name='resourceDescription' value='This conference room is in New York city, building 14, floor 12, Boardroom'/>
<apps:property name='resourceType' value='CR'/>
</atom:entry>
Note: When working with the API, the maximum number of calendar resources per domain is 3,000.
The properties are:
Note: When a resource is created in the control panel, the resource ID is a series of numbers.
When using our suggested naming strategy, a resource type becomes very helpful to the user. Resource hierarchies are automatically created when three of more resources are added with the same first three characters in their common name. In the calendar resource list, these hierarchies occur when the calendar resource list begins to scroll and the immediate screen is full with several resources.
A successful response returns an HTTP 201 status code found in the Google Data API status codes documentation. Along with the status code, the response returns an AtomPub feed with the entry element showing new resource's settings:
<entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schema.google.com/apps/2006'>
<id>https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/CR-NYC-14-12-BR</id>
<updated>2008-10-17T15:02:45.646Z</updated>
<link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/id'/>
<link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/id'/>
<apps:property name='resourceId' value='CR-NYC-14-12-BR'/>
<apps:property name='resourceCommonName' value='Boardroom'/>
<apps:property name='resourceDescription' value='This conference room is in New York city, building 14, floor 12, Boardroom'/>
<apps:property name='resourceType' value='CR'/>
</entry>
To retrieve a single calendar's resource, send the following HTTP GET request to the resource ID's feed URL. Include the Authorization header as described in Authenticating.
GET https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/resourceId
This operation has no parameters in the request body.
A successful response returns an HTTP 200 status code from the Google Data API status codes:
<entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
<id>https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/CR-NYC-14-12-BR</id>
<updated>2008-10-17T15:19:46.467Z</updated>
<link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/CR-NYC-14-12-BR'/>
<link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/CR-NYC-14-12-BR'/>
<apps:property name='resourceId' value='CR-NYC-14-12-BR'/>
<apps:property name='resourceCommonName' value='Boardroom'/>
<apps:property name='resourceEmail' value='domain_123456@resource.calendar.google.com'/>
<apps:property name='resourceDescription' value='This conference room is in New York city, building 14, floor 12, Boardroom'/>
<apps:property name='resourceType' value='CR'/>
</entry>
The response entry element returns the same properties used when creating a resource along with the calendar's encoded resourceEmail property:
<domain name>_nnn...@resource.calendar.google.com. This is the ID in a calendar's Calendar Details page's Calendar Address section. Your calendar must be public for others to use this calendar address.
The API's XML feed uses pagination for results listing more than 100 calendar resources. For a large response, each page of results returns a maximum of 100 entries, and includes a URI in a <link rel='next'...> tag pointing to the next page of results. When developing your client application, your code needs to manage these additional results.
To retrieve the first page of resource entries associated with a particular calendar, send an HTTP GET request ending with a forward slash to a resource feed URL. Include the Authorization header as described in Authenticating.
GET https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/
Optionally, you can send an HTTP GET request with an empty string in the start parameter to a resource feed URL.
GET https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/?start=""
This operation has no parameters in the request body.
A successful response returns an HTTP 200 status code from the Google Data API status codes.
In this example, the response entry elements return the properties for two resources:
<feed xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:apps='http://schemas.google.com/apps/2006'>
<id>https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain</id>
<updated>2008-10-17T15:29:21.064Z</atom:updated>
<link rel='next' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/?start=the next resourceId'/>
<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain'/>
<link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain'/>
<link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain?start=CR-NYC-14-12-BR'/>
<openSearch:startIndex>1</openSearch:startIndex>
<entry>
<id>https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/CR-NYC-14-12-BR</id>
<updated>2008-10-17T15:29:21.064Z</updated>
<link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/CR-NYC-14-12-BR'/>
<link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/feeds/calendar/resource/2.0/your domain/CR-NYC-14-12-BR'/>
<apps:property name='resourceId' value='CR-NYC-14-12-BR'/>
<apps:property name='resourceCommonName' value='Boardroom'/>
<apps:property name='resourceEmail' value='domain_123456@resource.calendar.google.com'/>
<apps:property name='resourceDescription' value='This conference room is in New York city, building 14, floor 12, Boardroom'/>
<apps:property name='resourceType' value='CR'/>
</entry>
<entry>
<id>https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/?start=(Bike)-London-43-Lobby-Bike-1</id>
<updated>2008-10-17T15:29:21.064Z</updated>
<link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/(Bike)-London-43-Lobby-Bike-1'/>
<link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/(Bike)-London-43-Lobby-Bike-1'/>
<apps:property name='resourceId' value='(Bike)-London-43-Lobby-Bike-1'/>
<apps:property name='resourceCommonName' value='London bike-1'/>
<apps:property name='resourceEmail' value='domain_123457@resource.calendar.google.com'/>
<apps:property name='resourceDescription' value='Bike is in London at building 43's lobby.'/>
<apps:property name='resourceType' value='(Bike)'/>
</entry>
</feed>
If the domain has over 100 resources, the response includes a next URI of the next page of results:
<link rel="next" type="application/atom+xml" href="https://apps-apis.google.com/a/feeds/calendar/resource/2.0/domainName/?start=the next page's first resourceId>
To retrieve these additional pages, use the next URI in your subsequent GET requests to retrieve all of your calendar resources:
GET https://apps-apis.google.com/a/feeds/calendar/resource/2.0/domainName/?start=the next page's first resourceId
To update a calendar resource, send a PUT request to a resource ID's feed URL. Include the Authorization header as described in Authenticating.
PUT https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/resourceId
You can update the resourceCommonName, resourceDescription, and resourceType properties:
<atom:entry xmlns:atom='http://www.w3.org/2005/Atom'>
<apps:property xmlns:apps='http://schemas.google.com/apps/2006' name='resourceCommonName' value='new common name'/>
<apps:property xmlns:apps='http://schemas.google.com/apps/2006' name='resourceDescription' value='new description'/>
<apps:property xmlns:apps='http://schemas.google.com/apps/2006' name='resourceType' value='new type'/>
</atom:entry>
A successful response returns an HTTP 200 status code from the Google Data API status codes.
The response entry element returns these resource settings:
<entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
<id>https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/resourceId</id>
<updated>2008-10-17T15:21:22.223Z</updated>
<link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/resouceId'/>
<link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/resourceId'/>
<apps:property name='resourceCommonName' value='new common name'/>
<apps:property name='resourceDescription' value='new description'/>
<apps:property name='resourceType' value='new type'/>
</entry>
To delete a calendar resource, send a DELETE request to a resource ID's feed URL. Include the Authorization header as described in Authenticating.
DELETE https://apps-apis.google.com/a/feeds/calendar/resource/2.0/your domain/resourceId
A successful response returns an HTTP 200 status code from the Google Data API status codes. The XML body of a successful response to a DELETE request is empty.