# Calendars requests

> The following GET request to the `/odata/Calendars` endpoint retrieves a specific calendar based on its `Name`.

## Retrieving calendars according to their name

The following GET request to the `/odata/Calendars` endpoint retrieves a specific calendar based on its `Name`.

GET

`https://{yourDomain}/odata/Calendars?$filter=Name%20eq%20'BankHoliday'`

### Request headers

| Key | Value |
| --- | --- |
| Authorization | Bearer |

### Response code

200 OK

### Response body

```
{
  "@odata.context": "https://{yourDomain}/odata/$metadata#Calendars",
  "value": [
    {
      "TimeZoneId": null,
      "ExcludedDates": [],
      "Name": "BankHoliday",
      "Id": 18845
    }
  ]
}
```

## Creating a calendar

The following POST request to the `/odata/Calendars` endpoint enables you to create a new calendar with an excluded date.

:::note
The `Id` parameter is automatically generated. The `TimeZoneId` parameter is populated with the tenant's timezone.
:::

POST

`https://{yourDomain}/odata/Calendars`

### Request headers

| Key | Value |
| --- | --- |
| Authorization | Bearer |

### Request body

```
{
  "Name": "VacationCal",
  "TimeZoneId": "string",
  "ExcludedDates": [
    "2019-11-12T14:31:44.778Z"
  ]
}
```

### Response code

200 OK

### Response body

```
{
  "@odata.context": "https://{yourDomain}/odata/$metadata#Calendars/$entity",
  "TimeZoneId": "GTB Standard Time",
  "ExcludedDates": [
    "2019-11-12T00:00:00Z"
  ],
  "Name": "VacationCal",
  "Id": 32718
}
```

## Retrieving excluded dates of a calendar

The GET `/odata/Calendars({calendar_id_value})` endpoint retrieves the excluded dates of the specified calendar.

Use the calendar `Id` to specify the calendar from which you want to retrieve the excluded dates.

To find out the `Id`s of the existing calendars in your tenant, make a GET request to the `/odata/Calendars` endpoint first.

Identify the desired calendar and copy the `Id` value from the response body.

GET

`https://{yourDomain}/odata/Calendars`

### Request headers

| Key | Value |
| --- | --- |
| Authorization | Bearer |

### Response code

200 OK

### Response body

```
{
    "@odata.context": "https://{yourDomain}/odata/$metadata#Calendars",
    "value": [
        {
            "TimeZoneId": null,
            "ExcludedDates": [],
            "Name": "November_excluded_dates",
            "Id": 1461
        }
    ]
}
```

To see the excluded dates, make a GET request to the `/odata/Calendars({calendar_id_value})`.

Replace `{calendar_id_value}` with the previously copied `Id` value.

The response body returns all the dates that have been excluded in the specified calendar.

For example, for the calendar with the ID value of `1461`, the request looks like below:

GET

`https://{yourDomain}/odata/Calendars(1461)`

### Request headers

| Key | Value |
| --- | --- |
| Authorization | Bearer |

### Response code

200 OK

### Response body

```
{
    "@odata.context": "https://{yourDomain}/odata/$metadata#Calendars/$entity",
    "TimeZoneId": "UTC",
    "ExcludedDates": [
        "2021-11-01T00:00:00Z",
        "2021-11-04T00:00:00Z",
        "2021-11-08T00:00:00Z",
        "2021-11-11T00:00:00Z",
        "2021-11-15T00:00:00Z",
        "2021-11-18T00:00:00Z",
        "2021-11-22T00:00:00Z",
        "2021-11-25T00:00:00Z"
    ],
    "Name": "November_excluded_dates",
    "Id": 1461
}
```
