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

# CRM

> Push leads and bookings into the Flabs CRM from your own funnels.

The CRM API has four endpoints. Use them in this order:

```mermaid theme={null}
flowchart TB
    A[POST /client/auth/token]
    B[GET /client/labs<br/>pick a branchID]
    C[GET /client/crm/tests<br/>?branchID=...]
    D[GET /client/crm/packages<br/>?branchID=...]
    E[POST /client/crm/lead/create]
    F{phase}
    G[Telecaller picks it up<br/>and converts it into a booking]
    H[Booking is scheduled<br/>and shows up in the phlebo app]

    A --> B
    B --> C
    B --> D
    C --> E
    D --> E
    E --> F
    F -->|lead| G
    F -->|booking| H
```

## Integration modes

Your account runs in one of two modes. Most accounts use **catch-all** — this page covers it. If your business routes work per referring corporate, doctor, or hospital, use **party-scoped**.

> [card] Catch-all (default)
>
> No party needed. Tests/packages return standard branch pricing, and one webhook receives every event for the lab. **This page.**

> [card] [Party-scoped (B2B)](https://developer.flabslis.com/crm/party-scoped.md)
>
> For a doctor's CRM, a hospital portal, a wellness app, or a corporate health dashboard. Every lead, booking, and price is tied to a corporate / doctor / hospital, and each gets its own webhook. Enabled by Flabs — contact support.

## Endpoints

> [card] [List Branches](https://developer.flabslis.com/crm/endpoint/list_branches.md)
>
> Fetch the branches under your account.

> [card] [List Tests](https://developer.flabslis.com/crm/endpoint/list_tests.md)
>
> Fetch every test offered by a branch.

> [card] [List Packages](https://developer.flabslis.com/crm/endpoint/list_packages.md)
>
> Fetch every package offered by a branch.

> [card] [Create Lead or Booking](https://developer.flabslis.com/crm/endpoint/create_lead.md)
>
> Create a CRM entry. Phase decides whether it's a lead or a booking.

## Lead vs Booking

| | Lead (default) | Booking |
| - | - | - |
| `phase` | `"lead"` | `"booking"` |
| Auto-assign | ✅ telecaller | ❌ |
| Notification | `NEW_LEAD` | `BOOKING_CONFIRMED` |
| Required booking fields | – | `bookingType`, `scheduledAt` |
| Defaults set by server | – | `bookingStatus: Scheduled`, `paymentStatus: Pending`, `convertedAt: now` |

## Rules to know

* **`integratorID` is required** — every `create` call must include your own unique `integratorID` for the entry. It is stored on the lead/booking, carried onto the bill when it converts, and echoed back in webhooks so you can match events to your records.
* **Branch scope** — every CRM call needs a `branchID`. Get it from `GET /client/labs`.
* **Duplicates** — if a lead or booking with the same `contact` (or `email`) was already ingested **today** for your account, the API returns `409 Conflict`.
* **Auto-assign** — runs only when `phase = "lead"` and `assignedTo` is not set in the body. Honours the strategy you've configured in CRM settings.
* **Rate limit** — 60 requests/minute per account on every CRM endpoint.

> [!NOTE]
>
> Fields not listed in the request schema are silently ignored. Send only what
> you need.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.