{
  "openapi": "3.1.0",
  "info": {
    "title": "PlatPhorm Evidence API",
    "version": "1.0.0",
    "description": "Deterministic claim verification ledger. Reads are open; writes require PLATPHORM_API_KEY via Bearer or X-PlatPhorm-API-Key. Every response carries request_id and trace_id for log correlation."
  },
  "servers": [
    {
      "url": "https://evidence.platphormnews.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "serviceKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-PlatPhorm-API-Key"
      },
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "evidence.case.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "caseId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "default": "ACTIVE",
            "type": "string"
          },
          "summary": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "caseId",
          "title",
          "status",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": false
      },
      "evidence.source-coverage.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "caseId": {
            "type": "string"
          },
          "sourceType": {
            "type": "string"
          },
          "coverageState": {
            "type": "string",
            "enum": [
              "PRESENT",
              "PARTIAL",
              "ABSENT",
              "UNKNOWN",
              "DEGRADED"
            ]
          },
          "firstObserved": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastObserved": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "eventCount": {
            "default": 0,
            "type": "number"
          },
          "sourceService": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "knownGaps": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "id",
          "caseId",
          "sourceType",
          "coverageState",
          "eventCount",
          "knownGaps"
        ],
        "additionalProperties": false
      },
      "evidence.coverage-gap.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "caseId": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "sourceType": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "impact": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "severity": {
            "type": "string",
            "enum": [
              "informational",
              "material",
              "critical"
            ]
          }
        },
        "required": [
          "id",
          "caseId",
          "category",
          "impact",
          "severity"
        ],
        "additionalProperties": false
      },
      "evidence.claim.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "caseId": {
            "type": "string"
          },
          "statement": {
            "type": "string"
          },
          "classification": {
            "type": "string",
            "enum": [
              "OBSERVED",
              "INFERRED",
              "HYPOTHESIS",
              "UNKNOWN"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "DRAFT",
              "SUPPORTED",
              "PARTIALLY_SUPPORTED",
              "CONTRADICTED",
              "UNSUPPORTED",
              "UNVERIFIABLE",
              "SUPERSEDED"
            ]
          },
          "currentVersion": {
            "default": 1,
            "type": "number"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "caseId",
          "statement",
          "classification",
          "status",
          "currentVersion",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": false
      },
      "evidence.claim-version.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "claimId": {
            "type": "string"
          },
          "version": {
            "type": "number"
          },
          "statement": {
            "type": "string"
          },
          "classification": {
            "type": "string",
            "enum": [
              "OBSERVED",
              "INFERRED",
              "HYPOTHESIS",
              "UNKNOWN"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "DRAFT",
              "SUPPORTED",
              "PARTIALLY_SUPPORTED",
              "CONTRADICTED",
              "UNSUPPORTED",
              "UNVERIFIABLE",
              "SUPERSEDED"
            ]
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "claimId",
          "version",
          "statement",
          "classification",
          "status",
          "createdAt"
        ],
        "additionalProperties": false
      },
      "evidence.reference.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "observation",
              "relationship",
              "activity_chain",
              "entity",
              "artifact",
              "external_knowledge",
              "trace",
              "claim"
            ]
          },
          "ref": {
            "type": "string"
          },
          "sourceService": {
            "type": "string"
          },
          "sourceType": {
            "type": "string"
          },
          "stance": {
            "default": "supporting",
            "type": "string",
            "enum": [
              "supporting",
              "contradicting",
              "neutral"
            ]
          },
          "timestamp": {
            "type": "string"
          },
          "resolved": {
            "type": "boolean"
          },
          "resolution": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "required": [
          "type",
          "ref",
          "stance"
        ],
        "additionalProperties": false
      },
      "evidence.artifact-reference.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "artifactId": {
            "type": "string"
          },
          "sourceService": {
            "default": "files",
            "type": "string"
          },
          "contentDigest": {
            "type": "string"
          },
          "mediaType": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "size": {
            "type": "number"
          },
          "uri": {
            "type": "string"
          },
          "provenance": {
            "type": "object",
            "properties": {
              "createdAt": {
                "type": "string"
              },
              "createdBy": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "human",
                      "agent",
                      "rule",
                      "service",
                      "import"
                    ]
                  },
                  "id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false
              },
              "sourceService": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "sourceOperation": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "traceId": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "inputRefs": {
                "default": [],
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "contractVersion": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "createdAt",
              "createdBy",
              "inputRefs"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "artifactId",
          "sourceService"
        ],
        "additionalProperties": false
      },
      "evidence.verification-result.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "claimId": {
            "type": "string"
          },
          "version": {
            "default": 1,
            "type": "number"
          },
          "status": {
            "type": "string",
            "enum": [
              "DRAFT",
              "SUPPORTED",
              "PARTIALLY_SUPPORTED",
              "CONTRADICTED",
              "UNSUPPORTED",
              "UNVERIFIABLE",
              "SUPERSEDED"
            ]
          },
          "supportedComponents": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unsupportedComponents": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidenceRefs": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "contradictoryEvidenceRefs": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "coverageGaps": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "verificationRules": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "checks": {
            "default": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rule": {
                  "type": "string"
                },
                "passed": {
                  "type": "boolean"
                },
                "severity": {
                  "type": "string",
                  "enum": [
                    "info",
                    "warning",
                    "error"
                  ]
                },
                "detail": {
                  "type": "string"
                },
                "refs": {
                  "default": [],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "rule",
                "passed",
                "severity",
                "detail",
                "refs"
              ],
              "additionalProperties": false
            }
          },
          "digest": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "claimId",
          "version",
          "status",
          "supportedComponents",
          "unsupportedComponents",
          "evidenceRefs",
          "contradictoryEvidenceRefs",
          "coverageGaps",
          "verificationRules",
          "checks",
          "digest"
        ],
        "additionalProperties": false
      },
      "evidence.evidence-bundle.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "bundleId": {
            "type": "string"
          },
          "claimId": {
            "type": "string"
          },
          "version": {
            "type": "number"
          },
          "evidence": {
            "default": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "observation",
                    "relationship",
                    "activity_chain",
                    "entity",
                    "artifact",
                    "external_knowledge",
                    "trace",
                    "claim"
                  ]
                },
                "ref": {
                  "type": "string"
                },
                "sourceService": {
                  "type": "string"
                },
                "sourceType": {
                  "type": "string"
                },
                "stance": {
                  "default": "supporting",
                  "type": "string",
                  "enum": [
                    "supporting",
                    "contradicting",
                    "neutral"
                  ]
                },
                "timestamp": {
                  "type": "string"
                },
                "resolved": {
                  "type": "boolean"
                },
                "resolution": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                }
              },
              "required": [
                "type",
                "ref",
                "stance"
              ],
              "additionalProperties": false
            }
          },
          "contradictions": {
            "default": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "observation",
                    "relationship",
                    "activity_chain",
                    "entity",
                    "artifact",
                    "external_knowledge",
                    "trace",
                    "claim"
                  ]
                },
                "ref": {
                  "type": "string"
                },
                "sourceService": {
                  "type": "string"
                },
                "sourceType": {
                  "type": "string"
                },
                "stance": {
                  "default": "supporting",
                  "type": "string",
                  "enum": [
                    "supporting",
                    "contradicting",
                    "neutral"
                  ]
                },
                "timestamp": {
                  "type": "string"
                },
                "resolved": {
                  "type": "boolean"
                },
                "resolution": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                }
              },
              "required": [
                "type",
                "ref",
                "stance"
              ],
              "additionalProperties": false
            }
          },
          "gaps": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "externalReferences": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string"
          },
          "digest": {
            "type": "string"
          }
        },
        "required": [
          "bundleId",
          "claimId",
          "version",
          "evidence",
          "contradictions",
          "gaps",
          "externalReferences",
          "createdAt",
          "digest"
        ],
        "additionalProperties": false
      },
      "evidence.receipt.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "receiptId": {
            "type": "string"
          },
          "operation": {
            "type": "string"
          },
          "claimId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "verificationId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "bundleId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "digest": {
            "type": "string"
          },
          "traceId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "receiptId",
          "operation",
          "digest",
          "createdAt"
        ],
        "additionalProperties": false
      },
      "evidence.provenance.v1": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "createdAt": {
            "type": "string"
          },
          "createdBy": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent",
                  "rule",
                  "service",
                  "import"
                ]
              },
              "id": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          "sourceService": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "sourceOperation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "traceId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "inputRefs": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "contractVersion": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "createdAt",
          "createdBy",
          "inputRefs"
        ],
        "additionalProperties": false
      },
      "Meta": {
        "type": "object",
        "properties": {
          "service": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "contract_version": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          },
          "trace_id": {
            "type": "string"
          },
          "latency_ms": {
            "type": "number"
          },
          "timestamp": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/api/health": {
      "get": {
        "summary": "Liveness and dependency health",
        "responses": {
          "200": {
            "description": "Healthy"
          },
          "503": {
            "description": "Degraded"
          }
        }
      }
    },
    "/api/v1/health": {
      "get": {
        "summary": "Versioned health alias",
        "responses": {
          "200": {
            "description": "Healthy"
          },
          "503": {
            "description": "Degraded"
          }
        }
      }
    },
    "/api/mcp": {
      "get": {
        "summary": "MCP metadata and usage",
        "responses": {
          "200": {
            "description": "MCP registry"
          }
        }
      },
      "post": {
        "summary": "MCP JSON-RPC 2.0 transport",
        "responses": {
          "200": {
            "description": "JSON-RPC response"
          },
          "204": {
            "description": "Notification accepted"
          }
        }
      }
    },
    "/api/v1/cases": {
      "get": {
        "summary": "List cases",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "details": {}
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "ok",
                    "data",
                    "error",
                    "meta"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/datasets": {
      "get": {
        "summary": "List public-safe Evidence dataset summaries",
        "responses": {
          "200": {
            "description": "Dataset summaries"
          }
        }
      },
      "post": {
        "summary": "Correlate and persist a bounded SIEM dataset",
        "security": [
          {
            "serviceKey": []
          },
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "caseId",
                  "title",
                  "events"
                ],
                "properties": {
                  "caseId": {
                    "type": "string",
                    "maxLength": 128
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "summary": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "filename": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "events": {
                    "oneOf": [
                      {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 10000,
                        "items": {
                          "type": "object"
                        }
                      },
                      {
                        "type": "object",
                        "required": [
                          "events"
                        ],
                        "properties": {
                          "events": {
                            "type": "array",
                            "minItems": 1,
                            "maxItems": 10000,
                            "items": {
                              "type": "object"
                            }
                          }
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Dataset persisted"
          },
          "401": {
            "description": "Unauthorized"
          },
          "409": {
            "description": "Dataset ID already exists"
          },
          "422": {
            "description": "Invalid dataset"
          },
          "502": {
            "description": "Correlate unavailable"
          }
        }
      }
    },
    "/api/v1/datasets/{caseId}/events": {
      "get": {
        "summary": "Read sanitized dataset events for a trusted server-side consumer",
        "security": [
          {
            "serviceKey": []
          },
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sanitized SIEM events"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Dataset not found"
          }
        }
      }
    },
    "/api/v1/cases/{caseId}": {
      "get": {
        "summary": "Case detail with claims, coverage, and gaps",
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v1/claims": {
      "get": {
        "summary": "List claims (paginated)",
        "parameters": [
          {
            "name": "caseId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Create a claim",
        "security": [
          {
            "serviceKey": []
          },
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/evidence.claim.v1"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "401": {
            "description": "Unauthorized"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/api/v1/claims/{id}": {
      "get": {
        "summary": "Claim detail: evidence, versions, verifications, bundles, receipts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v1/claims/{id}/verify": {
      "post": {
        "summary": "Run deterministic verification and persist result + receipt",
        "security": [
          {
            "serviceKey": []
          },
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Verified"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v1/verify": {
      "post": {
        "summary": "Stateless deterministic verification (no writes). Same input => same digest.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verdict"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/api/v1/receipts": {
      "get": {
        "summary": "List evidence receipts",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/import/correlate": {
      "post": {
        "summary": "Import source material from Correlate (idempotent, produces receipt)",
        "security": [
          {
            "serviceKey": []
          },
          {
            "bearer": []
          }
        ],
        "responses": {
          "201": {
            "description": "Imported"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/events": {
      "get": {
        "summary": "Event outbox (audit log, n8n-compatible)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}