Calendar Event Management
This allows developers to create, update, and delete calendar events for providers in Canvas. Events can be one-time or recurring, with support for daily and weekly recurrence patterns.
Build an Event with the attributes you want to set, then return one of its methods from your handler: create(), update(), or delete().
Methods #
create() → Effect #
Creates the event on a calendar.
calendar_id,title,starts_at, andends_atare required.event_idis optional. Set it to a new UUID, and Canvas gives the event that id. Store the id so your plugin can update or delete the event later. Whenevent_idisn’t set, Canvas generates the id.
update() → Effect #
Updates an existing event.
event_id,title,starts_at, andends_atare required.
delete() → Effect #
Deletes an existing event.
event_idis required.
Attributes #
| Attribute | Type | Description | Required |
|---|---|---|---|
calendar_id | str \| UUID \| None | The id of the calendar where the event will be created. | For create() |
event_id | str \| UUID \| None | The id of the event. For create(), a new UUID to give the event. For update() and delete(), the id of an existing event. | For update() and delete() |
title | str \| None | The title of the event. | For create() and update() |
starts_at | datetime \| None | The start date and time of the event. | For create() and update() |
ends_at | datetime \| None | The end date and time of the event. | For create() and update() |
recurrence_frequency | EventRecurrence \| None | The frequency of recurrence: EventRecurrence.Daily or EventRecurrence.Weekly. Without it, Canvas rejects an effect that sets recurrence_interval or recurrence_days and doesn’t save the event. | When recurrence_interval or recurrence_days is set |
recurrence_interval | int \| None | The interval between recurrences (for example, 1 for every week, 2 for every other week). | No |
recurrence_days | list[DaysOfWeek] \| None | List of days when the event should recur (used with weekly recurrence). | No |
recurrence_ends_at | datetime \| None | The date and time when the recurrence pattern ends. Canvas stores it as UNTIL in the event’s recurrence rule, so it’s the latest time an occurrence can start. To include the occurrence on the end date, set a time at or after that occurrence’s start, such as 23:59:59; midnight leaves that day’s occurrence out. Ignored when the event doesn’t recur. For update(), leave it unset to make the series open-ended. | No |
allowed_note_types | list[str] \| None | List of note types that are allowed for this event. | No |
EventRecurrence #
An enumeration of recurrence frequency options:
| Value | Description |
|---|---|
Daily | Event recurs daily |
Weekly | Event recurs weekly |
DaysOfWeek #
An enumeration of days of the week for recurring events:
| Value | Description |
|---|---|
MO | Monday |
TU | Tuesday |
WE | Wednesday |
TH | Thursday |
FR | Friday |
SA | Saturday |
SU | Sunday |
Example #
from canvas_sdk.effects.calendar import Event, EventRecurrence, DaysOfWeek
from datetime import datetime
from uuid import uuid4
# Create a one-time event
Event(
calendar_id="calendar-uuid",
title="Patient Consultation",
starts_at=datetime(2025, 1, 15, 9, 0),
ends_at=datetime(2025, 1, 15, 10, 0)
).create()
# Create a recurring event
Event(
calendar_id="calendar-uuid",
title="Weekly Team Meeting",
starts_at=datetime(2025, 1, 15, 14, 0),
ends_at=datetime(2025, 1, 15, 15, 0),
recurrence_frequency=EventRecurrence.Weekly,
recurrence_interval=1,
recurrence_days=[DaysOfWeek.Monday, DaysOfWeek.Wednesday],
recurrence_ends_at=datetime(2025, 12, 31, 23, 59),
allowed_note_types=["100", "101"]
).create()
# Create an event with an id you choose, so you can update or delete it later
event_id = str(uuid4())
Event(
event_id=event_id,
calendar_id="calendar-uuid",
title="Team Sync",
starts_at=datetime(2025, 1, 16, 9, 0),
ends_at=datetime(2025, 1, 16, 10, 0)
).create()
# Update an existing event
Event(
event_id=event_id,
title="Updated Meeting Title",
starts_at=datetime(2025, 1, 16, 15, 0),
ends_at=datetime(2025, 1, 16, 16, 0)
).update()
# Delete an event
Event(event_id=event_id).delete()