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

# Webhooks

> Reference for webhook events triggered during walk-in order lifecycle changes, with example payload structures.

The following webhook events are of interest when placing a Walk-in order. These are
described in detail in the following sections.

## Order webhook events

Based on the status present in [`Order Lifecycle`](/lab/walk-in/order-lifecycle),
Junction will trigger two kinds of webhook events, [`labtest.order.created`](/event-catalog/labtest.order.created) and
[`labtest.order.updated`](/event-catalog/labtest.order.updated).

The `labtest.order.created` event is triggered when an order is created in the system,
having the `ordered` status, and all subsequent status changes will trigger a `labtest.order.updated` event in the system.

<Note>The `partial_results` status does not trigger a Webhook unless specifically requested from Junction.</Note>

The webhook payload body will have the following information if the Order is in the `completed` status:

```json Walk-in Order Updated theme={null}
{
  "id": "84d96c03-6b1c-4226-ad8f-ef44a6bc08af",
  "team_id": "6353bcab-3526-4838-8c92-063fa760fb6b",
  "user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "patient_details": { "dob": "2020-01-01", "gender": "male" },
  "patient_address": {
    "receiver_name": "John Doe",
    "first_line": "123 Main St.",
    "second_line": "Apt. 208",
    "city": "San Francisco",
    "state": "CA",
    "zip": "91189",
    "country": "United States",
    "phone_number": "+1123456789"
  },
  "details": {
    "type": "walk_in_test",
    "data": {
      "id": "a655f0e4-6405-4a1d-80b7-66f06c2108a7",
      "created_at": "2020-01-01T00:00:00Z",
      "updated_at": "2020-01-01T00:00:00Z"
    }
  },
  "sample_id": "123456789",
  "notes": "This is a note",
  "created_at": "2020-01-01T00:00:00Z",
  "updated_at": "2020-01-01T00:00:00Z",
  "status": "completed",
  "events": [
    {
      "id": 1,
      "created_at": "2022-01-01T00:00:00Z",
      "status": "received.walk_in_test.ordered"
    },
    {
      "id": 2,
      "created_at": "2022-01-02T00:00:00Z",
      "status": "received.walk_in_test.requisition_created"
    },
    {
      "id": 3,
      "created_at": "2022-01-03T00:00:00Z",
      "status": "collecting_sample.walk_in_test.appointment_pending"
    },
    {
      "id": 4,
      "created_at": "2022-01-03T00:00:00Z",
      "status": "collecting_sample.walk_in_test.appointment_scheduled"
    },
    {
      "id": 5,
      "created_at": "2022-01-04T00:00:00Z",
      "status": "sample_with_lab.walk_in_test.partial_results"
    },
    {
      "id": 6,
      "created_at": "2022-01-04T00:00:00Z",
      "status": "completed.walk_in_test.completed"
    }
  ],
  "origin": "initial",
  "order_transaction": {
    "id": "6424dd45-ee1a-49c6-ad0c-5769b8e03fc1",
    "status": "completed",
    "orders": [
      {
        "id": "84d96c03-6b1c-4226-ad8f-ef44a6bc08af",
        "created_at": "2020-01-01T00:00:00Z",
        "updated_at": "2022-01-04T00:00:00Z",
        "low_level_status": "completed",
        "low_level_status_created_at": "2022-01-04T00:00:00Z",
        "origin": "initial"
      }
    ]
  }
}
```

## Appointment webhook events

Based on the status present in [`Order and Appointment Lifecycle - Appointment Lifecycle`](/lab/walk-in/order-lifecycle#appointment-lifecycle),
Junction will trigger the [`labtest.appointment.updated`](/event-catalog/labtest.appointment.updated) webhook event.

<Info>
  If the ability to [schedule appointments before a requisition has been created](/lab/walk-in/order-lifecycle#scheduling-appointments-before-a-requisition-has-been-created) is enabled for your team, and you intend to send patient communications for appointment updates, use the `labtest.appointment.updated` event. See more on communications for this feature [here](/lab/walk-in/communications#scheduling-appointments-before-a-requisition-has-been-created).
</Info>

The webhook payload body may have the following information if the appointment is in the `scheduled` status, after a **reschedule** has happened:

```json Walk-in Appointment Updated theme={null}
{
  "event_type": "labtest.appointment.updated",
  "data": {
    "id": "06c2c65b-74a0-4f25-a4a9-44f796296355",
    "user_id": "acf79a82-0c2c-4ca0-998b-378931793905",
    "order_id": "1ed9c8d7-e1b4-4d61-8123-0f99de5ae99a",
    "order_transaction_id": "6424dd45-ee1a-49c6-ad0c-5769b8e03fc1",
    "address": {
      "first_line": "123 Main St.",
      "second_line": "Apt. 208",
      "city": "San Francisco",
      "state": "CA",
      "zip_code": "91189",
      "country": "United States"
    },
    "location": {
      "lng": -122.4194155,
      "lat": 37.7749295
    },
    "start_at": "2022-01-01T00:00:00",
    "end_at": "2022-01-01T00:00:00",
    "iana_timezone": "America/New_York",
    "type": "patient_service_center",
    "provider": "quest",
    "status": "confirmed",
    "event_status": "scheduled",
    "provider_id": "123",
    "can_reschedule": true,
    "event_data": {
      "origin": "patient",
      "is_reschedule": true
    },
    "events": [
      {
        "created_at": "2022-01-01T00:00:00Z",
        "data": null,
        "status": "scheduled"
      },
      {
        "created_at": "2022-01-01T00:00:00Z",
        "data": {
          "origin": "patient",
          "is_reschedule": true
        },
        "status": "scheduled"
      }
    ]
  }
}
```

<br />

<Info>The `event_data` field contains relevant information regarding the current appointment status, and may be specific for each `provider`.</Info>
