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

# Replace weekly hours

> Replaces the hours at each listed branch (a branch with no days = not working there). Only when your system is the master record. If the new hours would leave booked patients outside them: 409 `has_booked_patients` with their appointment ids; move or cancel those first.



## OpenAPI

````yaml /openapi.json put /doctors/{id}/hours
openapi: 3.1.0
info:
  title: Docistra API
  version: 1.0.0
  description: >-
    Connect your software to Docistra in both directions. All times are ISO
    8601; Docistra's clinics run on Cairo time (Africa/Cairo). Every path {id}
    takes Docistra's id or `ext:<your id>`.
servers:
  - url: https://docistra.com/api/v1
security:
  - bearerAuth: []
tags:
  - name: Organization
  - name: Patients
  - name: Appointments
  - name: Availability
  - name: Doctors
  - name: Doctor schedule
  - name: Branches
  - name: Reference data
  - name: Webhooks
paths:
  /doctors/{id}/hours:
    parameters:
      - $ref: '#/components/parameters/Id'
    put:
      tags:
        - Doctor schedule
      summary: Replace weekly hours
      description: >-
        Replaces the hours at each listed branch (a branch with no days = not
        working there). Only when your system is the master record. If the new
        hours would leave booked patients outside them: 409
        `has_booked_patients` with their appointment ids; move or cancel those
        first.
      operationId: putDoctorHours
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HoursInput'
      responses:
        '200':
          description: Saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Hours'
        '409':
          $ref: '#/components/responses/Conflict'
components:
  parameters:
    Id:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: Docistra's id, or `ext:<your id>`.
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      schema:
        type: string
        maxLength: 255
      description: >-
        A unique value (e.g. a UUID) per operation. A retry with the same key
        returns the first response for 24 hours.
  schemas:
    HoursInput:
      type: object
      required:
        - branches
      properties:
        branches:
          type: array
          items:
            type: object
            required:
              - branch_id
            properties:
              branch_id:
                type: string
              mode:
                type: string
                enum:
                  - time
                  - queue
                default: time
              days:
                type: array
                items:
                  type: object
                  required:
                    - day_of_week
                    - start
                    - end
                  properties:
                    day_of_week:
                      type: integer
                      minimum: 0
                      maximum: 6
                      description: 0 = Sunday ... 6 = Saturday
                    start:
                      type: string
                      example: '16:00'
                    end:
                      type: string
                      example: '22:00'
                    max_queue:
                      type: integer
                      description: 'Queue mode: places per day.'
    Hours:
      type: object
      properties:
        doctor_id:
          type: string
        branches:
          type: array
          items:
            type: object
            properties:
              branch_id:
                type: string
              branch_external_id:
                type:
                  - string
                  - 'null'
              mode:
                type: string
              days:
                type: array
                items:
                  type: object
                  properties:
                    day_of_week:
                      type: integer
                    start:
                      type: string
                    end:
                      type: string
                    max_queue:
                      type:
                        - integer
                        - 'null'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: slot_taken
      additionalProperties: true
  responses:
    Conflict:
      description: >-
        The request clashes with the current state (slot taken, already linked,
        paid visit, ...)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your API key (dk_live_...), from Settings > Integrations > API in
        Docistra.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.