{
  "openapi": "3.0.3",
  "info": {
    "title": "Nabla Connect API",
    "description": "Nabla Connect callback API reference.",
    "version": ""
  },
  "paths": {
    "/callback": {
      "post": {
        "summary": "Receive Nabla Connect events",
        "description": "This is the endpoint you need to implement on your server to receive callbacks. This page references the format of all the possible callbacks.",
        "tags": [
          "Nabla Connect"
        ],
        "operationId": "callback",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/callback"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/callback_response"
                }
              }
            },
            "description": "Respond with 200 to acknowledge the handling of this event."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "note_export": {
        "$ref": "#/components/schemas/callback_note_export"
      },
      "uuid": {
        "type": "string",
        "format": "uuid",
        "description": "A unique identifier.",
        "example": "98FCE1EF-DBCA-41EF-8BC7-4D1621AC07C6"
      },
      "callback_type": {
        "type": "string",
        "enum": [
          "NOTE_EXPORT",
          "PATIENT_INSTRUCTIONS_EXPORT"
        ]
      },
      "base_callback": {
        "type": "object",
        "properties": {
          "request_uuid": {
            "$ref": "#/components/schemas/uuid",
            "description": "The unique identifier of this webhook event"
          },
          "type": {
            "$ref": "#/components/schemas/callback_type",
            "description": "Type of this event, serves as a discriminator between the different possible webhook types."
          }
        },
        "required": [
          "request_uuid",
          "type"
        ]
      },
      "note_section_type": {
        "type": "string",
        "description": "A category identifying a section of a note.\nThe set of possible categories depend on the template that is used.",
        "example": "CHIEF_COMPLAINT",
        "enum": [
          "CHIEF_COMPLAINT",
          "HISTORY_OF_PRESENT_ILLNESS",
          "PAST_HISTORY",
          "CURRENT_MEDICATIONS",
          "VITALS",
          "IMMUNIZATIONS",
          "ASSESSMENT_AND_PLAN",
          "EXAMINATION",
          "RESULTS",
          "PRESCRIPTIONS",
          "APPOINTMENTS"
        ]
      },
      "note_section": {
        "type": "object",
        "description": "A note section.",
        "properties": {
          "category": {
            "$ref": "#/components/schemas/note_section_type"
          },
          "title": {
            "type": "string",
            "description": "The section title.",
            "example": "Chief complaint"
          },
          "content": {
            "type": "string",
            "deprecated": true,
            "description": "Content of the note section, flattened as text. Deprecated: replace your usage with `structured_content`, which carries the same content in a structured form.",
            "example": "Sleep disorder"
          }
        },
        "required": [
          "content"
        ]
      },
      "note": {
        "type": "object",
        "description": "The generated note.",
        "properties": {
          "sections": {
            "type": "array",
            "description": "Content of the note structured in multiple sections.",
            "items": {
              "$ref": "#/components/schemas/note_section"
            }
          },
          "free_text": {
            "type": "string",
            "description": "Free-form text written by the practitioner, alongside the note sections."
          }
        },
        "required": [
          "sections"
        ]
      },
      "speaker": {
        "type": "string",
        "enum": [
          "DOCTOR",
          "PATIENT",
          "UNSPECIFIED"
        ],
        "description": "Who said the text in this transcript item.",
        "example": "DOCTOR"
      },
      "speech_locale": {
        "type": "string",
        "enum": [
          "ENGLISH_US",
          "ENGLISH_UK",
          "SPANISH_ES",
          "SPANISH_MX",
          "FRENCH_FR",
          "ARABIC_EG",
          "ARABIC_LB",
          "ARABIC_MA",
          "ARABIC_SA",
          "ARMENIAN_AM",
          "BENGALI_IN",
          "CANTONESE_CN",
          "CROATIAN_HR",
          "FILIPINO_PH",
          "GERMAN_DE",
          "GREEK_GR",
          "GUJARATI_IN",
          "HEBREW_IL",
          "HINDI_IN",
          "ITALIAN_IT",
          "JAPANESE_JP",
          "KHMER_KH",
          "KOREAN_KR",
          "MANDARIN_CN",
          "PERSIAN_IR",
          "POLISH_PL",
          "PORTUGUESE_PT",
          "PUNJABI_IN",
          "RUSSIAN_RU",
          "SERBIAN_RS",
          "TAMIL_IN",
          "TELUGU_IN",
          "THAI_TH",
          "URDU_IN",
          "VIETNAMESE_VN",
          "HAITIAN_HT"
        ],
        "example": "ENGLISH_US"
      },
      "transcript_item": {
        "type": "object",
        "description": "A portion of the transcribed consultation.",
        "properties": {
          "text": {
            "type": "string",
            "description": "The transcribed text.",
            "example": "Also, I’m allergic to peanuts."
          },
          "speaker_type": {
            "$ref": "#/components/schemas/speaker"
          },
          "locale": {
            "$ref": "#/components/schemas/speech_locale",
            "description": "Locale for this transcript item, detected by the speech-to-text engine from the list of locales in the input."
          },
          "start_offset_ms": {
            "type": "integer",
            "description": "Start time of this transcription item as the offset, in milliseconds, from the start of the audio file.",
            "example": 65100
          },
          "end_offset_ms": {
            "type": "integer",
            "description": "End time of this transcription item as the offset, in milliseconds, from the start of the audio file. Equals the `start_time_ms` plus the duration of the related transcribed audio portion.",
            "example": 69300
          }
        },
        "required": [
          "text",
          "speaker_type",
          "start_offset_ms",
          "end_offset_ms"
        ]
      },
      "transcript": {
        "type": "array",
        "description": "Transcript items from the audio file.",
        "items": {
          "$ref": "#/components/schemas/transcript_item"
        }
      },
      "note_export_data": {
        "type": "object",
        "properties": {
          "external_patient_id": {
            "type": "string",
            "description": "External patient ID from your app, that you provided at launch"
          },
          "external_encounter_id": {
            "type": "string",
            "description": "External encounter ID from your app, that you provided at launch"
          },
          "external_provider_id": {
            "type": "string",
            "description": "External patient ID from your app, that you provided at launch"
          },
          "note": {
            "$ref": "#/components/schemas/note",
            "description": "The exported note."
          },
          "transcript": {
            "$ref": "#/components/schemas/transcript",
            "description": "The exported note transcript."
          }
        },
        "required": [
          "external_patient_id",
          "external_encounter_id",
          "external_provider_id",
          "note"
        ]
      },
      "callback_note_export": {
        "x-sensitive-medical-data": true,
        "allOf": [
          {
            "$ref": "#/components/schemas/base_callback"
          },
          {
            "type": "object",
            "description": "Event sent when a note is exported.",
            "properties": {
              "data": {
                "$ref": "#/components/schemas/note_export_data"
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "patient_instructions": {
        "type": "object",
        "properties": {
          "instructions": {
            "type": "string",
            "description": "List of instructions for the patient.",
            "example": "- Order a sleep test that you can do at home. This will help us understand more about how you sleep.\n- After you've done the sleep test, we'll talk about the results in our next meeting."
          }
        },
        "required": [
          "instructions"
        ]
      },
      "patient_instructions_export_data": {
        "type": "object",
        "properties": {
          "external_patient_id": {
            "type": "string",
            "description": "External patient ID from your app, that you provided at launch"
          },
          "external_encounter_id": {
            "type": "string",
            "description": "External encounter ID from your app, that you provided at launch"
          },
          "external_provider_id": {
            "type": "string",
            "description": "External patient ID from your app, that you provided at launch"
          },
          "patient_instructions": {
            "$ref": "#/components/schemas/patient_instructions",
            "description": "The exported patient_instructions."
          }
        },
        "required": [
          "external_patient_id",
          "external_encounter_id",
          "external_provider_id",
          "patient_instructions"
        ]
      },
      "callback_patient_instructions_export": {
        "x-sensitive-medical-data": true,
        "allOf": [
          {
            "$ref": "#/components/schemas/base_callback"
          },
          {
            "type": "object",
            "description": "Event sent when patient instructions are exported.",
            "properties": {
              "data": {
                "$ref": "#/components/schemas/patient_instructions_export_data"
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "callback": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/callback_note_export",
            "title": "NOTE_EXPORT"
          },
          {
            "$ref": "#/components/schemas/callback_patient_instructions_export",
            "title": "PATIENT_INSTRUCTIONS_EXPORT"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "NOTE_EXPORT": "#/components/schemas/callback_note_export",
            "PATIENT_INSTRUCTIONS_EXPORT": "#/components/schemas/callback_patient_instructions_export"
          }
        },
        "example": {
          "request_uuid": "0cf0b04d-5bbe-47a9-9601-3dd037644f65",
          "type": "NOTE_EXPORT",
          "data": {
            "patient_id": "patient_123456",
            "encounter_id": "encounter_987654",
            "provider_id": "provider_456789",
            "note": {
              "sections": [
                {
                  "type": "CHIEF_COMPLAINT",
                  "title": "Chief complaint",
                  "content": "- Persistent fatigue\n- Mild headaches on the right side"
                },
                {
                  "type": "ASSESSMENT_AND_PLAN",
                  "title": "Past medical history",
                  "content": "- Hypertension\n- Elevated blood sugar levels"
                },
                {
                  "type": "RESULTS",
                  "title": "Lab results",
                  "content": "- Blood sugar level: 1.4 g/L\n- LDL cholesterol: 2 g/L"
                }
              ]
            }
          }
        }
      },
      "callback_response": {
        "type": "object",
        "properties": {
          "request_uuid": {
            "$ref": "#/components/schemas/uuid",
            "description": "The request UUID you provided in the request."
          }
        },
        "required": [
          "request_uuid"
        ]
      }
    }
  }
}
