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
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | — | Your Medos publishable API key. See API keys. |
mode | "modal" | "inline" | Yes | — | Pick one. Modal opens over the page; inline mounts into containerId. See Modal vs inline. |
containerId | string | Required for inline | — | The DOM id of the container element the widget mounts into. Ignored in modal mode. |
theme | "default" | "modern" | MedosTheme | PartialTheme | No | Auto-fetched | Theme name, full theme object, or partial override. See Theming. |
baseUrl | string | No | Production URL | Override the API base URL. Useful for staging or self-hosted deployments. |
calendarOnly | boolean | No | false | Skip the doctor-selection strip and go straight to the calendar. |
medosDoctorId | string | No | — | Pre-select a doctor by ID. |
doctorInfo | DoctorOverrideInfo | No | — | Override the fetched doctor's profile fields. |
doctorInfoByDoctorId | Record<string, DoctorOverrideInfo> | No | — | Per-doctor profile overrides, keyed by doctor id. |
onSuccess | (data) => void | No | — | Fired when a booking completes. Payload shape depends on system type — see Callbacks. |
onError | (error: Error) => void | No | — | Fired on any recoverable error. |
onClose | () => void | No | — | Fired 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:
apiKeyis 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.