{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/theusedcarindex-com/json-schema/theusedcarindex-com-vehicle-risk-schema.json",
  "title": "VehicleRisk",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/theusedcarindex-com-openapi.json#/components/schemas/VehicleRisk",
  "type": "object",
  "properties": {
    "vehicle": {
      "$ref": "#/$defs/Vehicle"
    },
    "complaints": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "with_crash": {
          "type": "integer",
          "minimum": 0
        },
        "with_fire": {
          "type": "integer",
          "minimum": 0
        },
        "with_injury": {
          "type": "integer",
          "minimum": 0
        },
        "injuries": {
          "type": "integer",
          "minimum": 0
        },
        "deaths": {
          "type": "integer",
          "minimum": 0
        },
        "by_source": {
          "type": "object",
          "properties": {
            "both": {
              "type": "integer",
              "minimum": 0
            },
            "bulk_only": {
              "type": "integer",
              "minimum": 0
            },
            "api_only": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "both",
            "bulk_only",
            "api_only"
          ]
        },
        "coverage_complete": {
          "type": "boolean"
        },
        "top_systems": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "system": {
                "type": "string"
              },
              "count": {
                "type": "integer",
                "minimum": 0
              },
              "share": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "description": "Distinct complaint records naming this system divided by complaints.total; a single share never exceeds 1. Shares across systems can sum above 1."
              }
            },
            "required": [
              "system",
              "count",
              "share"
            ]
          }
        },
        "top_subsystems": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "system": {
                "type": "string"
              },
              "subsystem": {
                "type": "string",
                "minLength": 1
              },
              "count": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "system",
              "subsystem",
              "count"
            ]
          }
        }
      },
      "required": [
        "total",
        "with_crash",
        "with_fire",
        "with_injury",
        "injuries",
        "deaths",
        "by_source",
        "coverage_complete",
        "top_systems",
        "top_subsystems"
      ]
    },
    "recalls": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "do_not_drive": {
          "type": "integer",
          "minimum": 0
        },
        "park_outside": {
          "type": "integer",
          "minimum": 0
        },
        "potential_units_max": {
          "type": [
            "number",
            "null"
          ]
        },
        "by_system": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "system": {
                "type": "string"
              },
              "count": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "system",
              "count"
            ]
          }
        },
        "latest": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "campaign_number": {
                "type": "string"
              },
              "received_date": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "systems": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "defect": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "consequence": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "remedy": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "do_not_drive": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "park_outside": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "truncated": {
                "type": "boolean"
              },
              "url": {
                "type": "string"
              }
            },
            "required": [
              "campaign_number",
              "received_date",
              "systems",
              "defect",
              "consequence",
              "remedy",
              "do_not_drive",
              "park_outside",
              "truncated",
              "url"
            ]
          },
          "maxItems": 10
        }
      },
      "required": [
        "total",
        "do_not_drive",
        "park_outside",
        "potential_units_max",
        "by_system",
        "latest"
      ]
    },
    "investigations": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "open": {
          "type": "integer",
          "minimum": 0
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "action_number": {
                "type": "string"
              },
              "opened_date": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "closed_date": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "campaign_numbers": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "subject": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "summary": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "systems": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "url": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "action_number",
              "opened_date",
              "closed_date",
              "campaign_numbers",
              "subject",
              "summary",
              "systems",
              "url"
            ]
          }
        }
      },
      "required": [
        "total",
        "open",
        "items"
      ]
    },
    "manufacturer_communications": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "by_system": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "system": {
                "type": "string"
              },
              "subsystem": {
                "type": "string",
                "description": "The empty string means all subsystems of this system; by_subsystem holds the subsystem rows."
              },
              "source_field": {
                "type": "string"
              },
              "count": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "system",
              "subsystem",
              "source_field",
              "count"
            ]
          }
        },
        "by_subsystem": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "system": {
                "type": "string"
              },
              "subsystem": {
                "type": "string",
                "minLength": 1
              },
              "source_field": {
                "type": "string"
              },
              "count": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "system",
              "subsystem",
              "source_field",
              "count"
            ]
          },
          "maxItems": 25
        },
        "recent": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "maxItems": 10
        }
      },
      "required": [
        "total",
        "by_system",
        "by_subsystem",
        "recent"
      ]
    },
    "rate": {
      "$ref": "#/$defs/Rate"
    },
    "model_tags": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/ModelTags"
        }
      ]
    },
    "model_tags_null_reason": {
      "enum": [
        null,
        "no_complaints",
        "model_year_not_tagged",
        "no_tagged_complaints"
      ],
      "description": "null when tags exist; no_complaints when complaints.total is zero; model_year_not_tagged when the model year is below the first tagged year in data_build.tag_coverage (2012 when that receipt field is absent); no_tagged_complaints when the year is covered but no tagged complaints exist."
    },
    "data": {
      "type": "object",
      "properties": {
        "built_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "url"
            ]
          }
        },
        "notes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "built_at",
        "sources",
        "notes"
      ]
    }
  },
  "required": [
    "vehicle",
    "complaints",
    "recalls",
    "investigations",
    "manufacturer_communications",
    "rate",
    "model_tags",
    "model_tags_null_reason",
    "data"
  ],
  "$defs": {
    "ModelTags": {
      "type": "object",
      "properties": {
        "model": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 2,
              "uniqueItems": true
            }
          ],
          "description": "Stored tagged_by provenance. One model string, or all model versions if several contributed."
        },
        "schema_version": {
          "const": "tag-v1"
        },
        "tagged_complaints": {
          "type": "integer",
          "minimum": 0
        },
        "complaints_total": {
          "type": "integer",
          "minimum": 0
        },
        "tagged_share": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Tagged complaints divided by the NHTSA complaint total."
        },
        "failure_modes": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "enum": [
                  "mechanical_failure",
                  "electrical_electronic",
                  "fluid_or_fuel_leak",
                  "fire_or_overheating",
                  "loss_of_control",
                  "restraint_or_airbag",
                  "visibility_or_lighting",
                  "structural_or_corrosion",
                  "noise_or_comfort",
                  "unclear"
                ]
              },
              "count": {
                "type": "integer",
                "minimum": 0
              },
              "share": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "description": "Count divided by tagged_complaints."
              },
              "mean_confidence": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "description": "Stored mean of the model probabilities for this chosen label; not accuracy."
              },
              "high_confidence_count": {
                "type": "integer",
                "minimum": 0,
                "description": "Confidence at least 0.8."
              },
              "low_confidence_count": {
                "type": "integer",
                "minimum": 0,
                "description": "Confidence below 0.5."
              }
            },
            "required": [
              "label",
              "count",
              "share",
              "mean_confidence",
              "high_confidence_count",
              "low_confidence_count"
            ]
          },
          "maxItems": 10
        },
        "severities": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "enum": [
                  "none",
                  "low",
                  "moderate",
                  "high",
                  "critical"
                ]
              },
              "count": {
                "type": "integer",
                "minimum": 0
              },
              "share": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "description": "Count divided by tagged_complaints."
              },
              "mean_confidence": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "description": "Stored mean of the model probabilities for this chosen label; not accuracy."
              },
              "high_confidence_count": {
                "type": "integer",
                "minimum": 0,
                "description": "Confidence at least 0.8."
              },
              "low_confidence_count": {
                "type": "integer",
                "minimum": 0,
                "description": "Confidence below 0.5."
              }
            },
            "required": [
              "label",
              "count",
              "share",
              "mean_confidence",
              "high_confidence_count",
              "low_confidence_count"
            ]
          },
          "maxItems": 5
        },
        "confidence_note": {
          "type": "string",
          "description": "Confidence is the model's own probability for the label it chose (0 to 1), not accuracy."
        },
        "note": {
          "type": "string",
          "description": "Jev tags exist for model years 2012 and newer; model year 2012 is only partly tagged and earlier model years carry no tags. tagged_share gives each vehicle's tagged fraction; about 43 percent of all complaints are tagged. Built from data_build.tag_coverage: model years {full_from_model_year} and newer are tagged in full, the partial year or range in part when those years differ (a single year is written once), and earlier model years have no tags. When tag_coverage is absent, the note says tagged_share gives the vehicle's tagged fraction. NHTSA's own flags remain separate in the complaints block."
        }
      },
      "required": [
        "model",
        "schema_version",
        "tagged_complaints",
        "complaints_total",
        "tagged_share",
        "failure_modes",
        "severities",
        "confidence_note",
        "note"
      ]
    },
    "Rate": {
      "type": "object",
      "properties": {
        "complaints_per_100k_sold": {
          "type": [
            "number",
            "null"
          ]
        },
        "units_sold": {
          "type": [
            "number",
            "null"
          ]
        },
        "sales_year": {
          "type": [
            "number",
            "null"
          ]
        },
        "basis": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "null_reason": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "complaints_per_100k_sold",
        "units_sold",
        "sales_year",
        "basis",
        "source",
        "source_url",
        "null_reason"
      ]
    },
    "Vehicle": {
      "type": "object",
      "properties": {
        "make": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "year": {
          "type": "integer",
          "minimum": 2000,
          "maximum": 2027
        },
        "family_key": {
          "type": "string"
        },
        "matched_models": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "model": {
                "type": "string"
              },
              "complaints": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "model",
              "complaints"
            ]
          },
          "description": "matched_models lists the vehicle's own NHTSA labels that carry complaints, or all of its own labels with count 0 when the vehicle has no complaints; other_names lists zero-count own labels of a vehicle that has complaints and alternate NHTSA labels, including lookup-only aliases."
        },
        "other_names": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "matched_models lists the vehicle's own NHTSA labels that carry complaints, or all of its own labels with count 0 when the vehicle has no complaints; other_names lists zero-count own labels of a vehicle that has complaints and alternate NHTSA labels, including lookup-only aliases."
        },
        "resolved_via": {
          "enum": [
            "vehicle_models",
            "model_aliases",
            "family_key"
          ]
        }
      },
      "required": [
        "make",
        "model",
        "year",
        "family_key",
        "matched_models",
        "other_names",
        "resolved_via"
      ]
    }
  }
}