I guess I've found a way using the Google Calendar API. Not a matter of finding a parameter name, but not "that" complex either :).
Here you can start to read the whole story:
https://developers.google.com/google-apps/calendar/quickstart/js
... or just get the code at the bottom :). It's pretty much just the Javascript quicstart example from the above link, but I have replaced the listing of the actual user's calendar events to what I needed: adding a new event with a particular color.
What you will need to get however is a Cliend ID if you don't have one already. The above site describes that process too.
The below snippet is what it's all about. Here you can see the colorId parameter. Also mind the date params, they are for all day events. If you need date and time use the dateTime one. (more about that here: https://developers.google.com/google-apps/calendar/create-events#add_an_event)
function listUpcomingEvents() {
var event = {
'summary': 'Test Event',
'description': 'Let's go somewhere fun',
'start': {
'date': '2016-03-17'
},
'end': {
'date': '2016-03-18'
},
'colorId': '5'
};
var request = gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': event
});
request.execute(function(event) {
appendPre('Event created: ' + event.htmlLink );
});
}
Full code:
<html>
<head>
<script type="text/javascript">
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '<CLIENT ID GOES HERE!!>';
var SCOPES = ["https://www.googleapis.com/auth/calendar"];
/**
* Check if current user has authorized this application.
*/
function checkAuth() {
gapi.auth.authorize(
{
'client_id': CLIENT_ID,
'scope': SCOPES.join(' '),
'immediate': true
}, handleAuthResult);
}
/**
* Handle response from authorization server.
*
* @param {Object} authResult Authorization result.
*/
function handleAuthResult(authResult) {
var authorizeDiv = document.getElementById('authorize-div');
if (authResult && !authResult.error) {
// Hide auth UI, then load client library.
authorizeDiv.style.display = 'none';
loadCalendarApi();
} else {
// Show auth UI, allowing the user to initiate authorization by
// clicking authorize button.
authorizeDiv.style.display = 'inline';
}
}
/**
* Initiate auth flow in response to user clicking authorize button.
*
* @param {Event} event Button click event.
*/
function handleAuthClick(event) {
gapi.auth.authorize(
{client_id: CLIENT_ID, scope: SCOPES, immediate: false},
handleAuthResult);
return false;
}
/**
* Load Google Calendar client library. List upcoming events
* once client library is loaded.
*/
function loadCalendarApi() {
gapi.client.load('calendar', 'v3', listUpcomingEvents);
}
/**
* Print the summary and start datetime/date of the next ten events in
* the authorized user's calendar. If no events are found an
* appropriate message is printed.
*/
function listUpcomingEvents() {
var event = {
'summary': 'Test Event',
'description': 'Let's go somewhere fun',
'start': {
'date': '2016-03-17'
},
'end': {
'date': '2016-03-18'
},
'colorId': '5'
};
var request = gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': event
});
request.execute(function(event) {
appendPre('Event created: ' + event.htmlLink );
});
}
/**
* Append a pre element to the body containing the given message
* as its text node.
*
* @param {string} message Text to be placed in pre element.
*/
function appendPre(message) {
var pre = document.getElementById('output');
var textContent = document.createTextNode(message + '\n');
pre.appendChild(textContent);
}
</script>
<script src="https://apis.google.com/js/client.js?onload=checkAuth">
</script>
</head>
<body>
<div id="authorize-div" style="display: none">
<span>Authorize access to Google Calendar API</span>
<!--Button for the user to click to initiate auth sequence -->
<button id="authorize-button" onclick="handleAuthClick(event)">
Authorize
</button>
</div>
<pre id="output"></pre>
</body>
</html>