{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/terminal-telematics/json-schema/terminal-telematics-hosdaily-log-schema.json",
  "title": "HOS Daily Log",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/terminal.openapi.json#/components/schemas/HOSDailyLog",
  "type": "object",
  "x-model-category": "time-series",
  "x-read-permission": "hos:read",
  "properties": {
    "id": {
      "$ref": "#/$defs/HOSDailyLogId"
    },
    "sourceId": {
      "$ref": "#/$defs/SourceId"
    },
    "provider": {
      "$ref": "#/$defs/ProviderCode"
    },
    "driver": {
      "$ref": "#/$defs/ExpandableDriver",
      "description": "The driver this log belongs to."
    },
    "vehicles": {
      "type": "array",
      "description": "Vehicles associated with this daily HOS log.",
      "items": {
        "$ref": "#/$defs/ExpandableVehicle"
      }
    },
    "date": {
      "type": "string",
      "format": "date"
    },
    "distances": {
      "type": "object",
      "description": "Breakdown of different distance measurements for the day when available in the source system",
      "properties": {
        "total": {
          "$ref": "#/$defs/DistanceInKilometers",
          "description": "Total distance driven during this day in kilometers"
        },
        "driving": {
          "$ref": "#/$defs/DistanceInKilometers",
          "description": "Distance driven during driving"
        },
        "personalConveyance": {
          "$ref": "#/$defs/DistanceInKilometers",
          "description": "Distance driven during personal conveyance"
        },
        "yardMove": {
          "$ref": "#/$defs/DistanceInKilometers",
          "description": "Distance driven during yard moves"
        }
      }
    },
    "statusDurations": {
      "type": "object",
      "properties": {
        "onDuty": {
          "$ref": "#/$defs/DurationInMS"
        },
        "offDuty": {
          "$ref": "#/$defs/DurationInMS"
        },
        "driving": {
          "$ref": "#/$defs/DurationInMS"
        },
        "waiting": {
          "$ref": "#/$defs/DurationInMS"
        },
        "sleeperBed": {
          "$ref": "#/$defs/DurationInMS"
        },
        "personalConveyance": {
          "$ref": "#/$defs/DurationInMS"
        },
        "yardMove": {
          "$ref": "#/$defs/DurationInMS"
        }
      }
    },
    "metadata": {
      "$ref": "#/$defs/EntityMetadata"
    },
    "raw": {
      "$ref": "#/$defs/RawDataList"
    }
  },
  "required": [
    "id",
    "sourceId",
    "provider",
    "driver",
    "date",
    "statusDurations",
    "metadata"
  ],
  "x-description": "Record of daily hours of service.",
  "$defs": {
    "AddedAt": {
      "title": "AddedAt",
      "type": "string",
      "format": "date-time",
      "description": "The date and time the record was ingested into Terminal. Note: this is not the date and time the record was created in the provider's system."
    },
    "CoreEntityMetadata": {
      "title": "CoreEntityMetadata",
      "type": "object",
      "description": "Internal metadata about the record.",
      "required": [
        "addedAt",
        "modifiedAt"
      ],
      "properties": {
        "addedAt": {
          "$ref": "#/$defs/AddedAt"
        },
        "modifiedAt": {
          "$ref": "#/$defs/ModifiedAt"
        },
        "deletedAt": {
          "$ref": "#/$defs/DeletedAt"
        },
        "visibility": {
          "type": "string",
          "enum": [
            "visible",
            "hidden_by_exclude_list",
            "hidden_by_include_list",
            "hidden_by_status",
            "deleted"
          ],
          "description": "Visibility status of a resource. Read more about hidden records [here](https://docs.withterminal.com/guides/vehicle-driver-filtering)."
        }
      }
    },
    "DeletedAt": {
      "title": "DeletedAt",
      "type": "string",
      "format": "date-time",
      "description": "The date and time the record was deleted from Terminal. Note: this is not the date and time the record was deleted in the provider's system."
    },
    "DeviceId": {
      "title": "DeviceId",
      "type": "string",
      "format": "ulid"
    },
    "DistanceInKilometers": {
      "title": "Distance In Kilometers",
      "type": "number",
      "format": "double",
      "description": "Distance in kilometers"
    },
    "DriverId": {
      "title": "DriverId",
      "description": "Unique identifier for the driver in Terminal.",
      "type": "string",
      "format": "ulid",
      "pattern": "^drv_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "DurationInMS": {
      "title": "DurationInMS",
      "type": "integer",
      "description": "Duration in MS"
    },
    "EntityMetadata": {
      "title": "EntityMetadata",
      "type": "object",
      "description": "Internal metadata about the record.",
      "required": [
        "addedAt",
        "modifiedAt"
      ],
      "properties": {
        "addedAt": {
          "$ref": "#/$defs/AddedAt"
        },
        "modifiedAt": {
          "$ref": "#/$defs/ModifiedAt"
        }
      }
    },
    "ExpandableDriver": {
      "oneOf": [
        {
          "$ref": "#/$defs/DriverId"
        },
        {
          "$ref": "#/$defs/ExpandedDriver"
        }
      ]
    },
    "ExpandableVehicle": {
      "oneOf": [
        {
          "$ref": "#/$defs/VehicleId"
        },
        {
          "$ref": "#/$defs/ExpandedVehicle"
        }
      ]
    },
    "ExpandedDriver": {
      "title": "Expanded Driver",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/DriverId"
        },
        "sourceId": {
          "$ref": "#/$defs/SourceId"
        },
        "provider": {
          "$ref": "#/$defs/ProviderCode"
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "inactive"
          ],
          "description": "The status in the providers system"
        },
        "firstName": {
          "type": "string"
        },
        "middleName": {
          "type": "string"
        },
        "lastName": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "format": "email"
        },
        "phone": {
          "title": "Phone",
          "type": "string",
          "pattern": "^\\+?\\d{10,14}$",
          "description": "Phone number formatted in [E.164](https://www.twilio.com/docs/glossary/what-e164) formatting"
        },
        "username": {
          "type": "string",
          "description": "The driver's username for login purposes"
        },
        "license": {
          "type": "object",
          "properties": {
            "state": {
              "$ref": "#/$defs/State"
            },
            "number": {
              "type": "string"
            }
          }
        },
        "groups": {
          "type": "array",
          "description": "The groups the driver belongs to.",
          "items": {
            "$ref": "#/$defs/GroupId"
          }
        },
        "createdAt": {
          "$ref": "#/$defs/SourceCreatedAt"
        },
        "updatedAt": {
          "$ref": "#/$defs/SourceUpdatedAt"
        },
        "metadata": {
          "$ref": "#/$defs/CoreEntityMetadata"
        },
        "raw": {
          "$ref": "#/$defs/RawDataList"
        }
      },
      "required": [
        "id",
        "sourceId",
        "provider",
        "status",
        "metadata"
      ],
      "x-description": "The model representing a driver in Terminal."
    },
    "ExpandedVehicle": {
      "title": "Expanded Vehicle",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/VehicleId"
        },
        "sourceId": {
          "$ref": "#/$defs/SourceId"
        },
        "provider": {
          "$ref": "#/$defs/ProviderCode"
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "inactive"
          ],
          "description": "The status in the providers system"
        },
        "vin": {
          "title": "VIN",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "make": {
          "type": "string"
        },
        "model": {
          "type": "string"
        },
        "year": {
          "type": "integer"
        },
        "groups": {
          "type": "array",
          "description": "The groups the vehicle belongs to.",
          "items": {
            "$ref": "#/$defs/GroupId"
          }
        },
        "devices": {
          "type": "array",
          "description": "The devices installed in the vehicle.",
          "items": {
            "$ref": "#/$defs/DeviceId"
          }
        },
        "licensePlate": {
          "type": "object",
          "properties": {
            "state": {
              "$ref": "#/$defs/State"
            },
            "number": {
              "type": "string"
            }
          }
        },
        "fuelType": {
          "enum": [
            "gasoline",
            "diesel",
            "propane",
            "electric",
            "hybrid_gasoline",
            "hybrid_diesel",
            "biodiesel",
            "compressed_natural_gas",
            "liquefied_natural_gas",
            "ethanol",
            "hydrogen",
            "plug_in_hybrid"
          ]
        },
        "fuelEfficiency": {
          "type": "number",
          "deprecated": true,
          "description": "This field will be removed in the future as is not commonly available from providers."
        },
        "fuelTankCapacity": {
          "description": "Maximum amount of fuel vehicle can hold in liters.",
          "title": "Volume In Liters",
          "type": "number"
        },
        "createdAt": {
          "$ref": "#/$defs/SourceCreatedAt"
        },
        "updatedAt": {
          "$ref": "#/$defs/SourceUpdatedAt"
        },
        "metadata": {
          "$ref": "#/$defs/CoreEntityMetadata"
        },
        "raw": {
          "$ref": "#/$defs/RawDataList"
        }
      },
      "required": [
        "id",
        "sourceId",
        "provider",
        "status",
        "metadata"
      ],
      "x-description": "The model representing a vehicle in Terminal."
    },
    "GroupId": {
      "title": "GroupId",
      "type": "string",
      "format": "ulid"
    },
    "HOSDailyLogId": {
      "title": "HOSDailyLogId",
      "type": "string",
      "format": "ulid"
    },
    "ModifiedAt": {
      "title": "ModifiedAt",
      "type": "string",
      "format": "date-time",
      "description": "The date and time the record was last updated in Terminal. Note: this is not the date and time the record was updated in the provider's system."
    },
    "ProviderCode": {
      "type": "string",
      "description": "Every provider has a unique code to identify it across Terminal's system. You can find each provider's code under [provider details](/providers)."
    },
    "RawData": {
      "title": "RawData",
      "type": "object",
      "properties": {
        "provider": {
          "type": "string"
        },
        "schema": {
          "type": "string"
        },
        "extractedAt": {
          "type": "string"
        },
        "data": {
          "type": "object"
        }
      },
      "required": [
        "provider",
        "schema",
        "extractedAt",
        "data"
      ]
    },
    "RawDataList": {
      "title": "RawDataList",
      "type": "array",
      "items": {
        "$ref": "#/$defs/RawData"
      }
    },
    "SourceCreatedAt": {
      "title": "SourceCreatedAt",
      "type": "string",
      "format": "date-time",
      "description": "The date and time the record was created in the provider's system. This timestamp comes directly from the source system and represents when the data was originally created there. Note: not all providers expose this."
    },
    "SourceId": {
      "title": "SourceId",
      "type": "string",
      "description": "The ID used to represent the entity in the source system."
    },
    "SourceUpdatedAt": {
      "title": "SourceUpdatedAt",
      "type": "string",
      "format": "date-time",
      "description": "The date and time the record was updated in the provider's system. This timestamp comes directly from the source system and represents when the data was last updated there. Note: not all providers expose this."
    },
    "State": {
      "title": "State",
      "type": "string",
      "enum": [
        "AL",
        "AK",
        "AS",
        "AZ",
        "AR",
        "CA",
        "CO",
        "CT",
        "DE",
        "FL",
        "GA",
        "GU",
        "HI",
        "ID",
        "IL",
        "IN",
        "IA",
        "KS",
        "KY",
        "LA",
        "ME",
        "MD",
        "MA",
        "MI",
        "MN",
        "MP",
        "MS",
        "MO",
        "MT",
        "NE",
        "NV",
        "NH",
        "NJ",
        "NM",
        "NY",
        "NC",
        "ND",
        "OH",
        "OK",
        "OR",
        "PA",
        "PR",
        "RI",
        "SC",
        "SD",
        "TN",
        "TX",
        "UT",
        "VT",
        "VA",
        "WA",
        "WV",
        "WI",
        "WY",
        "VI",
        "AB",
        "BC",
        "MB",
        "NB",
        "NL",
        "NS",
        "ON",
        "PE",
        "QC",
        "SK",
        "NT",
        "NU",
        "UM",
        "YT",
        "DC"
      ],
      "description": "US State or Canadian Province"
    },
    "VehicleId": {
      "title": "VehicleId",
      "description": "Unique identifier for the vehicle in Terminal.",
      "type": "string",
      "format": "ulid",
      "pattern": "^vcl_[0-9A-HJKMNP-TV-Z]{26}$"
    }
  }
}