# Add an event via API

**URL:** <https://help.nextcloud.com/t/add-an-event-via-api/53712>\
**Category:** ℹ️ Support\
**Tags:** calendar-app\
**Created:** [May 21, 2019, 9:47pm UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712 "2019-05-21T21:47:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bart15](https://help.nextcloud.com/user_avatar/help.nextcloud.com/bart15/32/60089_2.png) [@Bart15](https://help.nextcloud.com/u/Bart15)\
**Post date:** [May 21, 2019, 9:47pm UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/1 "2019-05-21T21:47:46Z")

</div>

Hello all.  
I need to add event to a nextcloud calendar via an API. I know how to build my event with python and icalender. But how to add it to the calendar 🤔? Should I add it directly to the database on the server?

Thanks for your help

---

<div class="post-metadata">

**Author:** ![georgehrke](https://help.nextcloud.com/user_avatar/help.nextcloud.com/georgehrke/32/912_2.png) [@georgehrke](https://help.nextcloud.com/u/georgehrke)\
**Post date:** [May 25, 2019, 5:31pm UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/2 "2019-05-25T17:31:33Z")

</div>

> [@Bart15](#):
>
> But how to add it to the calendar 🤔?

There is an official API: CalDAV.  
Just create yourself an app-password in the personal settings and create events directly via CalDAV. I can’t give you any recommendation, but there are plenty of caldav libs for Python.

> [@Bart15](#):
>
> Should I add it directly to the database on the server?

Please don’t. Whenever you create events, it’s not just added to the calendarobjects table, but there are modifications in many other tables. The c-tag in the calendars table is incremented, it adds a record to calendar changes, plenty new rows are added to calendarobjects\_props, the activity app saves a change, etc etc.  
If you insert it directly, you will only end up with inconsistencies in the database.

---

<div class="post-metadata">

**Author:** ![Bart15](https://help.nextcloud.com/user_avatar/help.nextcloud.com/bart15/32/60089_2.png) [@Bart15](https://help.nextcloud.com/u/Bart15)\
**Post date:** [May 26, 2019, 12:00pm UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/3 "2019-05-26T12:00:28Z")

</div>

@georgehrke  
In the meantime I’ve look at the database and see it would be very difficult to add event into it.  
And I discover CalDAV too. And find python’s lib.  
Thanks for your reply  
Have a nice day

---

<div class="post-metadata">

**Author:** ![bukowski](https://help.nextcloud.com/user_avatar/help.nextcloud.com/bukowski/32/20229_2.png) [@bukowski](https://help.nextcloud.com/u/bukowski)\
**Post date:** [January 9, 2020, 9:08am UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/4 "2020-01-09T09:08:35Z")

</div>

Hi  
I ask here, we have company app for vacations. How connect to caldav api as admin to create calendar vacations (if doesnt exist) and add event to all users?  
thanx for answer

---

<div class="post-metadata">

**Author:** ![daveteu](https://help.nextcloud.com/user_avatar/help.nextcloud.com/daveteu/32/27949_2.png) [@daveteu](https://help.nextcloud.com/u/daveteu)\
**Post date:** [December 15, 2020, 2:33pm UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/5 "2020-12-15T14:33:25Z")

</div>

did u happen to find an answer to this? Adding an event for all users

---

<div class="post-metadata">

**Author:** ![meonkeys](https://help.nextcloud.com/user_avatar/help.nextcloud.com/meonkeys/32/27937_2.png) [@meonkeys](https://help.nextcloud.com/u/meonkeys)\
**Post date:** [April 2, 2021, 9:02pm UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/6 "2021-04-02T21:02:43Z")

</div>

Will you share some example code or links to documentation? I’m trying to do something similar.

---

<div class="post-metadata">

**Author:** ![Akito](https://help.nextcloud.com/user_avatar/help.nextcloud.com/akito/32/17954_2.png) [@Akito](https://help.nextcloud.com/u/Akito)\
**Post date:** [April 29, 2023, 4:39pm UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/7 "2023-04-29T16:39:46Z")

</div>

Well, this also seems like a pain in the ass. I suppose, the two biggest reasons for that is the laughably inaccurate Nextcloud documentation & the atrocious general API to begin with.

---

<div class="post-metadata">

**Author:** ![tcit](https://help.nextcloud.com/user_avatar/help.nextcloud.com/tcit/32/5931_2.png) [@tcit](https://help.nextcloud.com/u/tcit)\
**Post date:** [May 2, 2023, 12:48pm UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/8 "2023-05-02T12:48:21Z")

</div>

Not through CalDAV, but our documentation has a whole section on how to interact and manage calendar events through public interfaces: [Calendar integration — Nextcloud latest Developer Manual latest documentation](https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/groupware/calendar.html)

For CalDAV any generic CalDAV library will do.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 4, 2024, 9:55am UTC](https://help.nextcloud.com/t/add-an-event-via-api/53712/9 "2024-12-04T09:55:41Z")

</div>


