How do I add calendar events to Local Calendar via rest api

hello,

my kids school sends out a lot emails with dates for different activities. I wrote a python script to extract the date and activity and I would like to add it to Home Assistant’s Local Calendar.

going off the very limited documentation found here:

I’ve tried sending the event with different variations of:

# JSON payload for creating an all-day event
event_data = {
    "entity_id": "calendar.local",  
    "summary": "calendar test",
    "start_date": "2024-11-02", 
    "end_date": "2024-11-03"   
}

# Make the POST request to call the `calendar.create_event` service
response = requests.post(
    f'{home_assistant_url}/api/services/calendar/create_event',
    # f'{home_assistant_url}/api/calendars/event/create',
    # f'{home_assistant_url}/api/calendar/event/create',
    # f'{home_assistant_url}/api/calendars/{calendar_id}/events',
    # f"{home_assistant_url}/api/services/calendar/create"
    # f"{home_assistant_url}/api/calendar/event/{calendar_id}"

    headers=headers,
    json=event_data
)

I either get a 404: Not Found, 400: Bad Request, or 405: Method Not Allowed. I’ve asked ChatGPT and Claude and neither have been any help.

is it possible to add an event to Local Calendar from a python script api post?

Thank you

You would use the /api/services/<domain>/<service> api call, where domain is “calendar” and service is “create_event”. You can find the domain and service, along with the parameters available in Developer Tools. If you switch to YAML mode after filling in the parameters you will see the YAML equivalent of the JSON you need to send, and the “action:” value will be the domain and service (action: calendar.create_event in this case).

that worked! thank you!

f'{home_assistant_url}/api/services/calendar/create_event',