# Create Timeslots

Before using this guide you will need a developer account and an access token. You can contact us about creating a developer account [here](https://developer.zocdoc.com/?utm_medium=organicpro&utm_routing=API_Sender#api-form). To get an access token, review the [authentication and access tokens](/guides/authentication) guide.

## 1. Get NPIs

First you need to retrieve the list of active provider NPIs within your Zocdoc directory.

A Zocdoc directory is a developer-managed list of Zocdoc providers. Each developer account has at least one directory, and multiple directories can be created if needed to support your specific API use case.

The primary purpose of a directory is to define which providers are available for booking through your application. You can also use directories to explore the Zocdoc marketplace and identify providers you may want to include in your bookable directory.

## 2. Get provider information

There are three ways to retrieve provider-specific information:

details
summary
strong
Search by NPI
NPIs retrieved in the previous step can be used to fetch detailed provider information, including name, gender identity, spoken languages, specialties, visit reasons, and affiliated locations. Up to 50 NPIs can be queried in a single request.

details
summary
strong
Search by ZIP and specialty or visit reason
If you don’t have NPIs, you can search by ZIP code and specialty or visit reason to find providers. This is beneficial when looking by distance or specifc reason.

details
summary
strong
Search by provider location
You can also retrieve provider information using specific `provider_location_id`s. This is useful for patients who want to see a specific doctor at a specific location.

## 3. Create a provider's timeslots

Using the `location_id` and `provider_id` you can set all slots for a given provider and date, replacing any existing slots. Submitting an empty request body will remove all slots for the given date. Ensure all open timeslots are included in the array for each date, per request. Subsequent requests for a single date will override previous data.

UTC and IANA
`time_zone` must be a valid [IANA timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).


```json
{
  "$ref": "#/components/schemas/TimeslotPutRequest",
  "components": {
    "schemas": {
      "PatientType": {
        "type": "string",
        "description": "Whether or not the patient has been to the provider's practice.",
        "enum": [
          "existing",
          "new"
        ],
        "example": "new"
      },
      "TimeslotBaseRequest": {
        "description": "a bookable appointment start time for a particular provider",
        "type": "object",
        "required": [
          "provider_id",
          "start_time",
          "location_id",
          "time_zone"
        ],
        "properties": {
          "provider_id": {
            "type": "string",
            "description": "Provider id",
            "example": "pr_abc123-def456_wxyz7890"
          },
          "location_id": {
            "type": "string",
            "description": "Location id",
            "example": "lo_abc123-def456_wxyz7890"
          },
          "start_time": {
            "type": "string",
            "format": "date-time-local",
            "description": "the local date and time within the timezone. The seconds may be omitted.",
            "example": "2024-10-16T09:30:00"
          },
          "time_zone": {
            "type": "string",
            "description": "The IANA time zone id of the appointment. Must be valid.",
            "example": "America/New_York"
          },
          "allowed_visit_reason_ids": {
            "type": "array",
            "description": "Restrict the timeslot to these visit reasons. Both `null` and an empty array will not restrict the timeslot.\n\nCan work in conjunction with `excluded_visit_reason_ids`. `allowed_visit_reason_ids` are superceded by `excluded_visit_reason_ids`.\nSo if a visit reason is included in both `allowed_visit_reason_ids` and `excluded_visit_reason_ids`, the net effect is that visit reason\nbeing excluded.\n\n| allowed | excluded | => Result |\n| -----   | -------- | --------- |\n| null    | null     | all visit reasons allowed |\n| [A,B]   | null     | only A & B are allowed |\n| null    | [A,B]    | all visit reasons except A & B are allowed |\n| [A,B]   | [B,C]    | only A is allowed (C is irrelevant) |\n| [A,B]   | [A,B]    | No visit reasons allowed, unbookable timeslot |\n",
            "items": {
              "type": "string"
            },
            "example": [
              "pc_TlZW-r06U0W3pCsIGtSI5B"
            ]
          },
          "excluded_visit_reason_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "pc_TAZW-r16U0B3pZeIutSI3L"
            ],
            "description": "Exclude these visit reasons. Both `null` and an empty array means no visit reasons will be excluded.\n\nCan work in conjunction with `allowed_visit_reason_ids`. `allowed_visit_reason_ids` are superceded by `excluded_visit_reason_ids`.\nSo if a visit reason is included in both `allowed_visit_reason_ids` and `excluded_visit_reason_ids`, the net effect is that visit reason\nbeing excluded.\n\n| allowed | excluded | => Result |\n| -----   | -------- | --------- |\n| null    | null     | all visit reasons allowed |\n| [A,B]   | null     | only A & B are allowed |\n| null    | [A,B]    | all visit reasons except A & B are allowed |\n| [A,B]   | [B,C]    | only A is allowed (C is irrelevant) |\n| [A,B]   | [A,B]    | No visit reasons allowed, unbookable timeslot |\n"
          },
          "patient_type": {
            "$ref": "#/components/schemas/PatientType"
          }
        }
      },
      "TimeslotPutRequest": {
        "required": [
          "timeslots"
        ],
        "type": "object",
        "properties": {
          "timeslots": {
            "type": "array",
            "minItems": 0,
            "maxItems": 1500,
            "items": {
              "$ref": "#/components/schemas/TimeslotBaseRequest"
            }
          }
        }
      }
    }
  }
}
```