> ## 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.

# Book an appointment

> Runs every booking rule Docistra has: working hours, days off, breaks, clashes, queue days. Send `start` for a timed day or `date` for a queue (walk-in numbers) day. The patient is only messaged when `notify_patient` is true.



## OpenAPI

````yaml /openapi.json post /appointments
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:
  /appointments:
    post:
      tags:
        - Appointments
      summary: Book an appointment
      description: >-
        Runs every booking rule Docistra has: working hours, days off, breaks,
        clashes, queue days. Send `start` for a timed day or `date` for a queue
        (walk-in numbers) day. The patient is only messaged when
        `notify_patient` is true.
      operationId: createAppointment
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AppointmentCreate'
            example:
              external_id: A-55012
              doctor_id: ext:D-7
              branch_id: ext:B-1
              start: '2026-12-03T17:30:00+02:00'
              patient:
                external_id: P-10293
                name: Mona Samy
                phone: '01012345678'
              notify_patient: true
      responses:
        '201':
          description: Booked
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppointmentWrite'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
components:
  parameters:
    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:
    AppointmentCreate:
      type: object
      required:
        - doctor_id
      properties:
        external_id:
          type: string
          maxLength: 200
        patient_id:
          type: string
          description: An existing patient. Or send `patient`.
        patient:
          $ref: '#/components/schemas/PatientInput'
        doctor_id:
          type: string
        branch_id:
          type: string
          description: Defaults to where the doctor works that day.
        start:
          type: string
          format: date-time
          description: Timed day.
        date:
          type: string
          format: date
          description: Queue day (walk-in numbers).
        duration_minutes:
          type: integer
          minimum: 5
          maximum: 480
          multipleOf: 5
          description: Defaults to the doctor's session length.
        type:
          type: string
          enum:
            - reservation
            - follow_up
          default: reservation
        notes:
          type: string
          maxLength: 2000
        notify_patient:
          type: boolean
          default: false
          description: Send the booking confirmation on WhatsApp / SMS.
        enforce_schedule:
          type: boolean
          default: true
          description: >-
            Master-record organizations only: false skips the working-hours
            checks (clashes are still refused).
    AppointmentWrite:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Appointment'
        patient_notified:
          $ref: '#/components/schemas/PatientNotified'
    PatientInput:
      type: object
      properties:
        external_id:
          type:
            - string
            - 'null'
          maxLength: 200
        name:
          type: string
          maxLength: 200
          description: Required on create.
        phone:
          type:
            - string
            - 'null'
          description: >-
            Egyptian mobile in any spelling, or an international number starting
            with + or 00.
        contact_phone:
          type:
            - string
            - 'null'
        gender:
          type:
            - string
            - 'null'
          enum:
            - male
            - female
            - null
        date_of_birth:
          type:
            - string
            - 'null'
          format: date
        age:
          type:
            - integer
            - 'null'
          minimum: 0
          maximum: 130
        address:
          type:
            - string
            - 'null'
          maxLength: 500
        nationality:
          type:
            - string
            - 'null'
          description: Country code or name, e.g. EG / Egypt / مصر
        file_number:
          type:
            - string
            - 'null'
          maxLength: 30
        holder_id:
          type: string
          description: Create as a family member of this patient (create only).
        relationship:
          type:
            - string
            - 'null'
          enum:
            - son
            - daughter
            - wife
            - husband
            - father
            - mother
            - brother
            - sister
            - grandson
            - granddaughter
            - grandfather
            - grandmother
            - other
            - null
    Appointment:
      type: object
      properties:
        object:
          const: appointment
        id:
          type: string
          format: uuid
        external_id:
          type:
            - string
            - 'null'
        status:
          type: string
          enum:
            - reserved
            - arrived
            - in_progress
            - completed
            - cancelled
            - no_show
        type:
          type: string
          enum:
            - reservation
            - recheck
          description: recheck = a follow-up visit
        patient_id:
          type: string
        patient_external_id:
          type:
            - string
            - 'null'
        doctor_id:
          type: string
        doctor_external_id:
          type:
            - string
            - 'null'
        branch_id:
          type:
            - string
            - 'null'
        branch_external_id:
          type:
            - string
            - 'null'
        start:
          type: string
          format: date-time
        end:
          type:
            - string
            - 'null'
          format: date-time
        queue_number:
          type:
            - integer
            - 'null'
          description: Set on a queue day instead of a time.
        source:
          type:
            - string
            - 'null'
          description: >-
            Where it was booked: api, ai_chat (the AI agent), booking_page,
            staff, ...
        notes:
          type:
            - string
            - 'null'
        cancel_reason:
          type:
            - string
            - 'null'
        rescheduled_from_id:
          type:
            - string
            - 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    PatientNotified:
      type:
        - object
        - 'null'
      description: How the patient was told. null = not asked to.
      properties:
        via:
          type:
            - string
            - 'null'
          enum:
            - whatsapp_text
            - whatsapp_template
            - sms
            - null
        reason:
          type:
            - string
            - 'null'
          description: >-
            Why nothing was sent: no_phone, consent, test_org (the clinic is in
            test mode), no_channel, ...
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: slot_taken
      additionalProperties: true
  responses:
    BadRequest:
      description: Invalid input
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not found in this organization
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    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.