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

# Save Doctor Schedule

> Create or fully replace the doctor's schedule — the submitted block set is the new truth

Full-replacement semantics: the submitted `workingDays` set replaces the
existing schedule. Requires **Manage** permission on the Appointments module.

Every block's `locationId` must be a location assigned to the doctor, and
blocks of the same day must not overlap — **same or different location** (the
doctor cannot be in two places at once). Violations return a localized `400`
with `code: VALIDATION_ERROR`.

## Path Parameters

<ParamField path="doctorId" type="string" required>The doctor's user ID</ParamField>

## Body

<ParamField body="workingDays" type="array" required>
  Schedule blocks (min 1). Each block: `day` (`monday`…`sunday`), `locationId`
  (must be assigned to the doctor), `startTime`/`endTime` (`"HH:MM"`, end after
  start), optional `lunchStartTime`/`lunchEndTime` (both or neither, inside the block).
</ParamField>

<ParamField body="exceptions" type="array">
  ISO 8601 dates. When omitted, existing exceptions are preserved.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.nevatal.com/api/v1/appointments/doctors/schedule/66dc441b8208f63a0269eecf" \
    -H "Authorization: Bearer nvtl_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "workingDays": [
        { "day": "thursday", "locationId": "696bdadfee83d82621f17748", "startTime": "08:00", "endTime": "12:00" },
        { "day": "thursday", "locationId": "69616b710ea6a551535841bb", "startTime": "14:00", "endTime": "17:00" }
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "success": true,
    "data": {
      "doctorId": "66dc441b8208f63a0269eecf",
      "workingDays": [
        { "day": "thursday", "locationId": "696bdadfee83d82621f17748", "locationName": "Pereira", "startTime": "08:00", "endTime": "12:00" },
        { "day": "thursday", "locationId": "69616b710ea6a551535841bb", "locationName": "Armenia", "startTime": "14:00", "endTime": "17:00" }
      ],
      "exceptions": []
    },
    "message": "Horario del doctor actualizado exitosamente"
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": "Bloques solapados el jueves: 08:00–12:00 (Pereira) y 11:00–15:00 (Armenia). El doctor no puede estar en dos sedes a la vez",
    "code": "VALIDATION_ERROR"
  }
  ```
</ResponseExample>
