[role="xpack"]
[testenv="platinum"]
[[ml-get-calendar-event]]
= Get scheduled events API
++++
Get scheduled events
++++
Retrieves information about the scheduled events in calendars.
[[ml-get-calendar-event-request]]
== {api-request-title}
`GET _ml/calendars//events` +
`GET _ml/calendars/_all/events`
[[ml-get-calendar-event-prereqs]]
== {api-prereq-title}
Requires the `monitor_ml` cluster privilege. This privilege is included in the 
`machine_learning_user` built-in role.
[[ml-get-calendar-event-desc]]
== {api-description-title}
You can get scheduled event information for multiple calendars in a single
API request by using a comma-separated list of ids or a wildcard expression.
You can get scheduled event information for all calendars by using `_all`,
by specifying `*` as the ``, or by omitting the ``.
For more information, see
{ml-docs}/ml-calendars.html[Calendars and scheduled events].
[[ml-get-calendar-event-path-parms]]
== {api-path-parms-title}
``::
(Required, string)
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=calendar-id]
[[ml-get-calendar-event-request-body]]
== {api-request-body-title}
`end`::
    (Optional, string) Specifies to get events with timestamps earlier than this
    time.
`from`::
    (Optional, integer) Skips the specified number of events.
`size`::
    (Optional, integer) Specifies the maximum number of events to obtain.
`start`::
    (Optional, string) Specifies to get events with timestamps after this time.
[[ml-get-calendar-event-results]]
== {api-response-body-title}
The API returns an array of scheduled event resources, which have the
following properties:
`calendar_id`::
(string)
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=calendar-id]
`description`::
(string) A description of the scheduled event.
`end_time`::
(date) The timestamp for the end of the scheduled event in milliseconds since
the epoch or ISO 8601 format.
`event_id`::
(string) An automatically-generated identifier for the scheduled event.
`start_time`::
(date) The timestamp for the beginning of the scheduled event in milliseconds
since the epoch or ISO 8601 format.
[[ml-get-calendar-event-example]]
== {api-examples-title}
[source,console]
--------------------------------------------------
GET _ml/calendars/planned-outages/events
--------------------------------------------------
// TEST[skip:setup:calendar_outages_addevent]
The API returns the following results:
[source,console-result]
----
{
  "count": 3,
  "events": [
    {
      "description": "event 1",
      "start_time": 1513641600000,
      "end_time": 1513728000000,
      "calendar_id": "planned-outages",
      "event_id": "LS8LJGEBMTCMA-qz49st"
    },
    {
      "description": "event 2",
      "start_time": 1513814400000,
      "end_time": 1513900800000,
      "calendar_id": "planned-outages",
      "event_id": "Li8LJGEBMTCMA-qz49st"
    },
    {
      "description": "event 3",
      "start_time": 1514160000000,
      "end_time": 1514246400000,
      "calendar_id": "planned-outages",
      "event_id": "Ly8LJGEBMTCMA-qz49st"
    }
  ]
}
----
// TESTRESPONSE[s/LS8LJGEBMTCMA-qz49st/$body.$_path/]
// TESTRESPONSE[s/Li8LJGEBMTCMA-qz49st/$body.$_path/]
// TESTRESPONSE[s/Ly8LJGEBMTCMA-qz49st/$body.$_path/]