[role="xpack"]
[testenv="platinum"]
[[ml-get-calendar]]
= Get calendars API
++++
<titleabbrev>Get calendars</titleabbrev>
++++

Retrieves configuration information for calendars.

[[ml-get-calendar-request]]
== {api-request-title}

`GET _ml/calendars/<calendar_id>` +

`GET _ml/calendars/_all`

[[ml-get-calendar-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-desc]]
== {api-description-title}

You can get information for multiple calendars in a single API request by using a
comma-separated list of ids or a wildcard expression. You can get
information for all calendars by using `_all`, by specifying `*` as the
`<calendar_id>`, or by omitting the `<calendar_id>`.

For more information, see
{ml-docs}/ml-calendars.html[Calendars and scheduled events].

[[ml-get-calendar-path-parms]]
== {api-path-parms-title}

`<calendar_id>`::
(Required, string)
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=calendar-id]

[[ml-get-calendar-request-body]]
== {api-request-body-title}

`page`.`from`::
    (Optional, integer) Skips the specified number of calendars. Defaults to `0`.

`page`.`size`::
    (Optional, integer) Specifies the maximum number of calendars to obtain.
    Defaults to `0`.

[[ml-get-calendar-results]]
== {api-response-body-title}

The API returns an array of calendar resources, which have the following
properties:

`calendar_id`::
(string)
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=calendar-id]

`job_ids`::
(array) An array of {anomaly-job} identifiers. For example: `["total-requests"]`.

[[ml-get-calendar-example]]
== {api-examples-title}

[source,console]
--------------------------------------------------
GET _ml/calendars/planned-outages
--------------------------------------------------
// TEST[skip:setup:calendar_outages_addjob]

The API returns the following results:

[source,console-result]
----
{
  "count": 1,
  "calendars": [
    {
      "calendar_id": "planned-outages",
      "job_ids": [
        "total-requests"
      ]
    }
  ]
}
----
