{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Device",
  "type": "object",
  "properties": {
    "connectionId": {
      "type": "string",
      "description": "The ID of the connection that this record belongs to."
    },
    "id": {
      "title": "DeviceId",
      "type": "string",
      "format": "ulid"
    },
    "sourceId": {
      "title": "SourceId",
      "type": "string",
      "description": "The ID used to represent the entity in the source system."
    },
    "provider": {
      "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)."
    },
    "type": {
      "description": "The type of device",
      "title": "Device Type",
      "type": "string",
      "enum": ["tracker", "camera", "phone"]
    },
    "vehicle": {
      "description": "The vehicle that the device is associated with.",
      "title": "VehicleId",
      "type": "string",
      "format": "ulid",
      "pattern": "^vcl_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "description": {
      "type": "string",
      "description": "The description or model of the device"
    },
    "serialNumber": {
      "type": "string",
      "description": "The serial number of the device"
    },
    "lastConnectedAt": {
      "description": "The time the device was last connected",
      "title": "ISODateTime",
      "type": "string",
      "format": "date-time"
    },
    "createdAt": {
      "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."
    },
    "updatedAt": {
      "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."
    },
    "metadata": {
      "title": "CoreEntityMetadata",
      "type": "object",
      "description": "Internal metadata about the record.",
      "required": ["addedAt", "modifiedAt"],
      "properties": {
        "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."
        },
        "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."
        },
        "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."
        },
        "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)."
        }
      }
    },
    "raw": {
      "title": "RawDataList",
      "type": "array",
      "items": {
        "title": "RawData",
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "schema": {
            "type": "string"
          },
          "extractedAt": {
            "type": "string"
          },
          "data": {
            "type": "object"
          }
        },
        "required": ["provider", "schema", "extractedAt", "data"]
      }
    }
  },
  "required": ["connectionId", "id", "sourceId", "provider", "type", "metadata"]
}
