> ## Documentation Index
> Fetch the complete documentation index at: https://developers.leadwaycrm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Free Slots

> Get free slots for a calendar between a date range. Optionally a consumer can also request free slots in a particular timezone and also for a particular user.

Get free slots for a calendar between a date range. Optionally a consumer can also request free slots in a particular timezone and also for a particular user.

```http theme={null}
GET https://services.leadconnectorhq.com/calendars/{calendarId}/free-slots
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Path parameters

<ParamField path="calendarId" type="string" required default="ocQHyuzHvysMo5N5VsXc">
  Calendar Id
</ParamField>

## Query parameters

<ParamField query="startDate" type="number" required default="1548898600000">
  Start Date (**⚠️ Important:** Date range cannot be more than 31 days)
</ParamField>

<ParamField query="endDate" type="number" required default="1601490599999">
  End Date (**⚠️ Important:** Date range cannot be more than 31 days)
</ParamField>

<ParamField query="timezone" type="string" default="America/Chihuahua">
  The timezone in which the free slots are returned
</ParamField>

<ParamField query="userId" type="string" default="082goXVW3lIExEQPOnd3">
  The user for whom the free slots are returned
</ParamField>

<ParamField query="userIds" type="string[]">
  The users for whom the free slots are returned
</ParamField>

## Respuestas

<Accordion title="200 - Availability map keyed by date (YYYY-MM-DD)">
  ```json theme={null}
  {
    "2024-10-28": {
      "slots": [
        "2024-10-28T10:00:00-05:00",
        "2024-10-28T11:00:00-05:00"
      ]
    },
    "2024-10-29": {
      "slots": [
        "2024-10-29T10:00:00-05:00",
        "2024-10-29T14:30:00-05:00"
      ]
    }
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET 'https://services.leadconnectorhq.com/calendars/YOUR_calendarId/free-slots' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/calendars/YOUR_calendarId/free-slots', {
    method: 'GET',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
    },
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'GET',
      'https://services.leadconnectorhq.com/calendars/YOUR_calendarId/free-slots',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
      },
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/calendars/YOUR_calendarId/free-slots');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'GET',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
      ],
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
