{
  "openapi": "3.1.0",
  "info": {
    "title": "PlatPhorm ThreatPulse API",
    "version": "0.1.2",
    "description": "Source-cited abuse.ch enrichment for IPs, domains, URLs, and file hashes. No record means no coverage, not safety."
  },
  "servers": [
    {
      "url": "https://threatpulse.platphormnews.com"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Service health",
        "responses": {
          "200": {
            "description": "Health",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/health": {
      "get": {
        "operationId": "getVersionedHealth",
        "summary": "Versioned service health",
        "responses": {
          "200": {
            "description": "Health",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/enrich": {
      "get": {
        "operationId": "enrichQuery",
        "summary": "Enrich one public read-only query",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Enrichment result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrichmentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Input too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Enrichment failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "enrichIndicators",
        "summary": "Enrich bounded indicators as a public read-only operation",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnrichmentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Enrichment result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrichmentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Input too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Enrichment failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/enrich/internal": {
      "post": {
        "operationId": "enrichIndicatorsInternal",
        "summary": "Enrich bounded indicators for a trusted PlatPhorm service",
        "security": [
          {
            "PlatPhormHeader": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnrichmentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Enrichment result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrichmentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Platform authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Input too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Enrichment failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Platform authentication is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trends": {
      "get": {
        "operationId": "getThreatTrends",
        "summary": "Read feed trends",
        "responses": {
          "200": {
            "description": "Trend report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/mcp": {
      "get": {
        "operationId": "getMcpMetadata",
        "summary": "MCP metadata",
        "responses": {
          "200": {
            "description": "MCP registry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "callMcp",
        "summary": "MCP JSON-RPC",
        "responses": {
          "200": {
            "description": "JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EnrichmentRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "query": {
            "type": "string",
            "minLength": 1,
            "maxLength": 8000
          },
          "indicators": {
            "type": "array",
            "maxItems": 25,
            "items": {
              "type": "string"
            }
          }
        },
        "anyOf": [
          {
            "required": [
              "query"
            ]
          },
          {
            "required": [
              "indicators"
            ]
          }
        ]
      },
      "EnrichmentResponse": {
        "type": "object",
        "required": [
          "ok",
          "data",
          "meta"
        ],
        "properties": {
          "ok": {
            "const": true
          },
          "data": {
            "type": "object",
            "required": [
              "intent",
              "results",
              "summary",
              "trace",
              "unparsed"
            ],
            "properties": {
              "intent": {
                "enum": [
                  "enrich",
                  "trend"
                ]
              },
              "results": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "summary": {
                "type": "object"
              },
              "trace": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "unparsed": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "trend": {
                "type": "object"
              }
            }
          },
          "meta": {
            "type": "object",
            "required": [
              "mode",
              "elapsedMs",
              "generatedAt"
            ]
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "const": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "details"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "PlatPhormBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Compatibility scheme for protected actions. PlatPhorm service calls use X-PlatPhorm-API-Key."
      },
      "PlatPhormHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-PlatPhorm-API-Key",
        "description": "Protected service-to-service actions use X-PlatPhorm-API-Key: $PLATPHORM_API_KEY."
      }
    }
  }
}