{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentpress.tv/api/v1/schema.json",
  "title": "AgentPress event",
  "description": "One event (a news story grouped from several sources). schema_version 1.",
  "type": "object",
  "required": [
    "schema_version",
    "id",
    "url",
    "title",
    "title_origin",
    "summary",
    "level",
    "domain",
    "importance",
    "relevance",
    "sources_n",
    "independent_24h",
    "first_reported",
    "updated",
    "entities",
    "outlets",
    "candidate_question",
    "image"
  ],
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[1-9][0-9]*$"
    },
    "url": {
      "type": "string",
      "format": "uri"
    },
    "title": {
      "type": "string"
    },
    "title_origin": {
      "enum": [
        "article",
        "source"
      ]
    },
    "summary": {
      "type": [
        "string",
        "null"
      ]
    },
    "level": {
      "type": [
        "integer",
        "null"
      ],
      "enum": [
        1,
        2,
        3,
        null
      ]
    },
    "domain": {
      "enum": [
        "ai",
        "macro",
        "realestate",
        "other"
      ]
    },
    "importance": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "score",
        "components"
      ],
      "additionalProperties": false,
      "properties": {
        "score": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "maximum": 100
        },
        "components": {
          "type": "object",
          "required": [
            "magnitude",
            "sources",
            "novelty",
            "question"
          ],
          "additionalProperties": false,
          "properties": {
            "magnitude": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "maximum": 100
            },
            "sources": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "maximum": 100
            },
            "novelty": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "maximum": 100
            },
            "question": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "maximum": 100
            }
          }
        }
      }
    },
    "relevance": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0,
      "maximum": 100
    },
    "sources_n": {
      "type": "integer",
      "minimum": 1
    },
    "independent_24h": {
      "type": "integer",
      "minimum": 0
    },
    "first_reported": {
      "type": "string",
      "format": "date-time"
    },
    "updated": {
      "type": "string",
      "format": "date-time"
    },
    "entities": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "outlets": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "candidate_question": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "type",
        "text",
        "resolution_source",
        "deadline"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": [
            "string",
            "null"
          ]
        },
        "text": {
          "type": "string"
        },
        "resolution_source": {
          "type": [
            "string",
            "null"
          ]
        },
        "deadline": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "image": {
      "description": "Stock photo of the approved article (Pexels licence), or null. Illustrative, not a photo of the event. alt describes what is visible.",
      "type": [
        "object",
        "null"
      ],
      "required": [
        "url",
        "alt",
        "credit",
        "credit_url",
        "license"
      ],
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "alt": {
          "type": "string"
        },
        "credit": {
          "type": "string"
        },
        "credit_url": {
          "type": "string",
          "format": "uri"
        },
        "license": {
          "type": "string"
        }
      }
    },
    "article": {
      "description": "Event detail only. Present (or null) when requested via /api/v1/events/{id}.",
      "type": [
        "object",
        "null"
      ],
      "required": [
        "title",
        "body",
        "published"
      ],
      "additionalProperties": false,
      "properties": {
        "title": {
          "type": "string"
        },
        "body": {
          "type": "string"
        },
        "published": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "sources": {
      "description": "Event detail only. Title, outlet, date and link: never the source text.",
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "n",
          "published_utc",
          "outlet",
          "title",
          "url"
        ],
        "additionalProperties": false,
        "properties": {
          "n": {
            "type": "integer",
            "minimum": 1
          },
          "published_utc": {
            "type": "string",
            "format": "date-time"
          },
          "outlet": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  }
}
