{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://thewarrecord.com/api/v1/schema/event.json",
 "title": "event",
 "type": "object",
 "required": [
  "id",
  "type",
  "conflict",
  "theatre",
  "title",
  "status",
  "status_basis",
  "category",
  "occurred",
  "place",
  "attribution",
  "citations",
  "revision",
  "history",
  "record_state",
  "schema_version",
  "published_at"
 ],
 "properties": {
  "record_state": {
   "enum": [
    "active",
    "merged",
    "withdrawn"
   ]
  },
  "merged_into": {
   "type": "string"
  },
  "withdrawn_reason": {
   "type": "string"
  },
  "schema_version": {
   "const": 1
  },
  "created_at": {
   "type": "string",
   "format": "date-time"
  },
  "last_changed": {
   "type": "string",
   "format": "date-time"
  },
  "id": {
   "type": "string",
   "pattern": "^ev-\\d{8}-[0-9a-hjkmnp-tv-z]{4}$"
  },
  "type": {
   "const": "event"
  },
  "conflict": {
   "type": "string",
   "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
  },
  "theatre": {
   "type": "string",
   "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
  },
  "title": {
   "type": "string",
   "maxLength": 140
  },
  "summary": {
   "type": "string"
  },
  "status": {
   "enum": [
    "confirmed",
    "reported",
    "disputed"
   ]
  },
  "status_basis": {
   "enum": [
    "independent_origins",
    "verified_visual_or_sensor",
    "admission_plus_independent",
    "single_origin",
    "one_side_only",
    "conflicting_origins"
   ]
  },
  "category": {
   "type": "object",
   "required": [
    "kind",
    "military"
   ],
   "properties": {
    "kind": {
     "type": "string"
    },
    "military": {
     "type": "boolean"
    },
    "target_class": {
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "occurred": {
   "type": "object",
   "required": [
    "date"
   ],
   "properties": {
    "date": {
     "type": "string",
     "format": "date"
    },
    "start": {
     "type": "string",
     "format": "date-time"
    },
    "end": {
     "type": "string",
     "format": "date-time"
    },
    "time_precision": {
     "enum": [
      "exact",
      "day",
      "approximate"
     ]
    }
   },
   "additionalProperties": false
  },
  "place": {
   "type": "string",
   "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
  },
  "actors": {
   "type": "object",
   "properties": {
    "initiator": {
     "type": "array",
     "items": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
     }
    },
    "target": {
     "type": "array",
     "items": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
     }
    }
   },
   "additionalProperties": false
  },
  "attribution": {
   "type": "object",
   "required": [
    "status"
   ],
   "properties": {
    "status": {
     "enum": [
      "acknowledged",
      "attributed",
      "contested",
      "single_source",
      "unknown"
     ]
    },
    "basis": {
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "harm": {
   "type": "object"
  },
  "citations": {
   "type": "array",
   "minItems": 1,
   "items": {
    "type": "object",
    "required": [
     "source",
     "url",
     "origin",
     "role",
     "published_at",
     "accessed_at"
    ],
    "properties": {
     "source": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
     },
     "url": {
      "type": "string",
      "format": "uri"
     },
     "archive_url": {
      "type": "string",
      "format": "uri"
     },
     "origin": {
      "type": "string",
      "minLength": 3,
      "description": "The first-hand material this citation relies on. Independence is counted on distinct origins, not outlets."
     },
     "role": {
      "enum": [
       "evidence",
       "corroboration",
       "contradiction",
       "claim_origin",
       "count",
       "visual",
       "sensor"
      ]
     },
     "supports": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "published_at": {
      "type": "string",
      "format": "date-time"
     },
     "accessed_at": {
      "type": "string",
      "format": "date-time"
     },
     "language": {
      "type": "string"
     },
     "excerpt": {
      "type": "string",
      "maxLength": 200
     }
    },
    "additionalProperties": false
   }
  },
  "published_at": {
   "type": "string",
   "format": "date-time"
  },
  "provenance": {
   "enum": [
    "daily",
    "backfilled",
    "leiden",
    "monthly_summary",
    "who_ssa",
    "unesco"
   ]
  },
  "dataset_ref": {
   "type": "string",
   "description": "The entry in the dataset this event comes from (for example \"WHO SSA 12345\"). Each entry is its own event; entries are never merged."
  },
  "revision": {
   "type": "integer",
   "minimum": 1
  },
  "history": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "at",
     "batch",
     "field",
     "from",
     "to",
     "reason"
    ],
    "properties": {
     "at": {
      "type": "string",
      "format": "date-time"
     },
     "batch": {
      "type": "string",
      "minLength": 3
     },
     "field": {
      "type": "string"
     },
     "from": {},
     "to": {},
     "rule": {
      "type": "string"
     },
     "reason": {
      "type": "string",
      "minLength": 3
     },
     "citations": {
      "type": "array",
      "items": {
       "type": "integer",
       "minimum": 0
      }
     }
    },
    "additionalProperties": false
   }
  }
 },
 "additionalProperties": false
}
