# List user availability schedule

GET https://services.leadconnectorhq.com/calendars/schedules/search

Retrieve user availability schedules based on various filters including location, calendar, and user. Supports pagination.

## 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 |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location ID to filter schedules by |
| `userId` | string | Yes | User ID to filter schedules by specific user |
| `calendarId` | string | No | Calendar ID for filtering schedules by specific calendar |
| `skip` | number | No | Number of items to skip for pagination |
| `limit` | number | No | Maximum number of items to return (max 500) |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/calendars/schedules/search": {
      "get": {
        "summary": "List user availability schedule",
        "operationId": "listUserAvailabilitySchedule",
        "description": "Retrieve user availability schedules based on various filters including location, calendar, and user. Supports pagination.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location ID to filter schedules by",
            "schema": {
              "example": "IkqiJlXJ7o9h61tCHHod",
              "type": "string"
            }
          },
          {
            "name": "userId",
            "required": true,
            "in": "query",
            "description": "User ID to filter schedules by specific user",
            "schema": {
              "example": "IkqiJlXJ7o9h61tCHHod",
              "type": "string"
            }
          },
          {
            "name": "calendarId",
            "required": false,
            "in": "query",
            "description": "Calendar ID for filtering schedules by specific calendar",
            "schema": {
              "example": "WvVX9LpvlBO6K506xLbp",
              "type": "string"
            }
          },
          {
            "name": "skip",
            "required": false,
            "in": "query",
            "description": "Number of items to skip for pagination",
            "schema": {
              "minimum": 0,
              "default": 0,
              "example": 0,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Maximum number of items to return (max 500)",
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "default": 50,
              "example": 50,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Schedules retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAllSchedulesResponseDTO"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        },
        "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": {
      "GetAllSchedulesResponseDTO": {
        "type": "object",
        "properties": {
          "schedules": {
            "description": "Array of schedules",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Unique identifier for the schedule",
                  "example": "IkqiJlXJ7o9h61tCHHod"
                },
                "name": {
                  "type": "string",
                  "description": "Human-readable name for the schedule",
                  "example": "Business Hours Schedule"
                },
                "locationId": {
                  "type": "string",
                  "description": "Location ID where this schedule applies",
                  "example": "IkqiJlXJ7o9h61tCHHod"
                },
                "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"
                        }
                      ]
                    }
                  ]
                },
                "timezone": {
                  "type": "string",
                  "description": "Timezone for the schedule (IANA timezone identifier)",
                  "example": "America/New_York"
                },
                "dateAdded": {
                  "type": "string",
                  "description": "ISO date string when the schedule was created",
                  "example": "2023-01-15T10:30:00.000Z"
                },
                "dateUpdated": {
                  "type": "string",
                  "description": "ISO date string when the schedule was last updated",
                  "example": "2023-01-20T14:45:00.000Z"
                },
                "userId": {
                  "type": "string",
                  "description": "User ID associated with the schedule",
                  "example": "IkqiJlXJ7o9h61tCHHod"
                },
                "calendarIds": {
                  "description": "Calendar IDs associated with the schedule",
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "example": [
                    "WvVX9LpvlBO6K506xLbp"
                  ]
                },
                "deleted": {
                  "type": "boolean",
                  "description": "Whether the schedule has been deleted",
                  "example": false
                }
              },
              "required": [
                "id",
                "name",
                "locationId",
                "rules",
                "timezone",
                "dateAdded",
                "dateUpdated",
                "userId",
                "deleted"
              ],
              "title": "ScheduleObjectResponseDTO"
            },
            "example": [
              {
                "id": "IkqiJlXJ7o9h61tCHHod",
                "name": "Business Hours Schedule",
                "locationId": "ocQHyuzHvysMo5N5VsXc"
              }
            ]
          }
        },
        "required": [
          "schedules"
        ],
        "title": "GetAllSchedulesResponseDTO"
      },
      "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/search?locationId=<LOCATIONID>&userId=<USERID>' \
  -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/search?locationId=<LOCATIONID>&userId=<USERID>', 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/search"

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

params = {
    "locationId": "<LOCATIONID>",
    "userId": "<USERID>"
}

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

**PHP**

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

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/calendars/schedules/search?locationId=<LOCATIONID>&userId=<USERID>',
  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/search?locationId=<LOCATIONID>&userId=<USERID>")
  .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/search?locationId=<LOCATIONID>&userId=<USERID>"
  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/search?locationId=<LOCATIONID>&userId=<USERID>")

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/search?locationId=<LOCATIONID>&userId=<USERID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
