Calendar API

Calendar API

core_calendar_create_calendar_events

This function is used to create new calendar events. You can create events for a user, a course, or a group.

Let's review the POST parameters for this function:

  1. Required Parameters:
    • events[0][name]= string (Required: The title of the calendar event.)
    • events[0][timestart]= int (Required: The start time for the event, formatted as a Unix timestamp.)
  2. Optional Parameters:
    • events[0][description]= string (Optional: A detailed description of the event.)
    • events[0][eventtype]= string (Optional: The context of the event. Can be 'user', 'course', 'group', 'site', or 'category'. Defaults to 'user'.)
    • events[0][courseid]= int (Optional: The ID of the course this event is associated with. Required if eventtype is 'course'.)
    • events[0][timeduration]= int (Optional: The duration of the event in seconds. If 0, the event is considered to have no end time.)
    • events[0][repeats]= int (Optional: The number of times the event repeats.)

cURL Command Example (Creating a Calendar Event):

curl "https://courses.yoursite.com/webservice/rest/server.php?wstoken=XXXXXXXXXXXXXXX" \
-d "wsfunction=core_calendar_create_calendar_events" \
-d "events[0][name]=Team Strategy Meeting" \
-d "events[0][description]=Discuss Q4 goals and project timelines." \
-d "events[0][timestart]=1759526400" \
-d "events[0][timeduration]=3600"



core_calendar_delete_calendar_events

This function is used to delete one or more calendar events using their unique event ID.

Let's review the POST parameters for this function:

  1. Required Parameter:
    • events[0][eventid]= int (Required: The unique ID of the calendar event to delete.)
  2. Optional Parameter:
    • events[0][repeat]= int (Optional: Set to 1 to delete all occurrences of a repeating event, or 0 to delete only this specific instance. Defaults to 0.)

cURL Command Example (Deleting a Calendar Event):

curl "https://courses.yoursite.com/webservice/rest/server.php?wstoken=XXXXXXXXXXXXXXX" \
-d "wsfunction=core_calendar_delete_calendar_events" \
-d "events[0][eventid]=456" \
-d "events[0][repeat]=0"