> ## Documentation Index
> Fetch the complete documentation index at: https://build.practicehub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples

> Complete, runnable integrations — each one a real flow end to end, with the calls, the payloads and the gotchas

Each example builds one integration from start to finish against a real clinic: the sequence of calls, the exact request and response shapes, what to store on your side, and where things go wrong in practice. They use the mechanisms explained in the guides — [querying](/guides/querying), [writing](/guides/writing), [booking](/guides/booking), [metadata](/guides/metadata), [webhooks](/guides/webhooks), [errors](/guides/errors) — so read those for the *why*; read these for the *how*.

<CardGroup cols={2}>
  <Card title="Online booking widget" icon="calendar-plus" href="/examples/booking-widget">
    TypeScript. Locations and types → free slots → find-or-create the patient → book with an idempotency key → handle a clash → cancel or move.
  </Card>

  <Card title="CRM sync" icon="arrows-rotate" href="/examples/crm-sync">
    Python. Initial backfill by cursor with `metadata` as the id map, then webhooks for incremental changes in both directions.
  </Card>

  <Card title="Accounting export" icon="file-invoice-dollar" href="/examples/accounting-export">
    PHP. Nightly invoices, line items, payments and allocations by `updated`; voids and refunds; money and timezone handled correctly.
  </Card>

  <Card title="Webhook receiver (coming soon)" icon="webhook" href="/examples/webhook-receiver">
    Node. Verify the signature, acknowledge fast, process idempotently, fetch the record behind a thin event.
  </Card>
</CardGroup>

Every snippet assumes two environment variables:

```bash theme={null}
export PRACTICEHUB_BASE_URL="https://your-clinic.your-region.practicehub.io/v3/api"
export PRACTICEHUB_API_KEY="phk_…"
```

Create the key under **Developers → API Keys** — read-only for the export and the receiver, read & write for the widget and the sync. Times you *send* are in the clinic timezone (`GET /me` tells you which); `created` / `updated` you *read* are UTC.
