> ## 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.

# Events Response

> The exact JSON body Flabs POSTs to your endpoint for every webhook event.

This page shows the exact payload your endpoint receives for each of the 12 webhook events. Every field is described once in the [field reference](#field-reference) at the bottom.

For what each event means and how to subscribe, see [Webhooks](https://developer.flabslis.com/webhooks/introduction.md) and [Register Webhook](https://developer.flabslis.com/webhooks/endpoint/register_webhook.md).

## Bill events

### `bill.created`

Sent when a new bill is created.

```json theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "bill.created",
  "eventTime": 1738751400,
  "data": {
    "billID": "6710b8e4d2a91f3c5e77aa12",
    "integratorID": "EXT-ORDER-90231",
    "billData": {
      "status": "ongoing",
      "testData": [
        {
          "_id": "6530a4a6f1d2c8b7e9a11111",
          "status": "PENDING"
        },
        {
          "_id": "6530a4a6f1d2c8b7e9a22222",
          "status": "PENDING"
        }
      ]
    }
  }
}
```

### `bill.completed`

Sent when every report on the bill is finished and the bill moves to `completed` (or `delivered`).

```json theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "bill.completed",
  "eventTime": 1738755102,
  "data": {
    "billID": "6710b8e4d2a91f3c5e77aa12",
    "integratorID": "EXT-ORDER-90231",
    "billData": {
      "status": "completed",
      "testData": [
        {
          "_id": "6530a4a6f1d2c8b7e9a11111",
          "status": "COMPLETE",
          "testName": "Complete Blood Count (CBC)",
          "parameter": [
            {
              "parameterName": "Haemoglobin",
              "id": "6530a4a6f1d2c8b7e9a33333",
              "value": "13.4"
            },
            {
              "parameterName": "Total WBC Count",
              "id": "6530a4a6f1d2c8b7e9a44444?0",
              "value": "7200"
            }
          ]
        },
        {
          "_id": "6530a4a6f1d2c8b7e9a22222",
          "status": "COMPLETE",
          "testName": "Allergy Panel (Food)",
          "parameter": []
        }
      ]
    },
    "reportURL": "https://flabs-lab.s3.ap-south-1.amazonaws.com/report/6710b8e4d2a91f3c5e77aa12.pdf",
    "sampleImages": [
      {
        "url": "https://flabs-lab.s3.ap-south-1.amazonaws.com/sample/sample-image-1.jpg",
        "lat": 19.076,
        "lng": 72.8777,
        "capturedAt": "2025-02-05T07:52:14.318Z"
      },
      {
        "url": "https://flabs-lab.s3.ap-south-1.amazonaws.com/sample/sample-image-2.jpg",
        "lat": null,
        "lng": null,
        "capturedAt": "2025-02-05T07:53:02.771Z"
      }
    ],
    "patientData": {
      "designation": "Mr.",
      "firstName": "Rahul",
      "lastName": "Sharma",
      "age": "32",
      "ageType": "year",
      "gender": "male",
      "contact": "9876543210",
      "email": "rahul.sharma@example.com",
      "address": "14 MG Road, Bengaluru",
      "country_code": "91",
      "aadhaar_number": "",
      "insurance_number": "",
      "uhid": "UH-90231",
      "height": "176",
      "weight": "72",
      "date_of_birth": "1993-08-14T00:00:00+05:30"
    }
  }
}
```

### `bill.deleted`

Sent when a bill is deleted. The payload carries identifiers only — no `billData`, no `reportURL`, no test list.

```json theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "bill.deleted",
  "eventTime": 1738756800,
  "data": {
    "billID": "6710b8e4d2a91f3c5e77aa12",
    "integratorID": "EXT-ORDER-90231"
  }
}
```

## Report events

### `report.completed`

Sent each time an individual test on the bill is marked complete, while the bill as a whole is still unfinished.

```json theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "report.completed",
  "eventTime": 1738753200,
  "data": {
    "reportID": "6710b8e4d2a91f3c5e77aa12",
    "integratorID": "EXT-ORDER-90231",
    "reportData": {
      "status": "partial",
      "testData": [
        {
          "_id": "6530a4a6f1d2c8b7e9a11111",
          "status": "COMPLETE"
        },
        {
          "_id": "6530a4a6f1d2c8b7e9a22222",
          "status": "PENDING"
        }
      ]
    },
    "reportURL": "https://flabs-lab.s3.ap-south-1.amazonaws.com/report/6710b8e4d2a91f3c5e77aa12.pdf"
  }
}
```

## CRM events

All eight CRM events share the same shape.

### `lead.created`

Sent when a lead is created in the CRM. This is the only CRM event where `phase` is `lead`.

```json theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "lead.created",
  "eventTime": 1738747800,
  "integratorID": "EXT-LEAD-10231",
  "data": {
    "leadID": "6712c4f7a8b3e91d4f22cc09",
    "phase": "lead",
    "first_name": "Rahul"
  }
}
```

### `booking.created`

Sent when a booking is created directly, or when an existing lead is converted into a booking. In the conversion case `leadID` is unchanged and `phase` flips to `booking`.

```json theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "booking.created",
  "eventTime": 1738748400,
  "integratorID": "EXT-LEAD-10231",
  "data": {
    "leadID": "6712c4f7a8b3e91d4f22cc09",
    "phase": "booking",
    "first_name": "Rahul"
  }
}
```

### Booking lifecycle events

The six events below track a home-collection booking from assignment through completion or cancellation. The body is identical in every case — only `eventType` differs.

```json booking.phlebotomist_assigned theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "booking.phlebotomist_assigned",
  "eventTime": 1738749000,
  "integratorID": "EXT-LEAD-10231",
  "data": {
    "leadID": "6712c4f7a8b3e91d4f22cc09",
    "phase": "booking",
    "first_name": "Rahul"
  }
}
```

```json booking.phlebotomist_arrived theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "booking.phlebotomist_arrived",
  "eventTime": 1738750200,
  "integratorID": "EXT-LEAD-10231",
  "data": {
    "leadID": "6712c4f7a8b3e91d4f22cc09",
    "phase": "booking",
    "first_name": "Rahul"
  }
}
```

```json booking.phlebotomist_sample_collected theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "booking.phlebotomist_sample_collected",
  "eventTime": 1738750800,
  "integratorID": "EXT-LEAD-10231",
  "data": {
    "leadID": "6712c4f7a8b3e91d4f22cc09",
    "phase": "booking",
    "first_name": "Rahul"
  }
}
```

```json booking.phlebotomist_sample_submitted theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "booking.phlebotomist_sample_submitted",
  "eventTime": 1738751400,
  "integratorID": "EXT-LEAD-10231",
  "data": {
    "leadID": "6712c4f7a8b3e91d4f22cc09",
    "phase": "booking",
    "first_name": "Rahul"
  }
}
```

```json booking.rescheduled theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "booking.rescheduled",
  "eventTime": 1738748700,
  "integratorID": "EXT-LEAD-10231",
  "data": {
    "leadID": "6712c4f7a8b3e91d4f22cc09",
    "phase": "booking",
    "first_name": "Rahul"
  }
}
```

```json booking.cancelled theme={null}
{
  "labID": "665f2a1c9b4e7d1a2c3f4b01",
  "eventType": "booking.cancelled",
  "eventTime": 1738748900,
  "integratorID": "EXT-LEAD-10231",
  "data": {
    "leadID": "6712c4f7a8b3e91d4f22cc09",
    "phase": "booking",
    "first_name": "Rahul"
  }
}
```

> [!WARNING]
>
> `booking.phlebotomist_sample_submitted` also auto-creates the bill for that booking, so a `bill.created` delivery follows it, then `report.completed` and `bill.completed` for the same patient.

***

## Field reference

### Envelope

Present on every event.

| Field | Type | Description |
| - | - | - |
| `labID` | string | The Flabs lab (branch) the event belongs to. |
| `eventType` | string | The event name, one of the 12 above. |
| `eventTime` | integer | Unix timestamp in seconds, stamped when the delivery is dispatched. |
| `data` | object | Event-specific body. |

### Bill and report events

| Field | Type | Description |
| - | - | - |
| `data.billID` | string | The bill identifier. Sent on `bill.created`, `bill.completed` and `bill.deleted`. |
| `data.reportID` | string | `report.completed` only. Carries the bill identifier. |
| `data.integratorID` | string | Your identifier for the bill, sent at create time. |
| `data.billData` / `data.reportData` | object | Bill state. `billData` on bill events, `reportData` on `report.completed`. |
| `…testData` | array | Every test on the bill. Always present. |
| `…testData[]._id` | string | The catalogue test identifier, as returned by [List Tests](https://developer.flabslis.com/crm/endpoint/list_tests.md). |
| `…testData[].testName` | string | `bill.completed` only. Name of the test. Always present. |
| `…testData[].parameter` | array | `bill.completed` only. Entered result values. Always present; `[]` when the test has none, never `null`. |
| `…parameter[].parameterName` | string | Name of the parameter, e.g. `Haemoglobin`. |
| `…parameter[].id` | string | Parameter identifier. |
| `…parameter[].value` | string | The entered value. Always a string, including numeric results. |
| `data.reportURL` | string | Link to the bill's report PDF. |
| `data.sampleImages` | array | `bill.completed` only. Geo-tagged sample-collection photos. Always present; `[]` when there are none. |
| `data.sampleImages[].url` | string | Link to the captured photo. |
| `data.sampleImages[].lat` | number \| null | Latitude at capture time. `null` when GPS was unavailable; the key is always present. |
| `data.sampleImages[].lng` | number \| null | Longitude at capture time. `null` when GPS was unavailable; the key is always present. |
| `data.sampleImages[].capturedAt` | string | ISO 8601 capture timestamp. Omitted when it was never recorded. |
| `data.patientData` | object | `bill.completed` only. The patient the bill belongs to. See below. |

### Patient data

`bill.completed` only. Every key below is always present; a detail the lab never recorded is sent as an empty string, never `null` or omitted. Values are sent exactly as the lab stored them, so treat them as free text unless noted.

| Field | Type | Description |
| - | - | - |
| `data.patientData.designation` | string | Salutation, e.g. `Mr.`, `Mrs.`, `Dr.`. |
| `data.patientData.firstName` | string | Given name. |
| `data.patientData.lastName` | string | Family name. |
| `data.patientData.age` | string | Age in `ageType` units. Sent as a string, e.g. `"32"`. |
| `data.patientData.ageType` | string | Unit for `age`: `year`, `month` or `day`. Lowercase and singular. |
| `data.patientData.gender` | string | `male`, `female` or `other`. Always lowercase. |
| `data.patientData.contact` | string | Mobile number, without the country code. |
| `data.patientData.country_code` | string | Dial code for `contact`, with no `+` — e.g. `91` for India. |
| `data.patientData.email` | string | Email address. |
| `data.patientData.address` | string | Postal address as a single line. |
| `data.patientData.aadhaar_number` | string | Aadhaar number, when recorded. |
| `data.patientData.insurance_number` | string | Insurance/policy number, when recorded. |
| `data.patientData.uhid` | string | The lab's unique health ID for the patient. |
| `data.patientData.height` | string | Height as recorded, e.g. `176`. No unit is attached. |
| `data.patientData.weight` | string | Weight as recorded, e.g. `72`. No unit is attached. |
| `data.patientData.date_of_birth` | string | ISO 8601 with the `+05:30` IST offset, e.g. `1993-08-14T00:00:00+05:30`. Empty string when no date of birth is on file. |

> [!NOTE]
>
> `age` and `date_of_birth` are recorded independently. A patient can have an
> age with no date of birth, and the two are not recalculated against each
> other — use whichever your system needs, and prefer `date_of_birth` when both
> are present.

> [!WARNING]
>
> `patientData` carries personal and health information, including government
> identity numbers when the lab has recorded them. Store only the fields you
> need, and keep them encrypted in transit and at rest.

### CRM events

| Field | Type | Description |
| - | - | - |
| `integratorID` | string | Your identifier for the record, sent at create time. Should be unique. Omitted when empty. |
| `data.leadID` | string | Identifier of the lead or booking. Unchanged when a lead converts to a booking. |
| `data.phase` | string | `lead` or `booking`. Always `booking` on every `booking.*` event. |
| `data.first_name` | string | Patient's first name. Always present. |


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