# Get event calendar availability schedule

GET https://services.leadconnectorhq.com/calendars/schedules/event-calendar/{calendarId}

Retrieve the availability schedule for a specific event calendar. Returns the schedule associated with the calendar ID provided in the path.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `calendars.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `calendarId` | string | Yes | Unique identifier of the event calendar |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/calendars/schedules/event-calendar/{calendarId}": {
      "get": {
        "summary": "Get event calendar availability schedule",
        "operationId": "getEventCalendarAvailabilitySchedule",
        "description": "Retrieve the availability schedule for a specific event calendar. Returns the schedule associated with the calendar ID provided in the path.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "calendarId",
            "required": true,
            "in": "path",
            "description": "Unique identifier of the event calendar",
            "schema": {
              "example": "WvVX9LpvlBO6K506xLbp",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Schedule retrieved successfully for the event calendar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventCalendarScheduleWrapperDTO"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "User not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "404": {
            "description": "Event calendar or schedule with the specified ID was not found"
          }
        },
        "security": [
          {
            "bearer": [
              "calendars.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "EventCalendarScheduleWrapperDTO": {
        "type": "object",
        "properties": {
          "schedule": {
            "description": "The event calendar schedule",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "timezone": {
                    "type": "string",
                    "description": "Timezone for the schedule (IANA timezone identifier)",
                    "example": "America/New_York"
                  },
                  "rules": {
                    "description": "Schedule rules defining when the schedule is active",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "wday",
                            "date"
                          ],
                          "description": "Type of schedule rule - weekday (recurring) or date (specific date)",
                          "example": "wday"
                        },
                        "intervals": {
                          "description": "Time intervals for the rule (e.g., 9 AM to 5 PM)",
                          "example": [
                            {
                              "from": "09:00",
                              "to": "17:00"
                            }
                          ],
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "from": {
                                "type": "string",
                                "description": "Start time in HH:MM format (24-hour format)",
                                "example": "09:00",
                                "pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9]$"
                              },
                              "to": {
                                "type": "string",
                                "description": "End time in HH:MM format (24-hour format)",
                                "example": "17:00",
                                "pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9]$"
                              }
                            },
                            "required": [
                              "from",
                              "to"
                            ],
                            "title": "ScheduleIntervalDTO"
                          }
                        },
                        "date": {
                          "type": "string",
                          "description": "Specific date in YYYY-MM-DD format (only for date-type rules)",
                          "example": "2023-04-15",
                          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                        },
                        "day": {
                          "type": "string",
                          "enum": [
                            "sunday",
                            "monday",
                            "tuesday",
                            "wednesday",
                            "thursday",
                            "friday",
                            "saturday"
                          ],
                          "description": "Day of week (only for weekday-type rules)",
                          "example": "monday"
                        }
                      },
                      "required": [
                        "type",
                        "intervals"
                      ],
                      "title": "ScheduleRuleDTO"
                    },
                    "example": [
                      {
                        "type": "weekday",
                        "day": "monday",
                        "intervals": [
                          {
                            "from": "09:00",
                            "to": "17:00"
                          }
                        ]
                      }
                    ]
                  },
                  "calendarId": {
                    "type": "string",
                    "description": "Calendar ID associated with the schedule",
                    "example": "WvVX9LpvlBO6K506xLbp"
                  },
                  "dateAdded": {
                    "type": "string",
                    "description": "Information about who created the schedule",
                    "example": "2023-01-15T10:30:00.000Z"
                  },
                  "dateUpdated": {
                    "type": "string",
                    "description": "Information about who last updated the schedule",
                    "example": "2023-01-20T14:45:00.000Z"
                  }
                },
                "required": [
                  "timezone",
                  "rules",
                  "calendarId"
                ],
                "title": "EventCalendarScheduleResponseDTO"
              }
            ],
            "example": {
              "timezone": "America/New_York",
              "rules": [
                {
                  "type": "weekday",
                  "day": "monday",
                  "intervals": [
                    {
                      "from": "09:00",
                      "to": "17:00"
                    }
                  ]
                }
              ],
              "calendarId": "WvVX9LpvlBO6K506xLbp"
            }
          }
        },
        "required": [
          "schedule"
        ],
        "title": "EventCalendarScheduleWrapperDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/calendars/schedules/event-calendar/<calendarId>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/calendars/schedules/event-calendar/<calendarId>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/calendars/schedules/event-calendar/{calendarId}"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

response = requests.get(url, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/calendars/schedules/event-calendar/<calendarId>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/calendars/schedules/event-calendar/<calendarId>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/calendars/schedules/event-calendar/<calendarId>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/calendars/schedules/event-calendar/<calendarId>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/calendars/schedules/event-calendar/<calendarId>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
