{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/getlabs/json-schema/getlabs-appointment-book-dto-schema.json",
  "title": "AppointmentBookDto",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/getlabs-openapi.yml#/components/schemas/AppointmentBookDto",
  "type": "object",
  "properties": {
    "key": {
      "type": "string",
      "description": "The booking key retrieved from the availability endpoint. A key is valid for 60 minutes after generation, to book an appointment after that a new key is needed."
    },
    "patientId": {
      "type": "string",
      "format": "uuid",
      "description": "The patient's ID as retrieved from the /patient endpoint"
    },
    "labOrderDetails": {
      "description": "An array of LabOrderDetails objects. If the key being used is for a priority appointment then labOrderFileIds must include a 'lab-order' file for at least one LabOrderDetail.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/LabOrderDetailsDto"
      }
    },
    "paymentMethod": {
      "type": "string",
      "description": "The Stripe payment method ID fetched using the Stripe client API. This is only required if your account is setup to bill patients directly."
    },
    "behalfOf": {
      "description": "Details of the person booking on behalf of the patient",
      "allOf": [
        {
          "$ref": "#/$defs/BehalfOfDto"
        }
      ]
    },
    "parkingInstruction": {
      "type": "string",
      "description": "Instructions for parking."
    },
    "specialRequest": {
      "type": "string",
      "description": "Special instruction notes."
    },
    "products": {
      "description": "Partner Products attached to the appointment.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/AppointmentProductDto"
      }
    },
    "externalId": {
      "type": [
        "string",
        "null"
      ],
      "description": "External identifier for the appointment."
    }
  },
  "required": [
    "key",
    "patientId",
    "labOrderDetails"
  ],
  "$defs": {
    "AppointmentProductDto": {
      "type": "object",
      "properties": {
        "productId": {
          "type": "string",
          "description": "The getlabs base product id."
        },
        "partnerProductConfigId": {
          "type": "string",
          "description": "The partner product configuration id."
        },
        "properties": {
          "description": "The booking properties collected for this appointment.",
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/AppointmentProductPropertyDto"
          }
        }
      },
      "required": [
        "partnerProductConfigId"
      ]
    },
    "AppointmentProductPropertyDto": {
      "type": "object",
      "properties": {
        "value": {
          "type": [
            "string",
            "null"
          ],
          "description": "The booking property's collected value."
        },
        "type": {
          "description": "The booking property's type.",
          "allOf": [
            {
              "$ref": "#/$defs/ProductPropertyValueType"
            }
          ]
        },
        "productPropertyId": {
          "type": "string",
          "description": "The booking property's product id."
        }
      },
      "required": [
        "value",
        "type",
        "productPropertyId"
      ]
    },
    "BehalfOfDto": {
      "type": "object",
      "properties": {
        "firstName": {
          "type": "string",
          "description": "First name of the person booking on behalf of"
        },
        "lastName": {
          "type": "string",
          "description": "Last name of the person booking on behalf of"
        },
        "email": {
          "type": "string",
          "description": "Email of the person booking on behalf of"
        },
        "phoneNumber": {
          "type": "string",
          "description": "Phone number of the person booking on behalf of"
        },
        "isLegalGuardian": {
          "type": "boolean",
          "description": "Are you the the patient's parent, legal guardian, or caretaker"
        },
        "shouldNotify": {
          "type": "boolean",
          "description": "Should we notify you of the patient's appointment status?"
        }
      }
    },
    "ExtendedFileDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "readOnly": true,
          "format": "uuid"
        },
        "name": {
          "type": "string",
          "description": "File name"
        },
        "purpose": {
          "description": "The purpose of this file, must be one of the available options",
          "allOf": [
            {
              "$ref": "#/$defs/ExtendedFilePurpose"
            }
          ]
        },
        "data": {
          "type": "string",
          "description": "Base64 encoded file contents, maximum size of 25 MB. The file MIME types allowed differ depending on the file \"purpose\":\n* lab-order can be one of: image/png, image/jpeg, image/heic, image/heif, image/tiff, application/pdf\n* collection-instructions can be one of: image/png, image/jpeg, image/heic, image/heif, image/tiff, application/pdf\n* insurance-front, insurance-rear can be one of: image/png, image/jpeg, image/heic, image/heif, image/tiff, application/pdf",
          "writeOnly": true
        },
        "size": {
          "type": "number",
          "description": "The file size in bytes",
          "readOnly": true
        },
        "type": {
          "type": "string",
          "description": "Type of the file.",
          "readOnly": true
        },
        "url": {
          "type": "string",
          "description": "Signed, expiring url for the file.",
          "readOnly": true
        }
      },
      "required": [
        "name",
        "purpose",
        "data",
        "size",
        "type",
        "url"
      ]
    },
    "ExtendedFilePurpose": {
      "type": "string",
      "enum": [
        "lab-order",
        "collection-instructions",
        "insurance-front",
        "insurance-rear",
        "specimen"
      ],
      "description": "The purpose of this file, must be one of the available options"
    },
    "LabOrderDetailsDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "readOnly": true,
          "format": "uuid",
          "description": "The ID of this entity"
        },
        "contactName": {
          "type": [
            "string",
            "null"
          ],
          "description": "Name of the person/doctor's office who has the lab order details. Required if labOrderFileIds does NOT include a 'lab-order' file AND the appointment is NOT a priority appointment."
        },
        "contactPhone": {
          "type": [
            "string",
            "null"
          ],
          "description": "10 digit phone number of the person/doctor's office who has the lab order details. Required if labOrderFileIds does NOT include a 'lab-order' file AND the appointment is NOT a priority appointment."
        },
        "labOrderFiles": {
          "readOnly": true,
          "description": "An array of all files attached.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ExtendedFileDto"
          }
        },
        "testCodes": {
          "description": "An array of test codes to be performed for this lab order.",
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        },
        "labOrderFileIds": {
          "writeOnly": true,
          "description": "An array of file IDs that were previously uploaded (and returned) using the /file endpoint. Files must have a purpose of 'lab-order' or 'collection-instructions'; a 'collection-instructions' file is only ever an attachment, so at least one 'lab-order' file is still required wherever a lab order is. Required if contactName and contactPhone are not set OR if trying to schedule a priority appointment and/or have already uploaded files using the /file endpoint.",
          "type": "array",
          "items": {
            "type": "string",
            "format": "uuid"
          }
        }
      }
    },
    "ProductPropertyValueType": {
      "type": "string",
      "enum": [
        "string",
        "number",
        "fileId",
        "boolean",
        "yesno",
        "url",
        "radio"
      ],
      "description": "The booking property's type."
    }
  }
}