{
  "openapi": "3.1.0",
  "info": {
    "title": "html.page API",
    "version": "1.0.0",
    "description": "Publish raw HTML (scripts allowed), get a shareable link. Anonymous, no auth. Pages expire after 7 days. Agent docs: /llms.txt"
  },
  "servers": [
    {
      "url": "https://html.page"
    }
  ],
  "paths": {
    "/api/publish": {
      "post": {
        "operationId": "publishHtml",
        "summary": "Publish an HTML document",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "html"
                ],
                "properties": {
                  "html": {
                    "type": "string",
                    "maxLength": 3000000,
                    "description": "Complete HTML document. Scripts allowed; runs in a CSP sandbox."
                  },
                  "markdown": {
                    "type": "string",
                    "maxLength": 3000000,
                    "description": "Optional agent-readable markdown twin, served at /:id.md. Author-supplied markdown is never overwritten; if omitted, one is derived from the HTML."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Published",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url",
                    "expires_at"
                  ],
                  "properties": {
                    "url": {
                      "type": "string",
                      "example": "https://html.page/Ab3x9K"
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_JSON, MISSING_FIELD, or INVALID_FIELD",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "CONTENT_TOO_LARGE — html or markdown over 3 MB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "CONTENT_REJECTED — matched a phishing or wallet-drainer pattern (enforcement is an operator switch; the hint field says how to fix legitimate prototypes)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentRejected"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED — 30 publishes/min per IP; Retry-After: 60",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/{id}.md": {
      "get": {
        "operationId": "getPageMarkdown",
        "summary": "Markdown companion of a page",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9]{6}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "text/markdown",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Expired, never existed, or markdown not (yet) available"
          },
          "410": {
            "description": "Removed for violating the acceptable-use policy"
          }
        }
      }
    },
    "/raw/{id}": {
      "get": {
        "operationId": "getPageHtml",
        "summary": "Raw HTML of a page (served under a CSP sandbox)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9]{6}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "text/html",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Expired or never existed"
          },
          "410": {
            "description": "Removed for violating the acceptable-use policy"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string",
            "example": "RATE_LIMITED"
          },
          "message": {
            "type": "string"
          },
          "hint": {
            "type": "string"
          }
        }
      },
      "ContentRejected": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Error"
          },
          {
            "type": "object",
            "required": [
              "category"
            ],
            "properties": {
              "category": {
                "type": "string",
                "enum": [
                  "phishing_pattern",
                  "wallet_drainer_pattern"
                ]
              }
            }
          }
        ]
      }
    }
  }
}