Skip to content

calendar ​

Read and write Google Calendar events from Agency code. Authorizes once via Google OAuth, then lists, creates, updates, and deletes events.

Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET (OAuth 2.0 desktop credentials from the Google Cloud console) for the example below. authorizeCalendar opens a browser for consent. Agency stores the tokens locally and refreshes them when possible.

ts
import { authorizeCalendar, isCalendarAuthorized, listEvents, createEvent } from "std::calendar"
import { env } from "std::system"

node main() {
  if (!isCalendarAuthorized()) {
    const clientId = env("GOOGLE_CLIENT_ID") with approve
    const clientSecret = env("GOOGLE_CLIENT_SECRET") with approve
    authorizeCalendar(clientId, clientSecret)
  }

  print(listEvents())

  createEvent(
    summary: "Team meeting",
    start: "2026-05-10T10:00:00-07:00",
    end: "2026-05-10T11:00:00-07:00"
  )
}

Times use ISO 8601 with a timezone (e.g. "2026-05-10T10:00:00-07:00"), or a date only (e.g. "2026-05-10") for all-day events. Pair with std::date helpers like tomorrow and atTime for convenient date construction.

Effects ​

std::authorizeCalendar ​

ts
@always(clientId)
effect std::authorizeCalendar {
  clientId: string
}

(source)

std::listEvents ​

ts
@always(calendarId)
effect std::listEvents {
  maxResults: number;
  calendarId: string;
  query: string
}

(source)

std::createEvent ​

ts
effect std::createEvent {
  summary: string;
  start: string;
  end: string;
  description: string;
  location: string
}

(source)

std::updateEvent ​

ts
effect std::updateEvent {
  eventId: string;
  summary: string;
  start: string;
  end: string
}

(source)

std::deleteEvent ​

ts
@always(calendarId)
effect std::deleteEvent {
  eventId: string;
  calendarId: string
}

(source)

Functions ​

authorizeCalendar ​

ts
authorizeCalendar(
  clientId: string,
  clientSecret: string,
): Result raises <std::authorizeCalendar>

Open the browser to authorize Google Calendar access.

Set up Google OAuth desktop credentials before authorizing. Tokens use the google-calendar provider in std::auth/oauth and refresh when possible. Use that module directly for custom scopes or callback ports.

Parameters:

NameTypeDefaultDescription
clientIdstringThe client ID from Google OAuth desktop credentials.
clientSecretstringThe matching Google OAuth client secret.

Returns: Result

Throws: std::authorizeCalendar

Needs: fileRead, fileWrite, network, subprocess, env

(source)

isCalendarAuthorized ​

ts
isCalendarAuthorized(): boolean

Check whether Google Calendar tokens are stored locally, without verifying their validity.

Returns: boolean

Needs: fileRead

(source)

listEvents ​

ts
listEvents(
  maxResults: number = 10,
  timeMin: string = "",
  timeMax: string = "",
  query: string = "",
  calendarId: string = "primary",
): Result raises <std::listEvents>

List Google Calendar events in start-time order.

Parameters:

NameTypeDefaultDescription
maxResultsnumber10
timeMinstring""An ISO 8601 timestamp with timezone, or empty to start at the current time.
timeMaxstring""An ISO 8601 timestamp with timezone, or empty for no upper bound.
querystring""Free-text terms to match against events.
calendarIdstring"primary"Use "primary" for the signed-in user's primary calendar.

Returns: Result

Throws: std::listEvents

Needs: fileRead, fileWrite, network, subprocess, env

(source)

createEvent ​

ts
createEvent(
  summary: string,
  start: string,
  end: string,
  description: string = "",
  location: string = "",
  calendarId: string = "primary",
): Result raises <std::createEvent>

Create a Google Calendar event.

For an all-day event, pass dates with an exclusive end date. For example, May 10 alone uses start "2026-05-10" and end "2026-05-11".

Parameters:

NameTypeDefaultDescription
summarystring
startstringAn ISO 8601 timestamp with timezone, or YYYY-MM-DD for an all-day event.
endstringAn ISO 8601 timestamp with timezone, or the exclusive end date for an all-day event.
descriptionstring""
locationstring""
calendarIdstring"primary"Use "primary" for the signed-in user's primary calendar.

Returns: Result

Throws: std::createEvent

Needs: fileRead, fileWrite, network, subprocess, env

(source)

updateEvent ​

ts
updateEvent(
  eventId: string,
  summary: string = "",
  start: string = "",
  end: string = "",
  description: string = "",
  location: string = "",
  calendarId: string = "primary",
): Result raises <std::updateEvent>

Update the supplied fields of a Google Calendar event, leaving empty fields unchanged.

Parameters:

NameTypeDefaultDescription
eventIdstringThe event id returned by a calendar listing or creation.
summarystring""
startstring""A timestamp with timezone or all-day date, or empty to leave unchanged.
endstring""A timestamp with timezone or exclusive all-day end date, or empty to leave unchanged.
descriptionstring""
locationstring""
calendarIdstring"primary"The calendar containing the event.

Returns: Result

Throws: std::updateEvent

Needs: fileRead, fileWrite, network, subprocess, env

(source)

deleteEvent ​

ts
deleteEvent(
  eventId: string,
  calendarId: string = "primary",
): Result raises <std::deleteEvent>

Delete a Google Calendar event.

Parameters:

NameTypeDefaultDescription
eventIdstringThe event id returned by a calendar listing or creation.
calendarIdstring"primary"The calendar containing the event.

Returns: Result

Throws: std::deleteEvent

Needs: fileRead, fileWrite, network, subprocess, env

(source)