Medos Booking Docs
Configure

init() options

The full reference for MedosBooking.init() and MedosBooking.open().

MedosBooking.init(config) bootstraps the widget. MedosBooking.open(config?) opens it as a modal (and accepts a partial config that merges with the last init call). MedosBooking.close() closes the modal.

Options

OptionTypeRequiredDefaultDescription
apiKeystringYesYour Medos publishable API key. See API keys.
mode"modal" | "inline"YesPick one. Modal opens over the page; inline mounts into containerId. See Modal vs inline.
containerIdstringRequired for inlineThe DOM id of the container element the widget mounts into. Ignored in modal mode.
theme"default" | "modern" | MedosTheme | PartialThemeNoAuto-fetchedTheme name, full theme object, or partial override. See Theming.
baseUrlstringNoProduction URLOverride the API base URL. Useful for staging or self-hosted deployments.
calendarOnlybooleanNofalseSkip the doctor-selection strip and go straight to the calendar.
medosDoctorIdstringNoPre-select a doctor by ID.
doctorInfoDoctorOverrideInfoNoOverride the fetched doctor's profile fields.
doctorInfoByDoctorIdRecord<string, DoctorOverrideInfo>NoPer-doctor profile overrides, keyed by doctor id.
onSuccess(data) => voidNoFired when a booking completes. Payload shape depends on system type — see Callbacks.
onError(error: Error) => voidNoFired on any recoverable error.
onClose() => voidNoFired when the modal closes (modal mode only).

Minimal example

MedosBooking.init({
  apiKey: "mk_your_publishable_key",
  mode: "modal",
});

Full example

MedosBooking.init({
  apiKey: "mk_your_publishable_key",
  mode: "inline",
  containerId: "medos-booking",
  theme: "modern",
  baseUrl: "https://api.medos.one/v1",
  calendarOnly: false,
  medosDoctorId: "doc-123",
  onSuccess: (data) => {
    console.log("Booked", data);
    // e.g. redirect the patient
    window.location.href = "/booking-confirmed";
  },
  onError: (err) => {
    console.error("Booking error", err);
  },
  onClose: () => {
    console.log("Modal closed");
  },
});

Methods

init(config)

Initializes the widget. Call once per page (or per iframe).

  • Modal mode: opens the modal immediately.
  • Inline mode: mounts into containerId.

Throws if:

  • apiKey is missing → "API key is required"
  • Inline mode with an unknown containerId"Container with id ... not found"

Call init() only once

Calling init() a second time mounts a second widget instance in the same container, which can double-render the booking UI. If you need to re-open, use open() in modal mode; if you need to re-render inline, clear the container's HTML first, then call init() again.

open(config?)

Opens the widget as a modal. The optional config argument merges into the last-known config, so you can call init() once and then open the modal later with just tweaks:

MedosBooking.init({ apiKey: "mk_..." });

// later, on a button click:
MedosBooking.open({ medosDoctorId: "doc-42" });

Throws if no apiKey has ever been set.

close()

Closes the currently open modal (no-op if the widget is inline or the modal isn't open). Fires onClose if it was provided.

DoctorOverrideInfo shape

Used by doctorInfo and doctorInfoByDoctorId to override profile fields the API returns.

interface DoctorOverrideInfo {
  fullName?: string;
  intro?: string;
  qualifications?: Array<{
    degree: string;
    institution?: string;
    year?: number;
  }>;
  awards?: string[];
  availableDays?: string;
  designation?: string;
  experience?: string;
  languages?: string[];
  registrationNumber?: string;
  registrationAuthority?: string;
  specialization?: string[];
  services?: string[];
  expertise?: string[];
  mode?: string[];
  gender?: string;
  profileImageUrl?: string;
  email?: string;
  phoneNumber?: string;
}

Any field you omit falls back to the API value. See Override doctor info for common patterns.

On this page