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

# Create Schedule

> ### Overview
Creates a schedule for an `entity_id` in a `location_id` — `entity_id` is your doctor id, `location_id` is your clinic id. A schedule holds booking config (overbooking limit, slot-duration mode) and, optionally, its timebounds (weekly / daily / repeat-weekly / repeat-daily / block rules) and a product assignment map, all in one call. This endpoint is primarily for setting the timebounds — the `s`/`e` windows a doctor is available in, and (for service-based schedules) the `conf_ids` bookable in each window.

### Duration-based vs. service-based schedules
`config.schedule_slot_config_enabled` decides how every bound's slots get sliced, and whether that bound may carry `conf_ids`:

- **Duration-based** (`schedule_slot_config_enabled: true`): requires at least one entry in `config.slot_durations`. Slots are sliced at a fixed length picked from `slot_durations`. Bounds in `timebounds` must **not** include `conf_ids` — sending any is rejected with `400`.
- **Service-based** (`schedule_slot_config_enabled` false or omitted): every bound must include `conf_ids` — the services bookable in that window. Valid ids come from the Service Configuration APIs (`Get Service Conf List`, `Get Service Conf Details`) for the schedule's `entity_id`; an id the entity doesn't own, or an empty list, is rejected with `400`. There is no schedule- level slot duration here — each slot is sliced using the `duration` stored on the attached service (`conf_id`), so different services in the same bound can produce differently-sized slots.

`product-widget` can only be assigned to one schedule per `(entity_id, location_id)` pair — a second assignment returns `409`.

### Notes & Considerations

Read more : ([API Reference - Get Appointment Slots](/api-reference/doc-tool/appointment-api/get-appointment-slots)) section — this API returns schedules assigned to `product-widget`.



## OpenAPI

````yaml post /schedule
openapi: 3.0.0
info:
  title: Ekacare API & Webhook Documentation
  contact: {}
  version: '1.0'
servers:
  - description: Production
    url: https://api.eka.care
  - description: Stage/Sandbox
    url: https://api.dev.eka.care
security: []
paths:
  /schedule:
    post:
      tags:
        - Appointment API
      summary: Create Schedule
      description: >-
        ### Overview

        Creates a schedule for an `entity_id` in a `location_id` — `entity_id`
        is your doctor id, `location_id` is your clinic id. A schedule holds
        booking config (overbooking limit, slot-duration mode) and, optionally,
        its timebounds (weekly / daily / repeat-weekly / repeat-daily / block
        rules) and a product assignment map, all in one call. This endpoint is
        primarily for setting the timebounds — the `s`/`e` windows a doctor is
        available in, and (for service-based schedules) the `conf_ids` bookable
        in each window.


        ### Duration-based vs. service-based schedules

        `config.schedule_slot_config_enabled` decides how every bound's slots
        get sliced, and whether that bound may carry `conf_ids`:


        - **Duration-based** (`schedule_slot_config_enabled: true`): requires at
        least one entry in `config.slot_durations`. Slots are sliced at a fixed
        length picked from `slot_durations`. Bounds in `timebounds` must **not**
        include `conf_ids` — sending any is rejected with `400`.

        - **Service-based** (`schedule_slot_config_enabled` false or omitted):
        every bound must include `conf_ids` — the services bookable in that
        window. Valid ids come from the Service Configuration APIs (`Get Service
        Conf List`, `Get Service Conf Details`) for the schedule's `entity_id`;
        an id the entity doesn't own, or an empty list, is rejected with `400`.
        There is no schedule- level slot duration here — each slot is sliced
        using the `duration` stored on the attached service (`conf_id`), so
        different services in the same bound can produce differently-sized
        slots.


        `product-widget` can only be assigned to one schedule per `(entity_id,
        location_id)` pair — a second assignment returns `409`.


        ### Notes & Considerations


        Read more : ([API Reference - Get Appointment
        Slots](/api-reference/doc-tool/appointment-api/get-appointment-slots))
        section — this API returns schedules assigned to `product-widget`.
      operationId: CreateSchedule
      parameters:
        - name: auth
          in: header
          description: ''
          required: true
          style: simple
          schema:
            type: string
            example: auth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  description: Schedule name. Required, non-empty.
                entity_id:
                  type: string
                  description: Doctor/entity id this schedule is scoped to.
                location_id:
                  type: string
                  description: Clinic/location id this schedule is scoped to.
                config:
                  type: object
                  properties:
                    overbooking_limit:
                      type: integer
                      minimum: 1
                    block_over_existing_bookings:
                      type: boolean
                    schedule_slot_config_enabled:
                      type: boolean
                      description: If true, `slot_durations` must be non-empty.
                    slot_durations:
                      type: array
                      items:
                        type: integer
                        minimum: 1
                        maximum: 1440
                      maxItems: 10
                      description: >-
                        Allowed slot durations in minutes (deduplicated and
                        sorted).
                timebounds:
                  type: object
                  description: >-
                    Availability rules to create alongside the schedule. Each
                    block below is independent — include only the rule types you
                    need.
                  properties:
                    weekly:
                      type: object
                      description: >-
                        Map keyed by weekday, `0`(Sunday)–`6`(Saturday), to that
                        day's bounds.
                      additionalProperties:
                        type: object
                        properties:
                          is_enabled:
                            type: boolean
                          bounds:
                            type: array
                            items:
                              type: object
                              properties:
                                s:
                                  type: integer
                                  description: >-
                                    Start time, military format (e.g. `900` =
                                    09:00).
                                e:
                                  type: integer
                                  description: >-
                                    End time, military format (e.g. `1300` =
                                    13:00).
                                conf_ids:
                                  type: array
                                  items:
                                    type: string
                                  description: service-conf ids bookable in this window.
                    daily:
                      type: object
                      description: >-
                        One-off, date-specific bounds. Keyed by ISO date
                        (`YYYY-MM-DD`).
                      additionalProperties:
                        type: object
                        properties:
                          is_enabled:
                            type: boolean
                          bounds:
                            type: array
                            items:
                              type: object
                              properties:
                                s:
                                  type: integer
                                e:
                                  type: integer
                                conf_ids:
                                  type: array
                                  items:
                                    type: string
                    repeat-weekly:
                      type: array
                      description: >-
                        Recurring weekly rules — a cycle of `repeat_every`
                        weeks, each with its own bounds via `phases`.
                      items:
                        type: object
                        properties:
                          repeat_every:
                            type: integer
                            description: >-
                              Cycle length in weeks. `phases` must have this
                              many entries.
                          anchor_date:
                            type: string
                            description: >-
                              ISO date the cycle is anchored to (phase 0 starts
                              here).
                          start_date:
                            type: string
                          end_date:
                            type: string
                            description: Optional. Omit for an indefinitely recurring rule.
                          phases:
                            type: array
                            description: >-
                              One weekly schedule per cycle week, same shape as
                              `weekly`.
                            items:
                              type: object
                    repeat-daily:
                      type: array
                      description: >-
                        Recurring daily rules — a cycle of `repeat_every` days
                        where phase `phase_index` is active.
                      items:
                        type: object
                        properties:
                          phase_index:
                            type: integer
                          repeat_every:
                            type: integer
                          anchor_date:
                            type: string
                          start_date:
                            type: string
                          end_date:
                            type: string
                          is_enabled:
                            type: boolean
                          bounds:
                            type: array
                            items:
                              type: object
                              properties:
                                s:
                                  type: integer
                                e:
                                  type: integer
                                conf_ids:
                                  type: array
                                  items:
                                    type: string
                    block:
                      type: array
                      description: Blackout windows — no slots are resolved inside these.
                      items:
                        type: object
                        properties:
                          start_date:
                            type: string
                            description: ISO date.
                          end_date:
                            type: string
                            description: ISO date.
                          start_time:
                            type: string
                            description: '`HH:mm`, 24h.'
                          end_time:
                            type: string
                            description: '`HH:mm`, 24h.'
                productMap:
                  type: object
                  description: >-
                    Assigns/unassigns this schedule to products. Keys are
                    `product-emr` or `product-widget`, values are `true` to
                    assign, `false` to unassign. `product-widget` allows only
                    one active schedule per `(entity_id, location_id)`.
                  additionalProperties:
                    type: boolean
              example:
                name: Dr. Sharma - OPD
                entity_id: doc_12345
                location_id: c-98765
                config:
                  overbooking_limit: 2
                  schedule_slot_config_enabled: true
                  slot_durations:
                    - 15
                    - 30
                timebounds:
                  weekly:
                    '1':
                      is_enabled: true
                      bounds:
                        - s: 900
                          e: 1300
                          conf_ids:
                            - conf_abc123
                        - s: 1400
                          e: 1800
                          conf_ids:
                            - conf_abc123
                    '2':
                      is_enabled: true
                      bounds:
                        - s: 900
                          e: 1300
                          conf_ids:
                            - conf_abc123
                  daily:
                    '2026-10-15':
                      is_enabled: true
                      bounds:
                        - s: 1000
                          e: 1200
                          conf_ids:
                            - conf_abc123
                  repeat-weekly:
                    - repeat_every: 2
                      anchor_date: '2026-09-21'
                      start_date: '2026-09-21'
                      end_date: '2027-03-21'
                      phases:
                        - '3':
                            is_enabled: true
                            bounds:
                              - s: 1600
                                e: 1900
                                conf_ids:
                                  - conf_abc123
                        - '3':
                            is_enabled: false
                            bounds: []
                  repeat-daily:
                    - phase_index: 0
                      repeat_every: 3
                      anchor_date: '2026-09-21'
                      start_date: '2026-09-21'
                      end_date: '2026-12-31'
                      is_enabled: true
                      bounds:
                        - s: 900
                          e: 1100
                          conf_ids:
                            - conf_abc123
                  block:
                    - start_date: '2026-10-20'
                      end_date: '2026-10-22'
                      start_time: '09:00'
                      end_time: '18:00'
                productMap:
                  product-emr: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      schedule_id:
                        type: string
                      business_id:
                        type: string
                      name:
                        type: string
                      archive:
                        type: boolean
                      default:
                        type: boolean
                      userCreatedDefault:
                        type: boolean
                      config:
                        type: object
                        properties:
                          overbooking_limit:
                            type: integer
                          block_over_existing_bookings:
                            type: boolean
                          schedule_slot_config_enabled:
                            type: boolean
                          slot_durations:
                            type: array
                            items:
                              type: integer
                      createdAt:
                        type: string
                      updatedAt:
                        type: string
                      timebounds:
                        type: object
                        description: Report of timebound rows created, keyed by rule type.
                      assignment:
                        type: object
                        properties:
                          products:
                            type: array
                            items:
                              type: string
                          error:
                            type: string
                      confs_created:
                        type: array
                        items:
                          type: string
                        description: >-
                          service-conf ids created as part of the product
                          assignment, if any.
        '400':
          description: >-
            Bad Request — validation failure (e.g. missing `name`, invalid
            `config`/`timebounds`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: name is required
        '409':
          description: >-
            Conflict — `product-widget` already assigned to another schedule for
            this `(entity_id, location_id)`
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
      deprecated: false

````