{
  "openapi": "3.1.0",
  "info": {
    "title": "Europe True View Partner API",
    "version": "1.0.0",
    "description": "Read published incident data and synchronize changes."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "security": [
    {
      "PartnerBearer": []
    }
  ],
  "paths": {
    "/api/v1/incidents": {
      "get": {
        "operationId": "listIncidents",
        "summary": "Filter published incidents",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "Repeat for multiple country codes.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[A-Z]{2}$"
              },
              "maxItems": 20
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "description": "Inclusive start date.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Inclusive end date.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "severity_min",
            "in": "query",
            "required": false,
            "description": "Minimum severity.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 5
            }
          },
          {
            "name": "severity_max",
            "in": "query",
            "required": false,
            "description": "Maximum severity.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 5
            }
          },
          {
            "name": "verification",
            "in": "query",
            "required": false,
            "description": "Repeat for multiple statuses.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "verified",
                  "partially_confirmed",
                  "unclear"
                ]
              },
              "maxItems": 3
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Undated records appear last.",
            "schema": {
              "type": "string",
              "enum": [
                "date_asc",
                "date_desc"
              ],
              "default": "date_desc"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum results in this response.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque continuation cursor. Keep the other filters and sort unchanged.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 2048
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Incident"
                      }
                    },
                    "page": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "next_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "page"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Valid partner token required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Quota reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying, when provided."
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying, when provided."
              }
            }
          }
        }
      }
    },
    "/api/v1/incidents/{id}": {
      "get": {
        "operationId": "getIncident",
        "summary": "Read a published incident and its sources",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Stable incident UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/IncidentDetail"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Valid partner token required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Quota reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying, when provided."
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying, when provided."
              }
            }
          },
          "404": {
            "description": "No published record for this ID",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metadata": {
      "get": {
        "operationId": "getMetadata",
        "summary": "Read supported filters, limits and permissions",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "version": {
                          "type": "string"
                        },
                        "countries": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "code",
                              "name"
                            ]
                          }
                        },
                        "verification": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "verified",
                              "partially_confirmed",
                              "unclear"
                            ]
                          }
                        },
                        "severity": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "value": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 5
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "value",
                              "label"
                            ]
                          }
                        },
                        "sort": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "date_asc",
                              "date_desc"
                            ],
                            "default": "date_desc"
                          }
                        },
                        "default_limit": {
                          "type": "integer"
                        },
                        "max_limit": {
                          "type": "integer"
                        },
                        "scopes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "version",
                        "countries",
                        "verification",
                        "severity",
                        "sort",
                        "default_limit",
                        "max_limit",
                        "scopes"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Valid partner token required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Quota reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying, when provided."
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying, when provided."
              }
            }
          }
        }
      }
    },
    "/api/v1/changes": {
      "get": {
        "operationId": "listChanges",
        "summary": "Read ordered changes with incidents:changes permission",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum results in this response.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Omit to start at the beginning, use latest to get a starting checkpoint, or pass the previous response cursor.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 2048
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Change"
                      }
                    },
                    "page": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "string"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "next_cursor",
                        "has_more"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "page"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Valid partner token required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Quota reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying, when provided."
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying, when provided."
              }
            }
          },
          "403": {
            "description": "Token lacks change feed permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "PartnerBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Opaque partner token"
      }
    },
    "schemas": {
      "Incident": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "date_precision": {
            "type": "string"
          },
          "severity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "verification": {
            "type": "string",
            "enum": [
              "verified",
              "partially_confirmed",
              "unclear"
            ]
          },
          "published_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "reference",
          "title",
          "summary",
          "country",
          "date",
          "date_precision",
          "severity",
          "verification",
          "published_at",
          "updated_at"
        ]
      },
      "Source": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "publisher": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "url",
          "title",
          "publisher"
        ]
      },
      "Change": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "operation": {
            "type": "string",
            "enum": [
              "upsert",
              "withdraw"
            ]
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "operation",
          "recorded_at"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "status": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "status",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "IncidentDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Incident"
          },
          {
            "type": "object",
            "properties": {
              "sources": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Source"
                },
                "maxItems": 30
              }
            },
            "required": [
              "sources"
            ]
          }
        ]
      }
    }
  }
}
