Building blocksConfigure

init() options

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

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.

Want to try these before writing any code? Use the Playground — it generates the exact snippet as you change options.

Core

OptionTypeRequiredDefaultDescription
apiKeystringYesYour Medos publishable API key. See API keys.
mode"modal" | "inline"YesModal opens over the page; inline mounts into containerId. See Modal vs inline.
containerIdstringFor inlineDOM id of the element the widget mounts into. Ignored in modal mode.

Booking scope

OptionTypeDefaultDescription
externalMemberIdstringLock the widget to one doctor by their external member id. The picker is skipped. See Lock to a single doctor.
calendarOnlybooleanfalseStrip back to the calendar: no profile panel, picker, filters, or headers. See Calendar-only and compact.
compactbooleanfalseHide only the doctor profile panel; picker and headers stay. See Calendar-only and compact.
doctorInfoDoctorOverrideInfoOverride the fetched doctor's profile fields.
doctorInfoByDoctorIdRecord<string, DoctorOverrideInfo>Per-doctor profile overrides, keyed by doctor id.

Appearance

OptionTypeDefaultDescription
theme"default" | "modern" | MedosTheme | PartialTheme"default"Built-in theme name, a full theme object, or a partial override. See Theming.
primaryColorstringFrom themeBrand colour shortcut. Hover and active shades are derived automatically.
secondaryColorstringFrom themeSecondary brand colour. Hover shade derived automatically.
borderRadiusstring | numberFrom themeCorner radius for the widget's surfaces. A number is treated as px.
fontFamilystringFrom themeCSS font stack applied across the widget.
fontUrlstringStylesheet URL (e.g. Google Fonts) loaded so fontFamily resolves.

Brand shortcuts win over `theme`

primaryColor, secondaryColor, borderRadius, and fontFamily are top-level shortcuts that layer on top of whatever theme you pass. You can start from "modern" and just override the primary colour. See Brand colours.

Sizing

OptionTypeDefaultDescription
maxWidthnumber | string600px in modal modeCap the widget width. A number is treated as px.
maxHeightnumber | string90vh in modal modeCap the widget height; inner content scrolls. A number is treated as px.

See Sizing for guidance on picking values.

Callbacks

OptionTypeDescription
onSuccess(data?: any) => voidNot currently invoked. Intended payload depends on the booking flow — see onSuccess.
onError(error: Error) => voidFired when the initial workspace load fails. In-flow errors don't reach it — see onError.
onClose() => voidFired when the modal closes. Modal mode only.

There is no `baseUrl` option

The API endpoint is compiled into the widget bundle, so there's nothing to point anywhere. If you're carrying a baseUrl over from older config, delete it.

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",

  // appearance
  theme: "modern",
  primaryColor: "#4f46e5",
  secondaryColor: "#6366f1",
  borderRadius: 12,
  fontFamily: "'Inter', sans-serif",
  fontUrl:
    "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap",

  // sizing
  maxWidth: 900,
  maxHeight: 720,

  // booking scope
  externalMemberId: "your-doctor-external-id",
  calendarOnly: false,
  compact: false,

  // callbacks
  onSuccess: (data) => {
    console.log("Booked", data);
    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 without containerId"containerId is required for inline mode"
  • 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. To re-open in modal mode use open(). To re-render inline, clear the container's HTML first, then call init() again — or mount each instance in its own iframe (see Multiple instances).

open(config?)

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

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

// later, on a button click:
MedosBooking.open({ externalMemberId: "your-doctor-external-id" });

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