> ## 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](/webhooks/introduction) and [Register Webhook](/webhooks/endpoint/register_webhook).

## 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"
      }
    ]
  }
}
```

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

<CodeGroup>
  ```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"
    }
  }
  ```
</CodeGroup>

<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.
</Warning>

***

## 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](/crm/endpoint/list_tests).                    |
| `…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.                                          |

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