{
  "openapi": "3.0.3",
  "info": {
    "title": "FrameForge API",
    "version": "0.1.0",
    "description": "FrameForge is a render API. Send one POST request with HTML or a URL and get back a PNG, JPEG or PDF rendered in real Chromium.\n\nBase URL: `https://api.frameforgeapi.com`.\nPaid endpoints require an API key in the `X-API-Key` header. Buy a plan at https://frameforgeapi.com/#pricing (Starter from \u00a39/month).\nCache hits on `POST /render` do not count against the monthly quota. Identical requests within about 24 hours may be served from cache.\nCommon cookie and consent banners are hidden automatically (CSS/selector based; shadow-DOM and novel walls may still appear).\n\nHonest limitations: no WebP, S3 upload, webhooks or official SDKs yet. Public pages only (private, loopback and metadata addresses are rejected). Single region (Helsinki), with no SLA. HTML is limited to 1 MiB. Default concurrency is 2 paid renders at a time.",
    "contact": {
      "name": "Frame Forge",
      "email": "service@frameforgeapi.com",
      "url": "https://frameforgeapi.com"
    },
    "x-logo": {
      "url": "https://frameforgeapi.com/icon-512.png",
      "backgroundColor": "#FFFFFF"
    }
  },
  "externalDocs": {
    "description": "Product site, docs and pricing",
    "url": "https://frameforgeapi.com"
  },
  "servers": [
    {
      "url": "https://api.frameforgeapi.com",
      "description": "Production (Helsinki)"
    }
  ],
  "tags": [
    {
      "name": "Health",
      "description": "Service status. No API key."
    },
    {
      "name": "Render",
      "description": "Paid render endpoint. Requires an API key."
    },
    {
      "name": "Quota",
      "description": "Remaining monthly quota for an API key."
    },
    {
      "name": "Free tools",
      "description": "Keyless tools with a per-IP daily allowance. Intended for the FrameForge website; CORS is limited to frameforgeapi.com. Paid API recommended for your own product."
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "tags": [
          "Health"
        ],
        "summary": "Service health",
        "description": "No API key required. Returns service status, version, uptime and current concurrency.",
        "security": [],
        "responses": {
          "200": {
            "description": "The service is up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                },
                "example": {
                  "ok": true,
                  "service": "frameforge-api",
                  "version": "0.1.0",
                  "uptimeSec": 120,
                  "concurrency": {
                    "active": 0,
                    "waiting": 0,
                    "max": 2,
                    "queueMax": 8,
                    "free": {
                      "active": 0,
                      "waiting": 0,
                      "max": 1,
                      "queueMax": 3
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quota": {
      "get": {
        "operationId": "getQuota",
        "tags": [
          "Quota"
        ],
        "summary": "Remaining monthly quota",
        "description": "Returns remaining monthly quota for the API key. The period is the UTC calendar month. Cache hits on `/render` do not increment `used`.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current quota for this key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quota"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/render": {
      "post": {
        "operationId": "render",
        "tags": [
          "Render"
        ],
        "summary": "Render HTML or a URL to PNG, JPEG or PDF",
        "description": "Provide exactly one of `html` or `url`. The response body is the rendered file.\n\nUseful response headers: `X-FrameForge-Cache` (`HIT` or `MISS`), `X-FrameForge-Hash` (SHA-256 of the canonical request), `X-FrameForge-Quota-Remaining` and `X-FrameForge-Quota-Limit`.\n\nOnly `http` and `https` URLs are accepted. Private, loopback, link-local and cloud-metadata addresses are rejected after DNS resolution, including on redirects and subresource requests.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderRequest"
              },
              "examples": {
                "urlPng": {
                  "summary": "Public URL to a full-page PNG",
                  "value": {
                    "url": "https://example.com",
                    "format": "png",
                    "width": 1280,
                    "height": 720,
                    "fullPage": true
                  }
                },
                "htmlPng": {
                  "summary": "HTML snippet to a PNG",
                  "value": {
                    "html": "<!doctype html><html><body style=\"font-family:sans-serif\"><h1>Hello from FrameForge</h1></body></html>",
                    "format": "png",
                    "width": 800,
                    "height": 600
                  }
                },
                "urlPdf": {
                  "summary": "Public URL to a PDF",
                  "value": {
                    "url": "https://example.com",
                    "format": "pdf",
                    "width": 1280,
                    "height": 720,
                    "fullPage": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rendered file.",
            "headers": {
              "X-FrameForge-Cache": {
                "description": "`HIT` if served from cache, otherwise `MISS`.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-FrameForge-Hash": {
                "description": "SHA-256 hash of the canonical request.",
                "schema": {
                  "type": "string"
                }
              },
              "X-FrameForge-Quota-Remaining": {
                "description": "Renders remaining in the current UTC month after this response. Cache hits do not decrement this.",
                "schema": {
                  "type": "string"
                }
              },
              "X-FrameForge-Quota-Limit": {
                "description": "Monthly quota for this key.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "429": {
            "$ref": "#/components/responses/QuotaOrRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServerBusy"
          },
          "504": {
            "$ref": "#/components/responses/Timeout"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/free/status": {
      "get": {
        "operationId": "getFreeStatus",
        "tags": [
          "Free tools"
        ],
        "summary": "Remaining free-tool uses",
        "description": "No API key. Does not consume a use. Default limits are 5 free renders and 30 card-preview checks per IP per UTC day.",
        "security": [],
        "responses": {
          "200": {
            "description": "Remaining free uses for the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FreeStatus"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/FreeForbidden"
          },
          "503": {
            "$ref": "#/components/responses/FreeUnavailable"
          }
        }
      }
    },
    "/free/render": {
      "post": {
        "operationId": "freeRender",
        "tags": [
          "Free tools"
        ],
        "summary": "Free URL render (watermarked, 5 per day per IP)",
        "description": "No API key. Renders a public URL only (raw HTML is rejected). Output is watermarked and height-capped. Every successful response counts against the daily allowance, including cache hits. Default size comes from `device`: desktop is 1280\u00d7800, mobile is 390\u00d7844. `fullPage` defaults to true.\n\nResponse headers: `X-FrameForge-Free-Remaining`, `X-FrameForge-Free-Limit`, and `Content-Disposition`.\n\nBrowser requests from origins other than frameforgeapi.com are rejected. Server-side or curl requests with no Origin header are allowed, still bounded by the per-IP limits.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FreeRenderRequest"
              },
              "example": {
                "url": "https://example.com",
                "format": "png",
                "fullPage": true,
                "device": "desktop"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The watermarked rendered file.",
            "headers": {
              "X-FrameForge-Free-Remaining": {
                "description": "Free renders remaining today for this IP.",
                "schema": {
                  "type": "string"
                }
              },
              "X-FrameForge-Free-Limit": {
                "description": "Daily free-render limit for this IP (default 5).",
                "schema": {
                  "type": "string"
                }
              },
              "Content-Disposition": {
                "description": "Inline filename derived from the page hostname.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/FreeError"
          },
          "403": {
            "$ref": "#/components/responses/FreeForbidden"
          },
          "429": {
            "$ref": "#/components/responses/FreeDailyLimit"
          },
          "503": {
            "$ref": "#/components/responses/FreeUnavailable"
          },
          "504": {
            "$ref": "#/components/responses/FreeError"
          }
        }
      }
    },
    "/free/og": {
      "get": {
        "operationId": "getFreeOg",
        "tags": [
          "Free tools"
        ],
        "summary": "Social-card metadata for a public URL",
        "description": "No API key. Fetches public HTML (SSRF-safe, size-capped) and returns Open Graph / Twitter card fields. Counts against a separate per-IP daily allowance (default 30). Used by the preview tool on frameforgeapi.com.",
        "security": [],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "Public http(s) URL to inspect. A host without a scheme is treated as https.",
            "schema": {
              "type": "string",
              "example": "https://example.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Extracted social-card metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OgMeta"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/FreeError"
          },
          "403": {
            "$ref": "#/components/responses/FreeForbidden"
          },
          "429": {
            "$ref": "#/components/responses/FreeDailyLimit"
          },
          "503": {
            "$ref": "#/components/responses/FreeUnavailable"
          },
          "504": {
            "$ref": "#/components/responses/FreeError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Your FrameForge API key. Get one by buying a plan at https://frameforgeapi.com/#pricing. Do not send a real key in public examples; use a placeholder."
      }
    },
    "schemas": {
      "Health": {
        "type": "object",
        "required": [
          "ok",
          "service",
          "version",
          "uptimeSec",
          "concurrency"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "service": {
            "type": "string",
            "example": "frameforge-api"
          },
          "version": {
            "type": "string",
            "example": "0.1.0"
          },
          "uptimeSec": {
            "type": "integer",
            "minimum": 0
          },
          "concurrency": {
            "$ref": "#/components/schemas/Concurrency"
          }
        }
      },
      "Concurrency": {
        "type": "object",
        "properties": {
          "active": {
            "type": "integer"
          },
          "waiting": {
            "type": "integer"
          },
          "max": {
            "type": "integer",
            "description": "Paid-render concurrency cap (default 2)."
          },
          "queueMax": {
            "type": "integer"
          },
          "free": {
            "type": "object",
            "properties": {
              "active": {
                "type": "integer"
              },
              "waiting": {
                "type": "integer"
              },
              "max": {
                "type": "integer"
              },
              "queueMax": {
                "type": "integer"
              }
            }
          }
        }
      },
      "Quota": {
        "type": "object",
        "required": [
          "name",
          "plan",
          "period",
          "monthlyQuota",
          "used",
          "remaining"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Label for this key."
          },
          "plan": {
            "type": "string",
            "description": "Plan slug, for example starter, studio, founding, or custom."
          },
          "period": {
            "type": "string",
            "description": "UTC calendar month, for example 2026-11.",
            "example": "2026-11"
          },
          "monthlyQuota": {
            "type": "integer",
            "minimum": 0
          },
          "used": {
            "type": "integer",
            "minimum": 0,
            "description": "Fresh renders counted this period. Cache hits are not included."
          },
          "remaining": {
            "type": "integer",
            "minimum": 0
          },
          "expiresAt": {
            "type": "string",
            "nullable": true,
            "description": "Optional key expiry. Date-only values are valid through the end of that UTC day. Null if the key does not expire."
          }
        }
      },
      "RenderRequest": {
        "type": "object",
        "description": "Provide exactly one of `html` or `url`.",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Public http or https URL to render. Mutually exclusive with `html`."
          },
          "html": {
            "type": "string",
            "description": "HTML document or snippet to render. Mutually exclusive with `url`. Maximum 1 MiB (1,048,576 bytes)."
          },
          "format": {
            "type": "string",
            "enum": [
              "png",
              "jpeg",
              "jpg",
              "pdf"
            ],
            "default": "png",
            "description": "`jpg` is accepted and treated as `jpeg`."
          },
          "width": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3840,
            "default": 1280
          },
          "height": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3840,
            "default": 720
          },
          "fullPage": {
            "type": "boolean",
            "default": false,
            "description": "If true, capture the full scroll height for images, or a taller PDF."
          }
        },
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine-readable code, for example invalid_request, missing_api_key, invalid_api_key, key_expired, quota_exceeded, rate_limited, payload_too_large, server_busy, timeout, internal_error."
          },
          "message": {
            "type": "string"
          },
          "quota": {
            "$ref": "#/components/schemas/Quota"
          }
        }
      },
      "FreeError": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "upgrade": {
            "type": "string",
            "format": "uri",
            "example": "https://frameforgeapi.com/#pricing"
          }
        }
      },
      "FreeStatus": {
        "type": "object",
        "properties": {
          "render": {
            "type": "integer",
            "minimum": 0,
            "description": "Free renders remaining today."
          },
          "og": {
            "type": "integer",
            "minimum": 0,
            "description": "Card-preview checks remaining today."
          },
          "resetsAt": {
            "type": "string",
            "description": "End of the current UTC day, for example 2026-11-12T23:59:59Z."
          },
          "limits": {
            "type": "object",
            "properties": {
              "render": {
                "type": "integer",
                "description": "Daily free-render cap (default 5)."
              },
              "og": {
                "type": "integer",
                "description": "Daily card-preview cap (default 30)."
              }
            }
          },
          "turnstile": {
            "type": "boolean",
            "description": "True if a Cloudflare Turnstile token is required on POST /free/render."
          }
        }
      },
      "FreeRenderRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Public URL to render. Raw HTML is not accepted on this endpoint."
          },
          "format": {
            "type": "string",
            "enum": [
              "png",
              "jpeg",
              "jpg",
              "pdf"
            ],
            "default": "png"
          },
          "fullPage": {
            "type": "boolean",
            "default": true
          },
          "device": {
            "type": "string",
            "enum": [
              "desktop",
              "mobile"
            ],
            "default": "desktop",
            "description": "desktop is 1280\u00d7800; mobile is 390\u00d7844."
          },
          "turnstileToken": {
            "type": "string",
            "description": "Cloudflare Turnstile token, required only when `/free/status` reports `turnstile: true`."
          }
        }
      },
      "OgMeta": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Final URL after following redirects."
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "image": {
            "type": "string",
            "nullable": true
          },
          "imageAlt": {
            "type": "string",
            "nullable": true
          },
          "imageWidth": {
            "type": "number",
            "nullable": true
          },
          "imageHeight": {
            "type": "number",
            "nullable": true
          },
          "siteName": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "twitterCard": {
            "type": "string",
            "nullable": true
          },
          "twitterSite": {
            "type": "string",
            "nullable": true
          },
          "favicon": {
            "type": "string",
            "nullable": true
          },
          "tags": {
            "type": "object",
            "additionalProperties": {
              "type": "boolean"
            },
            "description": "Which Open Graph or Twitter tags were present on the page."
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request: missing or conflicting `html`/`url`, bad format, width/height out of range, or a blocked URL.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, unrecognised or expired API key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PayloadTooLarge": {
        "description": "HTML exceeds the 1 MiB limit, or the JSON body is too large.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Per-key or per-IP rate limit. `Retry-After` is set in seconds.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "QuotaOrRateLimited": {
        "description": "Monthly quota exhausted (`quota_exceeded`, includes a `quota` object) or a short-term rate limit (`rate_limited`, `Retry-After` set).",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "string"
            },
            "description": "Present for rate_limited responses."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServerBusy": {
        "description": "The render queue is full (`server_busy`). Retry later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Timeout": {
        "description": "Navigation or render timed out (`timeout`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "InternalError": {
        "description": "Unexpected server error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "FreeError": {
        "description": "Invalid input, blocked URL, or a fetch/render failure on the free tools.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/FreeError"
            }
          }
        }
      },
      "FreeForbidden": {
        "description": "Origin is not allowed (`origin_not_allowed`), or a Turnstile check failed (`captcha_required` or `captcha_failed`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/FreeError"
            }
          }
        }
      },
      "FreeDailyLimit": {
        "description": "This IP has used today's free allowance (`daily_limit`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/FreeError"
            }
          }
        }
      },
      "FreeUnavailable": {
        "description": "Free tools paused (`free_disabled`) or the global daily cap was reached (`free_capacity`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/FreeError"
            }
          }
        }
      }
    }
  }
}
