{
  "openapi": "3.0.3",
  "info": {
    "title": "Mailganer Email Screenshot API",
    "version": "0.3.4",
    "description": "HTML письма → два PNG/WebP (preview ~300px и full ~526px). Ответ только inline base64, без хранения файлов. Демо: SmartCaptcha. Интеграции: Authorization Bearer / X-Api-Key. Keyed-ответы отдают attribution_required и tier (#21481).\n\nПубличный REST (#21407): `/tools/email-screenshot/v1/…`. На apex `/api/` занят личным кабинетом."
  },
  "servers": [
    {
      "url": "https://mailganer.com",
      "description": "Production"
    },
    {
      "url": "https://newland.mailganer.com",
      "description": "Staging"
    }
  ],
  "paths": {
    "/tools/email-screenshot/v1/status": {
      "get": {
        "summary": "Статус, квоты и SmartCaptcha",
        "operationId": "emailScreenshotStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "service": { "type": "string" },
                    "browser": { "type": "boolean" },
                    "daily_limit": { "type": "integer" },
                    "remaining": { "type": "integer" },
                    "keyed_api": { "type": "boolean" },
                    "key_daily_limit": { "type": "integer" },
                    "keyed": {
                      "type": "boolean",
                      "description": "true при валидном Bearer (#21481)"
                    },
                    "tier": {
                      "type": "string",
                      "enum": ["free", "paid"],
                      "description": "Уровень ключа; только с Bearer"
                    },
                    "attribution_required": {
                      "type": "boolean",
                      "description": "true — рядом с результатом нужно упоминание Mailganer"
                    },
                    "captcha": {
                      "type": "object",
                      "properties": {
                        "required": { "type": "boolean" },
                        "site_key": { "type": "string" },
                        "mode": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/tools/email-screenshot/v1/render": {
      "post": {
        "summary": "HTML → preview + full PNG/WebP (base64)",
        "operationId": "emailScreenshotRender",
        "security": [
          { "bearerAuth": [] },
          { "apiKeyAuth": [] },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["html"],
                "properties": {
                  "html": {
                    "type": "string",
                    "description": "HTML письма (≤ 1.5 MB). Фрагмент без <html> оборачивается в shell."
                  },
                  "smart_token": {
                    "type": "string",
                    "description": "Yandex SmartCaptcha token (демо)"
                  },
                  "format": {
                    "type": "string",
                    "enum": ["png", "webp"],
                    "default": "png"
                  },
                  "preview": {
                    "type": "object",
                    "properties": {
                      "width": { "type": "integer" },
                      "max_height": { "type": "integer" }
                    }
                  },
                  "full": {
                    "type": "object",
                    "properties": {
                      "width": { "type": "integer" },
                      "max_height": { "type": "integer" }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string" },
                    "request_id": { "type": "string" },
                    "preview": {
                      "type": "object",
                      "properties": {
                        "width": { "type": "integer" },
                        "height": { "type": "integer" },
                        "content_type": { "type": "string" },
                        "base64": { "type": "string" }
                      }
                    },
                    "full": {
                      "type": "object",
                      "properties": {
                        "width": { "type": "integer" },
                        "height": { "type": "integer" },
                        "content_type": { "type": "string" },
                        "base64": { "type": "string" }
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "render_ms": { "type": "integer" },
                        "html_bytes": { "type": "integer" },
                        "auth": {
                          "type": "string",
                          "enum": ["public", "keyed", "internal"]
                        }
                      }
                    },
                    "dailyRemaining": { "type": "integer" },
                    "dailyLimit": { "type": "integer" },
                    "keyed": {
                      "type": "boolean",
                      "description": "true при валидном Bearer (#21481)"
                    },
                    "tier": {
                      "type": "string",
                      "enum": ["free", "paid"]
                    },
                    "attribution_required": {
                      "type": "boolean",
                      "description": "true — подпись Mailganer обязательна у партнёра; PNG без водяного знака"
                    }
                  }
                }
              }
            }
          },
          "401": { "description": "Invalid API key" },
          "403": { "description": "Captcha failed" },
          "413": { "description": "HTML too large" },
          "429": { "description": "Quota exceeded" },
          "504": { "description": "Render timeout" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "EMAIL_SCREENSHOT_API_KEYS — без captcha"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key"
      }
    }
  }
}
