{
  "openapi": "3.1.0",
  "info": {
    "title": "nexyo Evidence",
    "version": "0.1.0-preview",
    "summary": "Company evidence prefetch across European registers.",
    "description": "Nimmt {name, country} entgegen und liefert eine provenienzgesicherte Evidenzakte plus vor-ausgefülltes Onboarding-Formular. Preview-Skizze, produktive Endpunkte folgen.",
    "contact": {"name": "nexyo", "email": "info@nexyo.io", "url": "https://trust.nexyo.io"}
  },
  "servers": [{"url": "https://evidence.nexyo.io", "description": "preview"}],
  "paths": {
    "/v1/company/prefetch": {
      "post": {
        "summary": "Prefetch company evidence from public registers",
        "operationId": "prefetch_company_evidence",
        "requestBody": {
          "required": true,
          "content": {"application/json": {"schema": {"$ref": "#/components/schemas/PrefetchQuery"}}}
        },
        "responses": {
          "200": {
            "description": "EvidenceSet with one or more matches",
            "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EvidenceSet"}}}
          }
        }
      }
    },
    "/v1/evidence/{evidence_id}/refresh": {
      "post": {
        "summary": "Force refresh of a previously issued EvidenceSet",
        "operationId": "refresh_evidence",
        "parameters": [{"name": "evidence_id", "in": "path", "required": true, "schema": {"type": "string"}}],
        "responses": {"200": {"description": "Refreshed EvidenceSet", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EvidenceSet"}}}}}
      }
    },
    "/healthz": {"get": {"summary": "Liveness", "responses": {"200": {"description": "ok"}}}}
  },
  "components": {
    "schemas": {
      "PrefetchQuery": {
        "type": "object", "required": ["name", "country"],
        "properties": {
          "name": {"type": "string", "example": "datahub.tirol GmbH"},
          "country": {"type": "string", "description": "ISO 3166-1 alpha-2", "example": "AT"},
          "hint": {"type": "string", "nullable": true, "description": "Optional: known registration number, LEI, or VAT-ID"}
        }
      },
      "EvidenceSet": {
        "type": "object",
        "properties": {
          "query": {"$ref": "#/components/schemas/PrefetchQuery"},
          "matches": {"type": "array", "items": {"$ref": "#/components/schemas/CompanyMatch"}},
          "metrics": {"type": "object", "properties": {
            "latency_ms": {"type": "integer"},
            "sources_hit": {"type": "integer"},
            "sources_failed": {"type": "integer"}
          }}
        }
      },
      "CompanyMatch": {
        "type": "object",
        "properties": {
          "confidence": {"type": "number", "minimum": 0, "maximum": 1},
          "canonical": {
            "type": "object",
            "properties": {
              "legal_name": {"type": "string"},
              "legal_form": {"type": "string"},
              "registration_number": {"type": "string"},
              "vat_id": {"type": "string"},
              "lei": {"type": "string"},
              "seat": {"type": "object"},
              "status": {"type": "string", "enum": ["active", "inactive", "unknown"]},
              "as_of": {"type": "string", "format": "date"}
            }
          },
          "representatives": {"type": "array", "items": {"type": "object"}},
          "evidences": {"type": "array", "items": {"$ref": "#/components/schemas/EvidenceArtifact"}},
          "checks": {
            "type": "object",
            "properties": {
              "C1": {"$ref": "#/components/schemas/EvidenceGrade"},
              "C2": {"$ref": "#/components/schemas/EvidenceGrade"},
              "C3": {"$ref": "#/components/schemas/EvidenceGrade"}
            }
          },
          "gaps": {"type": "array", "items": {"type": "string"}},
          "presentation": {"type": "object", "properties": {
            "format": {"type": "string", "example": "vp+jwt"},
            "signed_by": {"type": "string", "example": "did:web:trust.nexyo.io"},
            "kid": {"type": "string"}
          }}
        }
      },
      "EvidenceArtifact": {
        "type": "object",
        "properties": {
          "field": {"type": "string"},
          "value": {},
          "source": {"type": "string", "enum": ["VIES", "GLEIF", "BRIS", "OpenCorporates", "Kompass", "Hoppenstedt", "Creditsafe", "national"]},
          "retrieved_at": {"type": "string", "format": "date-time"},
          "contract_status": {"type": "string", "enum": ["free", "freemium", "commercial"]},
          "evidence_grade": {"$ref": "#/components/schemas/EvidenceGrade"},
          "raw_ref": {"type": "string"}
        }
      },
      "EvidenceGrade": {
        "type": "string", "enum": ["verified", "attested", "declared"],
        "description": "verified: authoritative source; attested: third-party aggregator; declared: self-asserted"
      }
    }
  }
}
