{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developers.youareaccountable.com/schemas/webhook-event.json",
  "title": "AccountableWebhookEvent",
  "description": "The JSON body of any webhook request Accountable sends. New fields can be added at any time, so do not reject fields you don't recognize.",
  "oneOf": [
    {
      "$ref": "#/$defs/toxicology.result.posted"
    },
    {
      "$ref": "#/$defs/toxicology.result.deleted"
    },
    {
      "$ref": "#/$defs/breathalyzer.result.posted"
    },
    {
      "$ref": "#/$defs/breathalyzer.result.deleted"
    },
    {
      "$ref": "#/$defs/notes.created"
    },
    {
      "$ref": "#/$defs/notes.updated"
    },
    {
      "$ref": "#/$defs/notes.deleted"
    },
    {
      "$ref": "#/$defs/plan_details.created"
    },
    {
      "$ref": "#/$defs/plan_details.updated"
    },
    {
      "$ref": "#/$defs/scheduled_intake.created"
    },
    {
      "$ref": "#/$defs/scheduled_intake.canceled"
    },
    {
      "$ref": "#/$defs/coaching_session.created"
    },
    {
      "$ref": "#/$defs/coaching_session.updated"
    },
    {
      "$ref": "#/$defs/coaching_session.canceled"
    }
  ],
  "$defs": {
    "toxicology.result.posted": {
      "title": "ToxicologyResultPosted",
      "description": "A drug test result is posted or changed. A changed result is sent again with the same test_id.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "toxicology.result.posted"
        },
        "data": {
          "type": "object",
          "required": [
            "medical_record_number",
            "test_date",
            "test_type",
            "test_result",
            "self_reported",
            "test_id"
          ],
          "properties": {
            "medical_record_number": {
              "$ref": "#/$defs/medical_record_number"
            },
            "plan_name": {
              "$ref": "#/$defs/plan_name"
            },
            "test_date": {
              "type": "string",
              "format": "date-time",
              "description": "The calendar day of the test in UTC. The time is always 00:00:00.000Z. Read the date part only."
            },
            "test_type": {
              "type": "string",
              "description": "The kind of test. New test types can be added, so do not reject a value you don't recognize.",
              "examples": [
                "10 Panel Instant",
                "10 Panel Instant w/ THC",
                "14 Panel Instant",
                "Cotinine",
                "Saliva Lab Confirmation",
                "Urine Analysis",
                "Urine Instant"
              ]
            },
            "test_result": {
              "$ref": "#/$defs/test_result"
            },
            "self_reported": {
              "type": "boolean",
              "description": "true when the member reported the result themselves."
            },
            "test_notes": {
              "type": [
                "string",
                "null"
              ],
              "description": "Notes on the result. Can be null or left out."
            },
            "kit_id": {
              "type": [
                "string",
                "null"
              ],
              "description": "The test kit ID. Can be null or left out."
            },
            "test_id": {
              "type": "string",
              "description": "The result's ID. The same ID is sent again if the result changes or is deleted."
            },
            "lab_results": {
              "type": "array",
              "description": "The lab's per-analyte panel. Sent only for lab tests that have a panel. Left out on every other result.",
              "items": {
                "type": "object",
                "required": [
                  "code",
                  "name",
                  "result",
                  "units",
                  "cutoff"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "description": "The lab's analyte code, such as LCMSAMPH."
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The analyte name as the lab reports it."
                  },
                  "result": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The lab's result text. Values vary by lab. Treat it as display text."
                  },
                  "units": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Units as reported by the lab, such as ng/mL."
                  },
                  "cutoff": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The cutoff as reported by the lab."
                  }
                }
              }
            }
          }
        }
      },
      "examples": [
        {
          "event_type": "toxicology.result.posted",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "test_date": "2026-01-01T00:00:00.000Z",
            "test_type": "10 Panel Instant",
            "test_result": "Negative",
            "self_reported": false,
            "test_id": "665f1c2ab7e4d90012a3f4c2"
          }
        },
        {
          "event_type": "toxicology.result.posted",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "test_date": "2026-01-01T00:00:00.000Z",
            "test_type": "Saliva Lab Confirmation",
            "test_result": "Positive",
            "self_reported": false,
            "test_notes": "Confirmed by lab.",
            "kit_id": "KIT-000123",
            "test_id": "665f1c2ab7e4d90012a3f4c2",
            "lab_results": [
              {
                "code": "LCMSAMPH",
                "name": "Amphetamine",
                "result": "Not Detected",
                "units": "ng/mL",
                "cutoff": "2"
              },
              {
                "code": "LCMSCOTN",
                "name": "Cotinine",
                "result": "444.29",
                "units": "ng/mL",
                "cutoff": "2"
              },
              {
                "code": "LCMSFENT",
                "name": "Fentanyl",
                "result": "Not Detected",
                "units": "ng/mL",
                "cutoff": "0.25"
              }
            ]
          }
        }
      ]
    },
    "toxicology.result.deleted": {
      "title": "ToxicologyResultDeleted",
      "description": "A drug test result is deleted.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "toxicology.result.deleted"
        },
        "data": {
          "type": "object",
          "required": [
            "test_id"
          ],
          "properties": {
            "test_id": {
              "type": "string",
              "description": "The ID of the deleted result."
            }
          }
        }
      },
      "examples": [
        {
          "event_type": "toxicology.result.deleted",
          "data": {
            "test_id": "665f1c2ab7e4d90012a3f4c2"
          }
        }
      ]
    },
    "breathalyzer.result.posted": {
      "title": "BreathalyzerResultPosted",
      "description": "A breathalyzer result is posted or changed. A changed result is sent again with the same test_id.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "breathalyzer.result.posted"
        },
        "data": {
          "type": "object",
          "required": [
            "medical_record_number",
            "test_date",
            "test_result",
            "test_type",
            "self_reported",
            "test_id"
          ],
          "properties": {
            "medical_record_number": {
              "$ref": "#/$defs/medical_record_number"
            },
            "plan_name": {
              "$ref": "#/$defs/plan_name"
            },
            "test_date": {
              "type": "string",
              "format": "date-time",
              "description": "When the test was taken."
            },
            "test_result": {
              "$ref": "#/$defs/test_result"
            },
            "test_type": {
              "const": "Breathalyzer"
            },
            "self_reported": {
              "type": "boolean",
              "description": "true when the member reported the result themselves. false for results read from the device."
            },
            "test_notes": {
              "type": [
                "string",
                "null"
              ],
              "description": "Notes on the result. Can be null or left out."
            },
            "test_id": {
              "type": "string",
              "description": "The result's ID. The same ID is sent again if the result changes or is deleted."
            }
          }
        }
      },
      "examples": [
        {
          "event_type": "breathalyzer.result.posted",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "test_date": "2026-01-01T18:45:00.000Z",
            "test_result": "Negative",
            "test_type": "Breathalyzer",
            "self_reported": false,
            "test_notes": "Evening test.",
            "test_id": "665f1c2ab7e4d90012a3f4c3"
          }
        }
      ]
    },
    "breathalyzer.result.deleted": {
      "title": "BreathalyzerResultDeleted",
      "description": "A breathalyzer result is deleted.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "breathalyzer.result.deleted"
        },
        "data": {
          "type": "object",
          "required": [
            "test_id"
          ],
          "properties": {
            "test_id": {
              "type": "string",
              "description": "The ID of the deleted result."
            }
          }
        }
      },
      "examples": [
        {
          "event_type": "breathalyzer.result.deleted",
          "data": {
            "test_id": "665f1c2ab7e4d90012a3f4c3"
          }
        }
      ]
    },
    "notes.created": {
      "title": "NotesCreated",
      "description": "A note is created. Sends the full note.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "notes.created"
        },
        "data": {
          "$ref": "#/$defs/note"
        }
      },
      "examples": [
        {
          "event_type": "notes.created",
          "data": {
            "note_id": "665f1c2ab7e4d90012a3f4c4",
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "note_content": "Weekly session. Member reports steady progress.",
            "created_at": "2026-01-01T14:30:00.000Z",
            "updated_at": "2026-01-01T14:31:10.000Z",
            "created_by": "Jordan Rivera",
            "session_details": {
              "start_time": "2026-01-01T14:00:00.000Z",
              "stop_time": "2026-01-01T14:30:00.000Z",
              "duration_minutes": 30
            },
            "coaching_session": {
              "session_id": "665f1c2ab7e4d90012a3f4c5",
              "scheduled_date": "2026-01-01T14:00:00.000Z",
              "end_time": "2026-01-01T14:30:00.000Z",
              "duration_minutes": 30,
              "status": "completed",
              "recurrence_group_id": null
            },
            "flags": {
              "essential_info": false,
              "recovery_capital_summary": false,
              "compliance": false,
              "tox_review": false,
              "onboarding_complete": false,
              "notify_care_team": true,
              "call": false,
              "email": false,
              "checkin": true,
              "family_contact": false,
              "clinical_contact": false,
              "justice_contact": false,
              "no_show": false
            },
            "tox_id": null,
            "file": null
          }
        }
      ]
    },
    "notes.updated": {
      "title": "NotesUpdated",
      "description": "A note is edited. Sends the full note.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "notes.updated"
        },
        "data": {
          "$ref": "#/$defs/note"
        }
      }
    },
    "notes.deleted": {
      "title": "NotesDeleted",
      "description": "A note is deleted.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "notes.deleted"
        },
        "data": {
          "type": "object",
          "required": [
            "note_id"
          ],
          "properties": {
            "note_id": {
              "type": "string",
              "description": "The ID of the deleted note."
            }
          }
        }
      },
      "examples": [
        {
          "event_type": "notes.deleted",
          "data": {
            "note_id": "665f1c2ab7e4d90012a3f4c4"
          }
        }
      ]
    },
    "plan_details.created": {
      "title": "PlanDetailsCreated",
      "description": "A member is enrolled and their plan details are set. Sends the full list.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "plan_details.created"
        },
        "data": {
          "$ref": "#/$defs/plan_details"
        }
      }
    },
    "plan_details.updated": {
      "title": "PlanDetailsUpdated",
      "description": "A member's plan details are changed. Sends the full list, not just what changed.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "plan_details.updated"
        },
        "data": {
          "$ref": "#/$defs/plan_details"
        }
      },
      "examples": [
        {
          "event_type": "plan_details.updated",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "plan_details": [
              "BAC Monitoring",
              "Coaching 1x Per Week",
              "Saliva Test 1x Per Week"
            ],
            "updated_at": "2026-01-01T15:00:00.000Z"
          }
        }
      ]
    },
    "scheduled_intake.created": {
      "title": "ScheduledIntakeCreated",
      "description": "An intake meeting is scheduled.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "scheduled_intake.created"
        },
        "data": {
          "type": "object",
          "required": [
            "medical_record_number",
            "scheduled_date",
            "meeting_url",
            "invitee_email",
            "meeting_id"
          ],
          "properties": {
            "medical_record_number": {
              "$ref": "#/$defs/medical_record_number"
            },
            "plan_name": {
              "$ref": "#/$defs/plan_name"
            },
            "scheduled_date": {
              "type": "string",
              "format": "date-time",
              "description": "When the meeting starts."
            },
            "meeting_url": {
              "type": "string",
              "description": "The video link for the meeting. An empty string when there is none."
            },
            "invitee_email": {
              "type": "string",
              "description": "The email address of the person invited. An empty string when there is none."
            },
            "meeting_id": {
              "type": "string",
              "description": "The meeting's ID. The cancel event uses the same ID."
            }
          }
        }
      },
      "examples": [
        {
          "event_type": "scheduled_intake.created",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "scheduled_date": "2026-01-05T16:00:00.000Z",
            "meeting_url": "https://example.zoom.us/j/1234567890",
            "invitee_email": "member@example.com",
            "meeting_id": "665f1c2ab7e4d90012a3f4c6"
          }
        }
      ]
    },
    "scheduled_intake.canceled": {
      "title": "ScheduledIntakeCanceled",
      "description": "A scheduled intake meeting is canceled.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "scheduled_intake.canceled"
        },
        "data": {
          "type": "object",
          "required": [
            "meeting_id"
          ],
          "properties": {
            "meeting_id": {
              "type": "string",
              "description": "The ID of the canceled meeting."
            }
          }
        }
      },
      "examples": [
        {
          "event_type": "scheduled_intake.canceled",
          "data": {
            "meeting_id": "665f1c2ab7e4d90012a3f4c6"
          }
        }
      ]
    },
    "coaching_session.created": {
      "title": "CoachingSessionCreated",
      "description": "A session or a recurring series is scheduled. Check data.is_recurring to tell the two shapes apart.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "coaching_session.created"
        },
        "data": {
          "oneOf": [
            {
              "title": "CoachingSessionCreatedOneSession",
              "description": "One session.",
              "type": "object",
              "required": [
                "medical_record_number",
                "session_id",
                "scheduled_date",
                "meeting_url",
                "status",
                "is_recurring"
              ],
              "properties": {
                "medical_record_number": {
                  "$ref": "#/$defs/medical_record_number"
                },
                "plan_name": {
                  "$ref": "#/$defs/plan_name"
                },
                "session_id": {
                  "type": "string",
                  "description": "The session's ID."
                },
                "scheduled_date": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The scheduled start time."
                },
                "end_time": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time",
                  "description": "The scheduled end time."
                },
                "duration_minutes": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "The scheduled length."
                },
                "meeting_url": {
                  "type": "string",
                  "description": "The video link. An empty string when there is none."
                },
                "status": {
                  "$ref": "#/$defs/session_status"
                },
                "is_recurring": {
                  "const": false
                }
              }
            },
            {
              "title": "CoachingSessionCreatedSeries",
              "description": "A recurring series. One event is sent for the whole series, not one per session.",
              "type": "object",
              "required": [
                "medical_record_number",
                "recurrence_group_id",
                "first_session_date",
                "meeting_url",
                "is_recurring",
                "recurrence_rule"
              ],
              "properties": {
                "medical_record_number": {
                  "$ref": "#/$defs/medical_record_number"
                },
                "plan_name": {
                  "$ref": "#/$defs/plan_name"
                },
                "recurrence_group_id": {
                  "type": "string",
                  "description": "The series ID."
                },
                "first_session_date": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The start time of the first session."
                },
                "duration_minutes": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "The scheduled length."
                },
                "meeting_url": {
                  "type": "string",
                  "description": "The video link. An empty string when there is none."
                },
                "is_recurring": {
                  "const": true
                },
                "recurrence_rule": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "description": "How the series repeats.",
                  "properties": {
                    "frequency": {
                      "enum": [
                        "weekly",
                        "biweekly",
                        "monthly"
                      ]
                    },
                    "day_of_week": {
                      "$ref": "#/$defs/day_of_week"
                    },
                    "time_utc": {
                      "$ref": "#/$defs/time_utc"
                    },
                    "end_date": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time",
                      "description": "When the series ends."
                    }
                  }
                }
              }
            }
          ]
        }
      },
      "examples": [
        {
          "event_type": "coaching_session.created",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "session_id": "665f1c2ab7e4d90012a3f4c5",
            "scheduled_date": "2026-01-06T15:00:00.000Z",
            "end_time": "2026-01-06T15:30:00.000Z",
            "duration_minutes": 30,
            "meeting_url": "https://example.zoom.us/j/1234567890",
            "status": "scheduled",
            "is_recurring": false
          }
        },
        {
          "event_type": "coaching_session.created",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "recurrence_group_id": "0b9d6c1e-5d2a-4a57-8f43-2f6a9d3c7e10",
            "first_session_date": "2026-01-06T15:00:00.000Z",
            "duration_minutes": 30,
            "meeting_url": "https://example.zoom.us/j/1234567890",
            "is_recurring": true,
            "recurrence_rule": {
              "frequency": "weekly",
              "day_of_week": 2,
              "time_utc": "15:00",
              "end_date": "2026-06-30T00:00:00.000Z"
            }
          }
        }
      ]
    },
    "coaching_session.updated": {
      "title": "CoachingSessionUpdated",
      "description": "A session is changed, a series is changed from a date onward, or a session's attendance is recorded. A series change has data.scope set to future.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "coaching_session.updated"
        },
        "data": {
          "oneOf": [
            {
              "title": "CoachingSessionUpdatedOneSession",
              "description": "One session.",
              "type": "object",
              "required": [
                "medical_record_number",
                "session_id",
                "recurrence_group_id",
                "scheduled_date",
                "status"
              ],
              "properties": {
                "medical_record_number": {
                  "$ref": "#/$defs/medical_record_number"
                },
                "plan_name": {
                  "$ref": "#/$defs/plan_name"
                },
                "session_id": {
                  "type": "string",
                  "description": "The session's ID."
                },
                "recurrence_group_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "The series ID. null when the session is not part of a series."
                },
                "scheduled_date": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The scheduled start time after the change."
                },
                "end_time": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time",
                  "description": "The scheduled end time after the change."
                },
                "duration_minutes": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "The scheduled length."
                },
                "status": {
                  "$ref": "#/$defs/session_status"
                }
              }
            },
            {
              "title": "CoachingSessionUpdatedSeries",
              "description": "Every session in a series from a date onward.",
              "type": "object",
              "required": [
                "medical_record_number",
                "recurrence_group_id",
                "scope",
                "effective_from",
                "recurrence_rule"
              ],
              "properties": {
                "medical_record_number": {
                  "$ref": "#/$defs/medical_record_number"
                },
                "plan_name": {
                  "$ref": "#/$defs/plan_name"
                },
                "recurrence_group_id": {
                  "type": "string",
                  "description": "The series ID."
                },
                "scope": {
                  "const": "future"
                },
                "effective_from": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The first session the change applies to."
                },
                "duration_minutes": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "The scheduled length."
                },
                "recurrence_rule": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "description": "The new time and day.",
                  "properties": {
                    "time_utc": {
                      "$ref": "#/$defs/time_utc"
                    },
                    "day_of_week": {
                      "$ref": "#/$defs/day_of_week"
                    }
                  }
                }
              }
            }
          ]
        }
      },
      "examples": [
        {
          "event_type": "coaching_session.updated",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "session_id": "665f1c2ab7e4d90012a3f4c5",
            "recurrence_group_id": null,
            "scheduled_date": "2026-01-06T16:00:00.000Z",
            "end_time": "2026-01-06T16:30:00.000Z",
            "duration_minutes": 30,
            "status": "scheduled"
          }
        },
        {
          "event_type": "coaching_session.updated",
          "data": {
            "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
            "plan_name": "Standard Plan",
            "recurrence_group_id": "0b9d6c1e-5d2a-4a57-8f43-2f6a9d3c7e10",
            "scope": "future",
            "effective_from": "2026-02-03T16:00:00.000Z",
            "duration_minutes": 30,
            "recurrence_rule": {
              "time_utc": "16:00",
              "day_of_week": 2
            }
          }
        }
      ]
    },
    "coaching_session.canceled": {
      "title": "CoachingSessionCanceled",
      "description": "A session is canceled, or a series is canceled from a date onward. A series cancel has data.scope set to future. Cancel events do not include medical_record_number.",
      "type": "object",
      "required": [
        "event_type",
        "data"
      ],
      "properties": {
        "event_type": {
          "const": "coaching_session.canceled"
        },
        "data": {
          "oneOf": [
            {
              "title": "CoachingSessionCanceledOneSession",
              "description": "One session.",
              "type": "object",
              "required": [
                "session_id",
                "recurrence_group_id"
              ],
              "properties": {
                "session_id": {
                  "type": "string",
                  "description": "The canceled session's ID."
                },
                "recurrence_group_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "The series ID. null when the session is not part of a series."
                },
                "canceled_date": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time",
                  "description": "The scheduled start time of the canceled session."
                }
              }
            },
            {
              "title": "CoachingSessionCanceledSeries",
              "description": "Every session in a series from a date onward.",
              "type": "object",
              "required": [
                "recurrence_group_id",
                "scope"
              ],
              "properties": {
                "recurrence_group_id": {
                  "type": "string",
                  "description": "The series ID."
                },
                "scope": {
                  "const": "future"
                },
                "effective_from": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time",
                  "description": "Sessions from this time onward are canceled."
                },
                "canceled_count": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "description": "How many sessions were canceled."
                }
              }
            }
          ]
        }
      },
      "examples": [
        {
          "event_type": "coaching_session.canceled",
          "data": {
            "session_id": "665f1c2ab7e4d90012a3f4c5",
            "recurrence_group_id": null,
            "canceled_date": "2026-01-06T16:00:00.000Z"
          }
        },
        {
          "event_type": "coaching_session.canceled",
          "data": {
            "recurrence_group_id": "0b9d6c1e-5d2a-4a57-8f43-2f6a9d3c7e10",
            "scope": "future",
            "effective_from": "2026-03-03T16:00:00.000Z",
            "canceled_count": 10
          }
        }
      ]
    },
    "medical_record_number": {
      "type": "string",
      "format": "uuid",
      "description": "The member's medical record number. Always a UUID. Use it to match the event to your own record."
    },
    "plan_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "The member's Accountable plan. Can be null or left out."
    },
    "test_result": {
      "type": "string",
      "description": "The overall result. Usually Positive, Negative or Missed. Lab tests can also be Inconclusive.",
      "examples": [
        "Positive",
        "Negative",
        "Missed",
        "Inconclusive"
      ]
    },
    "session_status": {
      "enum": [
        "scheduled",
        "completed",
        "canceled",
        "no-show"
      ]
    },
    "day_of_week": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0,
      "maximum": 6,
      "description": "0 is Sunday, 6 is Saturday."
    },
    "time_utc": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^[0-9]{2}:[0-9]{2}$",
      "description": "Start time in UTC, as HH:mm."
    },
    "note": {
      "type": "object",
      "required": [
        "note_id",
        "medical_record_number",
        "note_content",
        "created_at",
        "created_by",
        "session_details",
        "coaching_session",
        "flags",
        "tox_id",
        "file"
      ],
      "properties": {
        "note_id": {
          "type": "string",
          "description": "The note's ID."
        },
        "medical_record_number": {
          "$ref": "#/$defs/medical_record_number"
        },
        "plan_name": {
          "$ref": "#/$defs/plan_name"
        },
        "note_content": {
          "type": "string",
          "description": "The text of the note."
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "The date on the note."
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the note was last changed."
        },
        "created_by": {
          "type": [
            "string",
            "null"
          ],
          "description": "First and last name of the person who wrote the note."
        },
        "session_details": {
          "type": [
            "object",
            "null"
          ],
          "description": "The actual times the coach logged. null when the note has none.",
          "properties": {
            "start_time": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "When the session started. null on a no-show note."
            },
            "stop_time": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "When the session ended. Ignore it when start_time is null."
            },
            "duration_minutes": {
              "type": [
                "number",
                "null"
              ],
              "description": "How long the session ran."
            }
          }
        },
        "coaching_session": {
          "type": [
            "object",
            "null"
          ],
          "description": "The scheduled session this note was matched to. Set only on check-in and no-show notes that match a scheduled session.",
          "required": [
            "session_id",
            "scheduled_date",
            "status",
            "recurrence_group_id"
          ],
          "properties": {
            "session_id": {
              "type": "string",
              "description": "The scheduled session's ID."
            },
            "scheduled_date": {
              "type": "string",
              "format": "date-time",
              "description": "The scheduled start time."
            },
            "end_time": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "The scheduled end time."
            },
            "duration_minutes": {
              "type": [
                "number",
                "null"
              ],
              "description": "The scheduled length."
            },
            "status": {
              "$ref": "#/$defs/session_status"
            },
            "recurrence_group_id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Set when the session belongs to a recurring series."
            }
          }
        },
        "flags": {
          "type": "object",
          "description": "What kind of note this is.",
          "properties": {
            "essential_info": {
              "type": "boolean",
              "description": "The note holds important information about the member."
            },
            "recovery_capital_summary": {
              "type": "boolean",
              "description": "The note came from a recovery capital assessment."
            },
            "compliance": {
              "type": "boolean",
              "description": "The note is a compliance note."
            },
            "tox_review": {
              "type": "boolean",
              "description": "The note came from a review of a recorded test."
            },
            "onboarding_complete": {
              "type": "boolean",
              "description": "The note marks the end of onboarding."
            },
            "notify_care_team": {
              "type": "boolean",
              "description": "The care team was notified about the note."
            },
            "call": {
              "type": "boolean",
              "description": "A call was made."
            },
            "email": {
              "type": "boolean",
              "description": "An email was sent."
            },
            "checkin": {
              "type": "boolean",
              "description": "The note documents a session with the member."
            },
            "family_contact": {
              "type": "boolean",
              "description": "The note documents contact with family."
            },
            "clinical_contact": {
              "type": "boolean",
              "description": "The note documents contact with a clinician."
            },
            "justice_contact": {
              "type": "boolean",
              "description": "The note documents contact with probation, court or other justice staff."
            },
            "no_show": {
              "type": "boolean",
              "description": "The member missed a scheduled session."
            }
          }
        },
        "tox_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "The related test result, if there is one. Matches test_id on toxicology and breathalyzer events."
        },
        "file": {
          "type": "null",
          "description": "Reserved. Always null."
        }
      }
    },
    "plan_details": {
      "type": "object",
      "required": [
        "medical_record_number",
        "plan_details",
        "updated_at"
      ],
      "properties": {
        "medical_record_number": {
          "$ref": "#/$defs/medical_record_number"
        },
        "plan_name": {
          "$ref": "#/$defs/plan_name"
        },
        "plan_details": {
          "type": "array",
          "description": "Every service on the member's plan. Empty when the plan has none. New values can be added.",
          "items": {
            "type": "string"
          }
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "description": "When this request was built. A retry has a new value."
        }
      }
    }
  }
}
