5 minutes to help shape OpenTodo. Anonymous, no account. Take the survey

Calendar sync API

The account's own calendar (any CalDAV server with an app password, Google Calendar, or Outlook.com and Microsoft 365 through Microsoft Graph) receives its dated tasks as events, and changes made there come back to the tasks.

Implementation notes

The account's own calendar (any CalDAV server with an app password, Google Calendar, or Outlook.com and Microsoft 365 through Microsoft Graph) receives its dated tasks as events, and changes made there come back to the tasks (OpenSpec change calendar-two-way; guide: calendar-sync.md). Every /api/v1/calendar-sync route answers 404 calendar_sync_disabled while the owner's switch is off, and these routes and the settings answer 403 demo_restricted on the public demo before authentication. Read and agent tokens may use the GET routes only. Connections are server data: never operations, never synced or exported; passwords, Google and Microsoft refresh tokens and the Google and Microsoft client secrets live in <data>/secrets/calendar-sync.json only and are never returned.

GET /api/v1/calendar-sync/connections

List calendar sync connections · Token or session

{connections: [...]}: id, provider (caldav, google, microsoft), name, server_url, username, calendars ([{url, name, color, time_zone?, read_only, caps: {create, update, delete}}]), target, read, include_date_only, scope (see Sync scope), enabled, state (off, choose_calendar, pending, ok, failed, reconnect, stopped), next_sync_at, last_sync_at, last_success_at, last_error, last_error_at, stopped_reason, last_run ({moved, renamed, unscheduled, written, removed, conflicts, refused, partial}), password_set, event_count. Never the password or token.

Response 200
FieldTypeDescription
connections requiredarray of object
connections[].assistant_editsboolean
connections[].calendarsarray of object
connections[].calendars[].capsobject | null
connections[].calendars[].color requiredstring
connections[].calendars[].name requiredstring
connections[].calendars[].read_only requiredboolean
connections[].calendars[].time_zonestring
connections[].calendars[].url requiredstring
connections[].created_atnumber
connections[].edit_eventsboolean
connections[].enabledboolean
connections[].event_count requirednumber
connections[].idstring
connections[].include_date_onlyboolean
connections[].last_errorstring
connections[].last_error_atnumber | null
connections[].last_runobject | null
connections[].last_run.conflicts requirednumber
connections[].last_run.moved requirednumber
connections[].last_run.partial requiredboolean
connections[].last_run.refused requirednumber
connections[].last_run.removed requirednumber
connections[].last_run.renamed requirednumber
connections[].last_run.unscheduled requirednumber
connections[].last_run.written requirednumber
connections[].last_success_atnumber | null
connections[].last_sync_atnumber | null
connections[].namestring
connections[].next_sync_atnumber
connections[].password_set requiredboolean
connections[].project_calendars requiredobject
connections[].providerstring
connections[].readarray of string
connections[].scopeobject
connections[].scope.inboxes requiredarray of string
connections[].scope.mode requiredstring
connections[].scope.projects requiredarray of string
connections[].scope.workspaces requiredarray of string
connections[].server_urlstring
connections[].state requiredstring
connections[].stopped_reasonstring
connections[].targetstring
connections[].updated_atnumber
connections[].usernamestring

POST /api/v1/calendar-sync/connections

Create a calendar sync connection · Token or session

{server_url, username, password, name?}: server_url is an address, a host name or an email address (then /.well-known/caldav of its domain); discovery runs at once; 201 {connection} in the state choose_calendar

Needs a recently confirmed session or second factor.

Request body
FieldTypeDescription
name requiredstring
password requiredstring
server_url requiredstring
username requiredstring
Response 201
FieldTypeDescription
connection requiredobject | null
connection.assistant_editsboolean
connection.calendarsarray of object
connection.calendars[].capsobject | null
connection.calendars[].color requiredstring
connection.calendars[].name requiredstring
connection.calendars[].read_only requiredboolean
connection.calendars[].time_zonestring
connection.calendars[].url requiredstring
connection.created_atnumber
connection.edit_eventsboolean
connection.enabledboolean
connection.event_count requirednumber
connection.idstring
connection.include_date_onlyboolean
connection.last_errorstring
connection.last_error_atnumber | null
connection.last_runobject | null
connection.last_run.conflicts requirednumber
connection.last_run.moved requirednumber
connection.last_run.partial requiredboolean
connection.last_run.refused requirednumber
connection.last_run.removed requirednumber
connection.last_run.renamed requirednumber
connection.last_run.unscheduled requirednumber
connection.last_run.written requirednumber
connection.last_success_atnumber | null
connection.last_sync_atnumber | null
connection.namestring
connection.next_sync_atnumber
connection.password_set requiredboolean
connection.project_calendars requiredobject
connection.providerstring
connection.readarray of string
connection.scopeobject
connection.scope.inboxes requiredarray of string
connection.scope.mode requiredstring
connection.scope.projects requiredarray of string
connection.scope.workspaces requiredarray of string
connection.server_urlstring
connection.state requiredstring
connection.stopped_reasonstring
connection.targetstring
connection.updated_atnumber
connection.usernamestring

PATCH /api/v1/calendar-sync/connections/{id}

Update a calendar sync connection · Token or session

any of name, target (a writable calendar of the connection), read (up to 10 of its calendars), include_date_only, scope (see Sync scope; makes the connection due now), enabled, edit_events and assistant_edits (booleans, off by default, see Calendar events; assistant_edits: true while edit_events is off is 400 invalid_input naming assistant_edits, and turning edit_events off turns both off), password (CalDAV only; Google and Microsoft reconnect instead; needs a fresh sign-in, 403 reauth_required; checked by discovery, then clears a stop)

Path parameters
FieldTypeDescription
id requiredstringpath
Request body
FieldTypeDescription
assistant_editsboolean | null
edit_eventsboolean | null
enabledboolean | null
include_date_onlyboolean | null
namestring | null
passwordstring | null
project_calendarsobject | null
readarray of string
scopeobject | null
scope.inboxes requiredarray of string
scope.mode requiredstring
scope.projects requiredarray of string
scope.workspaces requiredarray of string
targetstring | null
Response 200
FieldTypeDescription
connection requiredobject | null
connection.assistant_editsboolean
connection.calendarsarray of object
connection.calendars[].capsobject | null
connection.calendars[].color requiredstring
connection.calendars[].name requiredstring
connection.calendars[].read_only requiredboolean
connection.calendars[].time_zonestring
connection.calendars[].url requiredstring
connection.created_atnumber
connection.edit_eventsboolean
connection.enabledboolean
connection.event_count requirednumber
connection.idstring
connection.include_date_onlyboolean
connection.last_errorstring
connection.last_error_atnumber | null
connection.last_runobject | null
connection.last_run.conflicts requirednumber
connection.last_run.moved requirednumber
connection.last_run.partial requiredboolean
connection.last_run.refused requirednumber
connection.last_run.removed requirednumber
connection.last_run.renamed requirednumber
connection.last_run.unscheduled requirednumber
connection.last_run.written requirednumber
connection.last_success_atnumber | null
connection.last_sync_atnumber | null
connection.namestring
connection.next_sync_atnumber
connection.password_set requiredboolean
connection.project_calendars requiredobject
connection.providerstring
connection.readarray of string
connection.scopeobject
connection.scope.inboxes requiredarray of string
connection.scope.mode requiredstring
connection.scope.projects requiredarray of string
connection.scope.workspaces requiredarray of string
connection.server_urlstring
connection.state requiredstring
connection.stopped_reasonstring
connection.targetstring
connection.updated_atnumber
connection.usernamestring

DELETE /api/v1/calendar-sync/connections/{id}

Delete a calendar sync connection · Token or session

204; the secret is removed, tasks and events already written stay

Path parameters
FieldTypeDescription
id requiredstringpath

Response 200: OK

PATCH /api/v1/calendar-sync/connections/{id}/events/{eventId}

Update a calendar sync connection event · Token or session

change an event of a connected calendar: see Calendar events

Path parameters
FieldTypeDescription
id requiredstringpath
eventId requiredstringpath
Request body
FieldTypeDescription
allDayboolean | null
endobject | null
end.date requiredstring
end.timestring | null
end.tzstring | null
revstring | null
startobject | null
start.date requiredstring
start.timestring | null
start.tzstring | null
summarystring | null
Response 200
FieldTypeDescription
event requiredobject
event.accessobject | null
event.access.delete requiredboolean
event.access.reasonstring
event.access.update requiredboolean
event.allDay requiredboolean
event.changedByobject | null
event.changedBy.kind requiredstring
event.changedBy.name requiredstring
event.end requiredobject
event.end.date requiredstring
event.end.timestring | null
event.end.tzstring | null
event.free requiredboolean
event.id requiredstring
event.location requiredstring
event.revstring
event.start requiredobject
event.start.date requiredstring
event.start.timestring | null
event.start.tzstring | null
event.subscriptionId requiredstring
event.summary requiredstring
event.uid requiredstring
replaces requiredstring

DELETE /api/v1/calendar-sync/connections/{id}/events/{eventId}

Delete a calendar sync connection event · Token or session

delete an event of a connected calendar: 204

Path parameters
FieldTypeDescription
id requiredstringpath
eventId requiredstringpath

Response 200: OK

POST /api/v1/calendar-sync/connections/{id}/events/{eventId}/undo

Calendar sync connection event undo · Token or session

restore what an assistant's change of the event replaced

Path parameters
FieldTypeDescription
id requiredstringpath
eventId requiredstringpath
Response 200
FieldTypeDescription
event requiredobject
event.accessobject | null
event.access.delete requiredboolean
event.access.reasonstring
event.access.update requiredboolean
event.allDay requiredboolean
event.changedByobject | null
event.changedBy.kind requiredstring
event.changedBy.name requiredstring
event.end requiredobject
event.end.date requiredstring
event.end.timestring | null
event.end.tzstring | null
event.free requiredboolean
event.id requiredstring
event.location requiredstring
event.revstring
event.start requiredobject
event.start.date requiredstring
event.start.timestring | null
event.start.tzstring | null
event.subscriptionId requiredstring
event.summary requiredstring
event.uid requiredstring
replaces requiredstring

POST /api/v1/calendar-sync/connections/{id}/sync

Calendar sync connection sync · Token or session

discovery and a cycle now: {ok, run?, reason?, connection}

Path parameters
FieldTypeDescription
id requiredstringpath
Response 200
FieldTypeDescription
connection requiredobject | null
connection.assistant_editsboolean
connection.calendarsarray of object
connection.calendars[].capsobject | null
connection.calendars[].color requiredstring
connection.calendars[].name requiredstring
connection.calendars[].read_only requiredboolean
connection.calendars[].time_zonestring
connection.calendars[].url requiredstring
connection.created_atnumber
connection.edit_eventsboolean
connection.enabledboolean
connection.event_count requirednumber
connection.idstring
connection.include_date_onlyboolean
connection.last_errorstring
connection.last_error_atnumber | null
connection.last_runobject | null
connection.last_run.conflicts requirednumber
connection.last_run.moved requirednumber
connection.last_run.partial requiredboolean
connection.last_run.refused requirednumber
connection.last_run.removed requirednumber
connection.last_run.renamed requirednumber
connection.last_run.unscheduled requirednumber
connection.last_run.written requirednumber
connection.last_success_atnumber | null
connection.last_sync_atnumber | null
connection.namestring
connection.next_sync_atnumber
connection.password_set requiredboolean
connection.project_calendars requiredobject
connection.providerstring
connection.readarray of string
connection.scopeobject
connection.scope.inboxes requiredarray of string
connection.scope.mode requiredstring
connection.scope.projects requiredarray of string
connection.scope.workspaces requiredarray of string
connection.server_urlstring
connection.state requiredstring
connection.stopped_reasonstring
connection.targetstring
connection.updated_atnumber
connection.usernamestring

GET /api/v1/calendar-sync/google/callback

Get calendar sync google callback · Session only

Google's redirect: exchanges the code, stores the refresh token, discovers the calendars and redirects (303) to /settings/integrations/calendar-sync?calendar-sync=connected&connection=<id>, or ?calendar-sync=<reason>: denied (Google's access_denied), redirect_uri_mismatch, authorization_failed (any other error from Google, or no code), invalid_state, google_client_refused (Google refused the owner's client id or secret), scope_not_granted (the calendar permission was unticked), no_refresh_token, caldav_api_disabled (Google's CalDAV answered 403: the CalDAV API is not enabled in the owner's project), limit_reached or another discovery reason

Needs a session; tokens are refused.

Response 200: OK

POST /api/v1/calendar-sync/google/start

Calendar sync google start · Token or session

{connection_id?} (to reconnect); {url}: Google's consent page with a single-use state (10 minutes) and a PKCE challenge; 409 google_not_configured without a Google client; 409 base_url_mismatch when the request's Origin is not the origin of the redirect address (set OPENTODO_BASE_URL)

Needs a recently confirmed session or second factor.

Request body
FieldTypeDescription
connection_id requiredstring
Response 200
FieldTypeDescription
url requiredstring

GET /api/v1/calendar-sync/microsoft/callback

Get calendar sync microsoft callback · Session only

Microsoft's redirect: exchanges the code, stores the refresh token, reads the account's address, mailbox time zone and calendars and redirects (303) to /settings/integrations/calendar-sync?calendar-sync=connected&connection=<id>&provider=microsoft, or ?calendar-sync=<reason>&provider=microsoft (denied, admin_consent_required when the organisation requires an administrator's approval, authorization_failed, invalid_state also for a Google state, no_refresh_token, limit_reached, unauthorized, a discovery reason)

Needs a session; tokens are refused.

Response 200: OK

POST /api/v1/calendar-sync/microsoft/start

Calendar sync microsoft start · Token or session

{connection_id?} (to reconnect); {url}: Microsoft's sign-in page for the configured tenant (https://login.microsoftonline.com/<tenant>/oauth2/v2.0/authorize) with the scopes offline_access User.Read Calendars.ReadWrite MailboxSettings.Read, a single-use state bound to the account and to Microsoft (10 minutes) and a PKCE challenge; 409 microsoft_not_configured without a Microsoft client, 409 limit_reached at 3 connections; counts toward the limit of 12 per hour

Needs a recently confirmed session or second factor.

Request body
FieldTypeDescription
connection_id requiredstring
Response 200
FieldTypeDescription
url requiredstring

GET /api/v1/settings/calendar-sync

Get settings calendar sync · Token or session

{enabled, google, microsoft, max_connections} (google, microsoft: that client is set up); the setting calendar_sync.enabled; off by default; a change is recorded as settings.changed

Response 200
FieldTypeDescription
enabled requiredboolean
google requiredboolean
max_connections requirednumber
microsoft requiredboolean

PUT /api/v1/settings/calendar-sync

Update settings calendar sync · Token or session

{enabled, google, microsoft, max_connections} (google, microsoft: that client is set up); the setting calendar_sync.enabled; off by default; a change is recorded as settings.changed

Only the server's owner.

Request body
FieldTypeDescription
enabled requiredboolean
Response 200
FieldTypeDescription
enabled requiredboolean

GET /api/v1/settings/calendar-sync/google

Get settings calendar sync google · Token or session

{client_id, secret_set, from_env, redirect_uri}; never the secret

Only the server's owner.

Response 200
FieldTypeDescription
client_id requiredstring
from_env requiredboolean
redirect_uri requiredstring
secret_set requiredboolean

PUT /api/v1/settings/calendar-sync/google

Update settings calendar sync google · Token or session

{client_id, client_secret?} (an empty secret removes it); 409 managed_by_environment while OPENTODO_GOOGLE_CLIENT_ID and a secret are set; recorded as settings.changed for calendar_sync.google_client without values

Only the server's owner. Needs a session or an admin token; full tokens are refused.

Request body
FieldTypeDescription
client_idstring | null
client_secretstring | null
Response 200
FieldTypeDescription
client_id requiredstring
from_env requiredboolean
redirect_uri requiredstring
secret_set requiredboolean

GET /api/v1/settings/calendar-sync/microsoft

Get settings calendar sync microsoft · Token or session

{client_id, tenant, secret_set, from_env, redirect_uri, refused_at} (tenant is common unless set; refused_at: when Microsoft last refused the secret, Unix ms, else null); never the secret

Only the server's owner.

Response 200
FieldTypeDescription
client_id requiredstring
from_env requiredboolean
redirect_uri requiredstring
refused_at requirednumber | null
secret_set requiredboolean
tenant requiredstring

PUT /api/v1/settings/calendar-sync/microsoft

Update settings calendar sync microsoft · Token or session

{client_id, tenant?, client_secret?} (an empty secret removes it; tenant is common, organizations, consumers, a tenant id or a domain, else 400 invalid_input with field: tenant); a new secret clears refused_at and resumes the connections stopped with microsoft_client_refused; 409 managed_by_environment while OPENTODO_MICROSOFT_CLIENT_ID and a secret are set; recorded as settings.changed for calendar_sync.microsoft_client without values

Only the server's owner. Needs a session or an admin token; full tokens are refused.

Request body
FieldTypeDescription
client_idstring | null
client_secretstring | null
tenantstring | null
Response 200
FieldTypeDescription
client_id requiredstring
from_env requiredboolean
redirect_uri requiredstring
refused_at requirednumber | null
secret_set requiredboolean
tenant requiredstring

This group in the HTTP API guide