---
type: api
title: Create a calendar
description: ## Required authorization
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-ml-put-calendar
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-ml-put-calendar
products:
  - Elasticsearch Serverless
---

# Create a calendar

Availability:

## Paths

- `PUT` `/_ml/calendars/{calendar_id}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

- `calendar_id` (string Id)
  A string that uniquely identifies a calendar.

## Description



## Required authorization

* Cluster privileges: `manage_ml`

## Request Body

`application/json`

- `job_ids` ([] string Id) — optional
  An array of anomaly detection job identifiers.
- `description` (string) — optional
  A description of the calendar.

## Response

`application/json`

- `calendar_id` (string Id)
  A string that uniquely identifies a calendar.
- `description` (string)
  A description of the calendar.
- `job_ids` (string Ids)
  A list of anomaly detection job identifiers or group names.
## Code Examples

#### Console

```console
PUT _ml/calendars/planned-outages
```

#### JavaScript

```javascript
const response = await client.ml.putCalendar({
  calendar_id: "planned-outages",
});
```

#### Python

```python
resp = client.ml.put_calendar(
    calendar_id="planned-outages",
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_ml/calendars/planned-outages" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().putCalendar(p -> p
    .calendarId("planned-outages")
);
```

#### C#

```c#
var response = await client.MachineLearning.PutCalendarAsync(calendarId: "planned-outages");
```

#### PHP

```php
$resp = $client->ml()->putCalendar([
    "calendar_id" => "planned-outages",
]);
```

#### Ruby

```ruby
response = client.ml.put_calendar(
  calendar_id: "planned-outages"
)
```

