{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/medsender/json-schema/medsender-received-fax-schema.json",
  "title": "ReceivedFax",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/medsender-openapi.json#/components/schemas/ReceivedFax",
  "type": "object",
  "required": [
    "sendToken",
    "fromNumber",
    "toNumber",
    "faxStatus",
    "isTest"
  ],
  "properties": {
    "sendToken": {
      "type": "string"
    },
    "fromNumber": {
      "type": "string",
      "description": "Fax number in E.164 format.",
      "pattern": "^\\+[1-9]\\d{1,14}$"
    },
    "toNumber": {
      "type": "string",
      "description": "Fax number in E.164 format.",
      "pattern": "^\\+[1-9]\\d{1,14}$"
    },
    "callerName": {
      "type": [
        "string",
        "null"
      ]
    },
    "faxStatus": {
      "type": "string",
      "enum": [
        "success",
        "failure"
      ]
    },
    "sentAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "numPages": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    },
    "isTest": {
      "type": "boolean"
    },
    "errorDetails": {
      "$ref": "#/$defs/FaxErrorDetails"
    },
    "callbackStatus": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "success",
        "failed",
        "pending",
        null
      ]
    },
    "client": {
      "type": [
        "string",
        "null"
      ]
    },
    "documentClassification": {
      "type": [
        "string",
        "null"
      ]
    },
    "secondaryCategory": {
      "type": [
        "string",
        "null"
      ]
    },
    "patientName": {
      "type": [
        "string",
        "null"
      ]
    },
    "patientFirstName": {
      "type": [
        "string",
        "null"
      ]
    },
    "patientMiddleName": {
      "type": [
        "string",
        "null"
      ]
    },
    "patientLastName": {
      "type": [
        "string",
        "null"
      ]
    },
    "patientDob": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "insuranceMemberId": {
      "type": [
        "string",
        "null"
      ]
    },
    "referenceNumber": {
      "type": [
        "string",
        "null"
      ]
    },
    "authorizationNumber": {
      "type": [
        "string",
        "null"
      ]
    },
    "codes": {
      "type": [
        "string",
        "null"
      ],
      "description": "Extracted codes as stored text, or null when AI extraction is absent. The text is not guaranteed to be JSON."
    },
    "authDateRangeStart": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "authDateRangeEnd": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "denialReason": {
      "type": [
        "string",
        "null"
      ]
    },
    "secureLink": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    }
  },
  "$defs": {
    "FaxErrorDetails": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "errorMessage"
      ],
      "properties": {
        "errorMessage": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}