{
  "openapi": "3.1.0",
  "info": {
    "title": "FLAC to MP3 Converter API",
    "version": "1.0.0",
    "description": "Public, read-only discovery and health contract for the FLAC to MP3 converter. Audio conversion itself runs entirely in the browser; these endpoints expose service metadata, health, and machine-readable discovery.",
    "contact": {
      "name": "Platphorm News",
      "url": "https://platphormnews.com/contact"
    },
    "license": {
      "name": "MIT"
    }
  },
  "servers": [
    {
      "url": "https://flac.platphormnews.com",
      "description": "Canonical production origin"
    }
  ],
  "tags": [
    {
      "name": "Platform",
      "description": "Health, documentation, and MCP discovery."
    },
    {
      "name": "Discovery",
      "description": "Machine-readable discovery documents."
    }
  ],
  "components": {
    "securitySchemes": {
      "PlatphormApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-PlatPhorm-API-Key",
        "description": "Shared PlatPhorm platform key. Public read-only routes need no auth; future mutations require PLATPHORM_API_KEY, also accepted as `Authorization: Bearer`."
      },
      "PlatphormBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Shared PLATPHORM_API_KEY presented as a bearer token for protected operations."
      }
    },
    "schemas": {
      "HealthEnvelope": {
        "type": "object",
        "required": [
          "ok",
          "data"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "data": {
            "type": "object",
            "required": [
              "service",
              "version",
              "status",
              "timestamp",
              "trace",
              "vercelMetadataCaptured"
            ],
            "properties": {
              "service": {
                "type": "string"
              },
              "version": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "timestamp": {
                "type": "string",
                "format": "date-time"
              },
              "vercelMetadataCaptured": {
                "type": "boolean"
              },
              "trace": {
                "type": "object"
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {}
  ],
  "paths": {
    "/api/health": {
      "get": {
        "tags": [
          "Platform"
        ],
        "summary": "Service health",
        "description": "Versioned health envelope reporting status, trace-context state, and safe Vercel metadata capture.",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "Health envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/health": {
      "get": {
        "tags": [
          "Platform"
        ],
        "summary": "Versioned service health",
        "description": "Identical health envelope under the versioned /api/v1 namespace.",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "Health envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/mcp": {
      "post": {
        "tags": [
          "Platform"
        ],
        "summary": "MCP JSON-RPC endpoint",
        "description": "JSON-RPC 2.0 Model Context Protocol endpoint. Supports initialize, tools/list, and tools/call (read-only).",
        "security": [
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/docs": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "OpenAPI document",
        "description": "Returns this OpenAPI 3.1 document as JSON.",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "OpenAPI document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/events": {
      "get": {
        "tags": [
          "Platform"
        ],
        "summary": "Read the event outbox",
        "description": "Public, read-only view of the bounded event outbox.",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "Outbox",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Platform"
        ],
        "summary": "Emit an event (protected)",
        "description": "Protected mutation. Requires the shared PLATPHORM_API_KEY via `Authorization: Bearer` or the `X-PlatPhorm-API-Key` header.",
        "security": [
          {
            "PlatphormBearer": []
          },
          {
            "PlatphormApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "maxLength": 128
                  },
                  "payload": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Event accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Missing or invalid PLATPHORM_API_KEY"
          }
        }
      }
    }
  }
}