# Add the OpenDoc "Book & pay now" button to a website

A complete install guide for practice staff and AI assistants. Web page version: https://opendoc.com/providers/website-button. This markdown copy: https://opendoc.com/providers/website-button.md.

Paste one snippet on your site. Patients tap it, OpenDoc opens, and they choose Book now, pay later or Pay cash now. It works on any website, with no setup and no developer.

## What the button does

- It is a link to `https://opendoc.com/book/<NPI>`. That page shows the provider's name and asks "How would you like to book?"
- **Book now, pay later.** The patient asks for a time, the office confirms it, then the patient pays.
- **Pay cash now.** The patient pays online at the cash price the provider posted on OpenDoc. This choice appears only when the provider has a posted price.
- Booking and payment run on opendoc.com, in a popup or a new tab. Nothing is framed inside your site.
- No website registration, allow-list, API key or developer is needed. It works on any domain.
- The button script does not read or send any patient data.

## What you need

1. The provider's 10-digit NPI (National Provider Identifier). There is one button per clinician. For a group practice, add one button per clinician. A single practice-wide button is not available yet.
2. The provider must already be on OpenDoc. Not yet? They can join free at https://opendoc.com/for-providers.
3. A way to edit the website: an HTML or code block, or at least a button you can point at a web address.

## Step 1: Find the NPI or the ready-made button code

Use the first option that works.

### Option A: Copy the button code from the OpenDoc dashboard (easiest)

1. Sign in to your OpenDoc dashboard and open Add to your website.
2. Pick the provider and copy the snippet. It already has the right NPI.
3. Paste it on your site where the button belongs (steps for your site builder below).
4. Publish, then click the button once to check it.

The page is https://opendoc.com/provider-dashboard/embed-setup (tab "Add to your website"). It needs the office's OpenDoc sign-in. It lists every clinician in the practice, with a preview, a "Copy snippet" button and a "Copy button link" button.

### Option B: Read it from the provider's OpenDoc page

Provider pages look like `https://opendoc.com/providers/jane-smith-md--YOUR_NPI`. The 10 digits after the last `--` are the NPI.

### Option C: Look it up

- OpenDoc search: https://opendoc.com/search
- OpenDoc public registry API (no key): `GET https://api.opendoc.com/npi?q=<name>&state=<two-letter state>`. Each result has `npi`, `displayName`, `organizationName`, `addressCity` and `addressState`.
- The federal NPI registry: https://npiregistry.cms.hhs.gov

Match the name, city and practice. If two people have similar names, ask the office. Never guess an NPI.

### Confirm the provider is on OpenDoc

```
curl -s -o /dev/null -w "%{http_code}\n" https://api.opendoc.com/providers/YOUR_NPI
```

- `200`: the provider is on OpenDoc and the button will work. The JSON `data.displayName` should be the right person.
- `404` (`not_found`): the provider is not on OpenDoc yet. The button would open a "This booking link isn't working" page. Have them join first.

## Step 2: The snippet

Replace `YOUR_NPI` with the 10-digit NPI. Change nothing else.

```html
<a href="https://opendoc.com/book/YOUR_NPI" target="_blank" rel="noopener" data-opendoc-button>Book &amp; pay now</a>
<script src="https://opendoc.com/opendoc-button.js" async></script>
```

If the site builder only lets you point its own button at a web address, use the button link instead:

```
https://opendoc.com/book/YOUR_NPI
```

Set that button to open in a new tab or new window.

## Attributes and options

| Part | Required | What it does |
| --- | --- | --- |
| `href="https://opendoc.com/book/<NPI>"` | Yes | The page the button opens. Keep the domain and path exactly. |
| `data-opendoc-button` | Yes, for the styled button and popup | Tells the script which links to turn into buttons. |
| `target="_blank" rel="noopener"` | Recommended | Opens a new tab when there is no popup. The script adds them if they are missing. |
| Link text | No | The words on the button. Default: `Book &amp; pay now`. Write `&amp;` for "&". |
| `data-style="none"` | No | Keeps your site's own link or button style. The popup still works. |
| `?service=<service id>` on the href | No | Shows only that service under "Pay cash now". The service id is the part after the last `--` in the provider's service page URL (`/providers/<provider>/services/<service>--<id>`), or `data.offerings[].providerHsoId` from the provider API. An id that matches no priced service is ignored. |
| `<script src="https://opendoc.com/opendoc-button.js" async>` | No | Styles the button and opens the popup. Without it the link still works and opens a new tab. Include it once per page. Including it twice is harmless. |

What the script changes on each `a[data-opendoc-button]`:

- Adds `src=website-button` and `site=<your hostname>` to the link so OpenDoc can count button visits. It does not overwrite values you set yourself. Do not add other tracking parameters.
- Adds the class `opendoc-button`, `role="button"` and `data-opendoc-ready="1"` (unless `data-style="none"`, which skips the class and role).
- Injects one `<style id="opendoc-button-style">`: a blue (#0B6BCB) rounded button, at least 44px tall, 16px semibold text. To restyle it, target `a.opendoc-button` with more specific CSS. The text color uses `!important`, so your override needs it too. Or use `data-style="none"`.

## Popup or new tab

- **Desktop, window at least 640px wide:** a centered popup about 480px wide opens. The patient's page stays open behind it. Every button reuses the same popup window.
- **Phones and windows under 640px:** a new tab.
- **Popup blocked:** the link's normal new tab opens instead. Nothing is lost.
- **Ctrl/Cmd/Shift/Alt-click or middle-click:** the browser's normal behavior (new tab or window).
- **No script** (removed by the site builder, or a builder button using the plain link): a new tab.
- **Inside a small embed frame** (for example the Wix code box): the frame is narrow, so expect a new tab.
- Never put https://opendoc.com/book/<NPI> inside an iframe. Booking and payment are built to run as a full page on opendoc.com.

## Where to paste it

### Wix

1. Open your site in the Wix Editor and go to the page where the button belongs.
2. Click Add (+), then Embed Code, then Embed HTML.
3. Choose Code, paste your snippet, and click Update.
4. Drag the box where you want the button, then Publish.
5. Or skip the code: add a Wix button, click Link, choose Web Address, paste your button link, and pick New Window.

- Wix shows embedded code inside a small frame. Make the box big enough for the whole button. From inside that frame the button usually opens a new tab instead of a popup. That is expected.
- Embedded code does not run in the Wix Editor preview. Check the published page.

### Squarespace

1. Edit the page and click Add Block (+) where the button belongs.
2. Choose Code.
3. Paste your snippet, make sure the mode is HTML, and click outside the block.
4. Save, then check the live page.
5. Or skip the code: add a Button block, paste your button link as the link, and turn on Open in New Tab.

- Some Squarespace plans do not run scripts in Code blocks. If the published button looks like a plain text link, use the Button block with your button link instead.

### WordPress

1. Edit the page and click the block inserter (+) where the button belongs.
2. Search for Custom HTML and add that block.
3. Paste your snippet.
4. Update or Publish the page.
5. Or skip the code: add a Buttons block, paste your button link as the link, and turn on Open in new tab.

- Some WordPress.com plans remove script tags. If the published button looks like a plain text link, use the Buttons block with your button link instead.
- Page builders (Elementor, Divi, Beaver Builder) have their own HTML or Code widget. Paste the snippet there.

### Raw HTML or any other website

1. Paste the snippet into the page's HTML where the button should appear.
2. If your site only lets you link a button, use your button link instead.

- Put the <a> tag exactly where the button should appear. The <script> tag can go anywhere on the page, for example just before </body>.
- Several buttons on one page (one per clinician) need only one <script> tag.
- If your site sends a Content-Security-Policy header, add https://opendoc.com to script-src, or leave the script out. The link works without it.
- Single-page apps (React, Vue and similar): render the <a> tag in your component and load the script once. Loading the script again re-scans the page for new buttons.

## Test it

1. Open https://opendoc.com/book/<NPI> in a browser. You should see the provider's name, "How would you like to book?", "Book now, pay later", and "Pay cash now" with a price if the provider posted one.
2. Publish the website page. Check the live page, not the editor preview. Many site builders do not run embedded code in the editor.
3. With the script, the link looks like a blue rounded button (unless `data-style="none"`). Inspect it: it should have `data-opendoc-ready="1"`, and its href should end with `src=website-button&site=<your hostname>`. That means the script ran.
4. Click it on a desktop: a popup opens. Click it on a phone: a new tab opens.
5. Stop at the choice page. Do not book a visit or pay just to test.

Quick checks from a terminal:

```
curl -sI https://opendoc.com/opendoc-button.js   # expect 200 and text/javascript
curl -s -o /dev/null -w "%{http_code}\n" https://api.opendoc.com/providers/<NPI>   # expect 200
```

## Troubleshooting

| What you see | Likely cause | Fix |
| --- | --- | --- |
| "This booking link isn't working" | Wrong NPI, a typo, `YOUR_NPI` left in, or the provider is not on OpenDoc | Check the NPI with the provider API (200 = good). Fix the href. |
| A plain text link, not a button | The script did not load: the builder strips scripts, the plan blocks them, a Content-Security-Policy blocks opendoc.com, or `data-opendoc-button` is missing | The link still works. Allow the script, or use the builder's own button with the button link. |
| Nothing shows in the editor | The builder does not run embedded code in preview | Publish and check the live page. |
| A new tab opens, not a popup | Phone, window under 640px, popup blocker, embed frame, or a modifier-click | Expected. The patient still gets the same page. |
| Only "Book now, pay later" shows | The provider has no posted cash price yet | Post a price in OpenDoc. "Pay cash now" then appears by itself. |
| Clicking does nothing | Another script or overlay on the site is catching the click | Test the plain button link. Remove the overlay or move the button. |
| The button clashes with the site | Default style | Add `data-style="none"`, or restyle `a.opendoc-button`. |
| The words show `&amp;` | The builder escaped the text twice | Type a plain "&" in the builder's text field, or use "and". |

## Rules for AI assistants doing the install

- Get the site owner's go-ahead before publishing a change to their website. Only edit sites you are allowed to edit.
- Use a real NPI confirmed by the provider API (200, with the right name). Never invent one, and never ship the placeholder.
- Keep the domain, path and attributes as given. Do not frame the booking page, rename the script, or self-host a copy of it.
- Do not add claims about insurance, privacy, safety or prices to the button or the text around it. Prices are shown on OpenDoc.
- If the provider is not on OpenDoc, stop and point them to the free signup. The button cannot work until they join.

## Questions

**What do patients see?** Your button opens OpenDoc in a small window or a new tab. Patients choose Book now, pay later (they ask for a time, your office confirms it, then they pay) or Pay cash now at the cash price you posted.

**What if I haven't posted a cash price?** The button still works. Patients see only Book now, pay later. Pay cash now appears by itself once you post a price on OpenDoc.

**Do I need to register my website or change any settings?** No. The button opens opendoc.com, so it works on any website without setup.

**Does it slow down my site?** No. The script is a few kilobytes, loads after your page, and only styles the button. Without it, the link still works.

**Can I change the words on the button?** Yes. Change the text between the <a> and </a> tags. Keep the rest the same.

**Can I use my own button style?** Yes. Add data-style="none" inside the <a> tag and style it like any link on your site, or link your site's own button to your button link.
