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 - POST
/api/v1/calendar-sync/connections - PATCH
/api/v1/calendar-sync/connections/{id} - DELETE
/api/v1/calendar-sync/connections/{id} - PATCH
/api/v1/calendar-sync/connections/{id}/events/{eventId} - DELETE
/api/v1/calendar-sync/connections/{id}/events/{eventId} - POST
/api/v1/calendar-sync/connections/{id}/events/{eventId}/undo - POST
/api/v1/calendar-sync/connections/{id}/sync - GET
/api/v1/calendar-sync/google/callback - POST
/api/v1/calendar-sync/google/start - GET
/api/v1/calendar-sync/microsoft/callback - POST
/api/v1/calendar-sync/microsoft/start - GET
/api/v1/settings/calendar-sync - PUT
/api/v1/settings/calendar-sync - GET
/api/v1/settings/calendar-sync/google - PUT
/api/v1/settings/calendar-sync/google - GET
/api/v1/settings/calendar-sync/microsoft - PUT
/api/v1/settings/calendar-sync/microsoft
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.
| Field | Type | Description |
|---|---|---|
connections required | array of object | |
connections[].assistant_edits | boolean | |
connections[].calendars | array of object | |
connections[].calendars[].caps | object | null | |
connections[].calendars[].color required | string | |
connections[].calendars[].name required | string | |
connections[].calendars[].read_only required | boolean | |
connections[].calendars[].time_zone | string | |
connections[].calendars[].url required | string | |
connections[].created_at | number | |
connections[].edit_events | boolean | |
connections[].enabled | boolean | |
connections[].event_count required | number | |
connections[].id | string | |
connections[].include_date_only | boolean | |
connections[].last_error | string | |
connections[].last_error_at | number | null | |
connections[].last_run | object | null | |
connections[].last_run.conflicts required | number | |
connections[].last_run.moved required | number | |
connections[].last_run.partial required | boolean | |
connections[].last_run.refused required | number | |
connections[].last_run.removed required | number | |
connections[].last_run.renamed required | number | |
connections[].last_run.unscheduled required | number | |
connections[].last_run.written required | number | |
connections[].last_success_at | number | null | |
connections[].last_sync_at | number | null | |
connections[].name | string | |
connections[].next_sync_at | number | |
connections[].password_set required | boolean | |
connections[].project_calendars required | object | |
connections[].provider | string | |
connections[].read | array of string | |
connections[].scope | object | |
connections[].scope.inboxes required | array of string | |
connections[].scope.mode required | string | |
connections[].scope.projects required | array of string | |
connections[].scope.workspaces required | array of string | |
connections[].server_url | string | |
connections[].state required | string | |
connections[].stopped_reason | string | |
connections[].target | string | |
connections[].updated_at | number | |
connections[].username | string |
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.
| Field | Type | Description |
|---|---|---|
name required | string | |
password required | string | |
server_url required | string | |
username required | string |
| Field | Type | Description |
|---|---|---|
connection required | object | null | |
connection.assistant_edits | boolean | |
connection.calendars | array of object | |
connection.calendars[].caps | object | null | |
connection.calendars[].color required | string | |
connection.calendars[].name required | string | |
connection.calendars[].read_only required | boolean | |
connection.calendars[].time_zone | string | |
connection.calendars[].url required | string | |
connection.created_at | number | |
connection.edit_events | boolean | |
connection.enabled | boolean | |
connection.event_count required | number | |
connection.id | string | |
connection.include_date_only | boolean | |
connection.last_error | string | |
connection.last_error_at | number | null | |
connection.last_run | object | null | |
connection.last_run.conflicts required | number | |
connection.last_run.moved required | number | |
connection.last_run.partial required | boolean | |
connection.last_run.refused required | number | |
connection.last_run.removed required | number | |
connection.last_run.renamed required | number | |
connection.last_run.unscheduled required | number | |
connection.last_run.written required | number | |
connection.last_success_at | number | null | |
connection.last_sync_at | number | null | |
connection.name | string | |
connection.next_sync_at | number | |
connection.password_set required | boolean | |
connection.project_calendars required | object | |
connection.provider | string | |
connection.read | array of string | |
connection.scope | object | |
connection.scope.inboxes required | array of string | |
connection.scope.mode required | string | |
connection.scope.projects required | array of string | |
connection.scope.workspaces required | array of string | |
connection.server_url | string | |
connection.state required | string | |
connection.stopped_reason | string | |
connection.target | string | |
connection.updated_at | number | |
connection.username | string |
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)
| Field | Type | Description |
|---|---|---|
id required | string | path |
| Field | Type | Description |
|---|---|---|
assistant_edits | boolean | null | |
edit_events | boolean | null | |
enabled | boolean | null | |
include_date_only | boolean | null | |
name | string | null | |
password | string | null | |
project_calendars | object | null | |
read | array of string | |
scope | object | null | |
scope.inboxes required | array of string | |
scope.mode required | string | |
scope.projects required | array of string | |
scope.workspaces required | array of string | |
target | string | null |
| Field | Type | Description |
|---|---|---|
connection required | object | null | |
connection.assistant_edits | boolean | |
connection.calendars | array of object | |
connection.calendars[].caps | object | null | |
connection.calendars[].color required | string | |
connection.calendars[].name required | string | |
connection.calendars[].read_only required | boolean | |
connection.calendars[].time_zone | string | |
connection.calendars[].url required | string | |
connection.created_at | number | |
connection.edit_events | boolean | |
connection.enabled | boolean | |
connection.event_count required | number | |
connection.id | string | |
connection.include_date_only | boolean | |
connection.last_error | string | |
connection.last_error_at | number | null | |
connection.last_run | object | null | |
connection.last_run.conflicts required | number | |
connection.last_run.moved required | number | |
connection.last_run.partial required | boolean | |
connection.last_run.refused required | number | |
connection.last_run.removed required | number | |
connection.last_run.renamed required | number | |
connection.last_run.unscheduled required | number | |
connection.last_run.written required | number | |
connection.last_success_at | number | null | |
connection.last_sync_at | number | null | |
connection.name | string | |
connection.next_sync_at | number | |
connection.password_set required | boolean | |
connection.project_calendars required | object | |
connection.provider | string | |
connection.read | array of string | |
connection.scope | object | |
connection.scope.inboxes required | array of string | |
connection.scope.mode required | string | |
connection.scope.projects required | array of string | |
connection.scope.workspaces required | array of string | |
connection.server_url | string | |
connection.state required | string | |
connection.stopped_reason | string | |
connection.target | string | |
connection.updated_at | number | |
connection.username | string |
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
| Field | Type | Description |
|---|---|---|
id required | string | path |
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
| Field | Type | Description |
|---|---|---|
id required | string | path |
eventId required | string | path |
| Field | Type | Description |
|---|---|---|
allDay | boolean | null | |
end | object | null | |
end.date required | string | |
end.time | string | null | |
end.tz | string | null | |
rev | string | null | |
start | object | null | |
start.date required | string | |
start.time | string | null | |
start.tz | string | null | |
summary | string | null |
| Field | Type | Description |
|---|---|---|
event required | object | |
event.access | object | null | |
event.access.delete required | boolean | |
event.access.reason | string | |
event.access.update required | boolean | |
event.allDay required | boolean | |
event.changedBy | object | null | |
event.changedBy.kind required | string | |
event.changedBy.name required | string | |
event.end required | object | |
event.end.date required | string | |
event.end.time | string | null | |
event.end.tz | string | null | |
event.free required | boolean | |
event.id required | string | |
event.location required | string | |
event.rev | string | |
event.start required | object | |
event.start.date required | string | |
event.start.time | string | null | |
event.start.tz | string | null | |
event.subscriptionId required | string | |
event.summary required | string | |
event.uid required | string | |
replaces required | string |
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
| Field | Type | Description |
|---|---|---|
id required | string | path |
eventId required | string | path |
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
| Field | Type | Description |
|---|---|---|
id required | string | path |
eventId required | string | path |
| Field | Type | Description |
|---|---|---|
event required | object | |
event.access | object | null | |
event.access.delete required | boolean | |
event.access.reason | string | |
event.access.update required | boolean | |
event.allDay required | boolean | |
event.changedBy | object | null | |
event.changedBy.kind required | string | |
event.changedBy.name required | string | |
event.end required | object | |
event.end.date required | string | |
event.end.time | string | null | |
event.end.tz | string | null | |
event.free required | boolean | |
event.id required | string | |
event.location required | string | |
event.rev | string | |
event.start required | object | |
event.start.date required | string | |
event.start.time | string | null | |
event.start.tz | string | null | |
event.subscriptionId required | string | |
event.summary required | string | |
event.uid required | string | |
replaces required | string |
POST /api/v1/calendar-sync/connections/{id}/sync
Calendar sync connection sync · Token or session
discovery and a cycle now: {ok, run?, reason?, connection}
| Field | Type | Description |
|---|---|---|
id required | string | path |
| Field | Type | Description |
|---|---|---|
connection required | object | null | |
connection.assistant_edits | boolean | |
connection.calendars | array of object | |
connection.calendars[].caps | object | null | |
connection.calendars[].color required | string | |
connection.calendars[].name required | string | |
connection.calendars[].read_only required | boolean | |
connection.calendars[].time_zone | string | |
connection.calendars[].url required | string | |
connection.created_at | number | |
connection.edit_events | boolean | |
connection.enabled | boolean | |
connection.event_count required | number | |
connection.id | string | |
connection.include_date_only | boolean | |
connection.last_error | string | |
connection.last_error_at | number | null | |
connection.last_run | object | null | |
connection.last_run.conflicts required | number | |
connection.last_run.moved required | number | |
connection.last_run.partial required | boolean | |
connection.last_run.refused required | number | |
connection.last_run.removed required | number | |
connection.last_run.renamed required | number | |
connection.last_run.unscheduled required | number | |
connection.last_run.written required | number | |
connection.last_success_at | number | null | |
connection.last_sync_at | number | null | |
connection.name | string | |
connection.next_sync_at | number | |
connection.password_set required | boolean | |
connection.project_calendars required | object | |
connection.provider | string | |
connection.read | array of string | |
connection.scope | object | |
connection.scope.inboxes required | array of string | |
connection.scope.mode required | string | |
connection.scope.projects required | array of string | |
connection.scope.workspaces required | array of string | |
connection.server_url | string | |
connection.state required | string | |
connection.stopped_reason | string | |
connection.target | string | |
connection.updated_at | number | |
connection.username | string |
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.
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.
| Field | Type | Description |
|---|---|---|
connection_id required | string |
| Field | Type | Description |
|---|---|---|
url required | string |
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.
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.
| Field | Type | Description |
|---|---|---|
connection_id required | string |
| Field | Type | Description |
|---|---|---|
url required | string |
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
| Field | Type | Description |
|---|---|---|
enabled required | boolean | |
google required | boolean | |
max_connections required | number | |
microsoft required | boolean |
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.
| Field | Type | Description |
|---|---|---|
enabled required | boolean |
| Field | Type | Description |
|---|---|---|
enabled required | boolean |
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.
| Field | Type | Description |
|---|---|---|
client_id required | string | |
from_env required | boolean | |
redirect_uri required | string | |
secret_set required | boolean |
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.
| Field | Type | Description |
|---|---|---|
client_id | string | null | |
client_secret | string | null |
| Field | Type | Description |
|---|---|---|
client_id required | string | |
from_env required | boolean | |
redirect_uri required | string | |
secret_set required | boolean |
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.
| Field | Type | Description |
|---|---|---|
client_id required | string | |
from_env required | boolean | |
redirect_uri required | string | |
refused_at required | number | null | |
secret_set required | boolean | |
tenant required | string |
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.
| Field | Type | Description |
|---|---|---|
client_id | string | null | |
client_secret | string | null | |
tenant | string | null |
| Field | Type | Description |
|---|---|---|
client_id required | string | |
from_env required | boolean | |
redirect_uri required | string | |
refused_at required | number | null | |
secret_set required | boolean | |
tenant required | string |