Skip to main content

POST /events

Description

Creates a new event and returns a json object with the event ID in it

The route handles the POST request made to the /events path.

HTTP methodRoute
POST/events

Payload

The server needs to receive a json object with the next properties:

NameTypeDescription
textstringRequired. The name of a new event to be added.
start_datestringRequired. The event start date in the ISO format yyyy-MM-dd'T'HH:mm:ss.SSSXXX
end_datestringRequired. The event end date in the ISO format yyyy-MM-dd'T'HH:mm:ss.SSSXXX
allDaybooleanOptional. Enables/disables the event duration throughout the day.
typenumberRequired. The calendar ID which is the event type.
detailsstringOptional. Details about a new event.
filesobjectOptional. An array of the files to be attached to a new event. You can attach files that are already uploaded to the server. The file object should contain the file id, name, and url.

Example:

{
"text": "New Event",
"start_date": "2021-06-10T03:05:00.369Z",
"end_date": "2021-06-10T10:10:00.369Z",
"allDay": true,
"type": 1,
"details": "Some details",
"files": [
{
"id": 2,
"name": "document.html",
"url": "http://localhost:3000/uploads/2/document.html"
}
]
}

Response

The route returns a json object with the ID of a new event.

Example:

"id": 1 

The HTTP status code shows whether the request succeeds (response.status == 200) or fails (response.status == 500).


Related articles: Working with server