{
  "openapi": "3.1.0",
  "info": {
    "title": "DocGen API",
    "version": "1.0.0",
    "description": "Synchronous document conversion: HTML or a public URL to PDF, Markdown to HTML, HTML to EPUB / MOBI / AZW3. Each call returns the file in the response body; nothing is stored. Get an API key from https://docgen.novtopro.com/dashboard. Human docs: https://docgen.novtopro.com/docs"
  },
  "servers": [
    {
      "url": "https://docgen.novtopro.com"
    }
  ],
  "security": [
    {
      "apiKeyHeader": []
    },
    {
      "bearer": []
    }
  ],
  "paths": {
    "/api/v1/pdf": {
      "post": {
        "operationId": "convertPdf",
        "summary": "HTML or URL to PDF",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PdfRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The PDF.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/pdf"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_json`; `html_required` (neither `html` nor `url`); `ambiguous_source` (both); `url_invalid` (not an http(s) URL); `url_not_allowed` (localhost or a private address).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`account_canceled`: the account's subscription is canceled. `engine_not_allowed`: the plan doesn't include the requested engine (free is Tiger only).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "description": "`conversion_failed`: the engine produced no PDF. `url_fetch_failed`: the `url` couldn't be fetched (timeout, non-2xx, redirect, non-HTML).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/markdown": {
      "post": {
        "operationId": "convertMarkdown",
        "summary": "Markdown (GitHub-flavored) to HTML",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarkdownRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A complete HTML document.",
            "content": {
              "text/html; charset=utf-8": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_json` or `markdown_required`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Canceled"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/v1/epub": {
      "post": {
        "operationId": "convertEpub",
        "summary": "HTML to EPUB",
        "requestBody": {
          "$ref": "#/components/requestBodies/Ebook"
        },
        "responses": {
          "200": {
            "description": "The EPUB.",
            "content": {
              "application/epub+zip": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/epub+zip"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/EbookBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Canceled"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/ConversionFailed"
          }
        }
      }
    },
    "/api/v1/mobi": {
      "post": {
        "operationId": "convertMobi",
        "summary": "HTML to MOBI",
        "requestBody": {
          "$ref": "#/components/requestBodies/Ebook"
        },
        "responses": {
          "200": {
            "description": "The MOBI.",
            "content": {
              "application/x-mobipocket-ebook": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/x-mobipocket-ebook"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/EbookBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Canceled"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/ConversionFailed"
          }
        }
      }
    },
    "/api/v1/azw3": {
      "post": {
        "operationId": "convertAzw3",
        "summary": "HTML to AZW3 (Kindle)",
        "requestBody": {
          "$ref": "#/components/requestBodies/Ebook"
        },
        "responses": {
          "200": {
            "description": "The AZW3.",
            "content": {
              "application/vnd.amazon.mobi8-ebook": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/vnd.amazon.mobi8-ebook"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/EbookBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Canceled"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/ConversionFailed"
          }
        }
      }
    },
    "/api/v1/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Plan, limits and this month's usage",
        "description": "Works for canceled accounts too; not metered or rate limited.",
        "responses": {
          "200": {
            "description": "The API key's account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "API key (`dk_live_…`). Takes precedence over Authorization."
      },
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "`Authorization: Bearer dk_live_…`"
      }
    },
    "requestBodies": {
      "Ebook": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/EbookRequest"
            }
          }
        }
      }
    },
    "responses": {
      "EbookBadRequest": {
        "description": "`invalid_json`, `html_required`, or `title_required` (missing or empty).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "`missing_api_key` or `invalid_api_key` (unknown or revoked).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Canceled": {
        "description": "`account_canceled`: the account's subscription is canceled.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooLarge": {
        "description": "`body_too_large`: the request body (or the page fetched from `url`) exceeds the plan's maxBodyBytes (free 256 KB, pro 4 MB).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "`quota_exceeded`: the monthly conversions are used up (free: 50). `rate_limit_exceeded`: too many requests this minute (free 5, pro 120).",
        "headers": {
          "Retry-After": {
            "description": "Seconds until the limit resets: the next whole minute for `rate_limit_exceeded`, the start of the next UTC calendar month for `quota_exceeded`.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ConversionFailed": {
        "description": "`conversion_failed`: no file was produced (e.g. an invalid base64 `cover`). Not retried, not metered.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "invalid_json",
              "html_required",
              "title_required",
              "markdown_required",
              "ambiguous_source",
              "url_invalid",
              "url_not_allowed",
              "missing_api_key",
              "invalid_api_key",
              "account_canceled",
              "engine_not_allowed",
              "body_too_large",
              "quota_exceeded",
              "rate_limit_exceeded",
              "conversion_failed",
              "url_fetch_failed"
            ]
          }
        }
      },
      "PdfRequest": {
        "type": "object",
        "description": "Exactly one of `html` or `url`.",
        "oneOf": [
          {
            "required": [
              "html"
            ]
          },
          {
            "required": [
              "url"
            ]
          }
        ],
        "properties": {
          "html": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "A public http(s) page; private/local addresses are rejected and redirects are not followed."
          },
          "css": {
            "type": "string",
            "description": "Added before the HTML as a <style> block."
          },
          "engine": {
            "type": "string",
            "enum": [
              "tiger",
              "lion",
              "wolf"
            ],
            "default": "tiger",
            "description": "Free plan: tiger only."
          },
          "title": {
            "type": "string",
            "description": "PDF document title."
          },
          "pageSize": {
            "type": "string",
            "enum": [
              "letter",
              "a4",
              "legal",
              "tabloid"
            ],
            "default": "letter",
            "description": "Tiger only; on Lion and Wolf use CSS @page size."
          },
          "orientation": {
            "type": "string",
            "enum": [
              "portrait",
              "landscape"
            ],
            "default": "portrait",
            "description": "Tiger only."
          },
          "margins": {
            "description": "Tiger only, in points (1/72 in): one number for every side, or per side. Default 40.",
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "object",
                "properties": {
                  "top": {
                    "type": "number"
                  },
                  "right": {
                    "type": "number"
                  },
                  "bottom": {
                    "type": "number"
                  },
                  "left": {
                    "type": "number"
                  }
                }
              }
            ]
          }
        }
      },
      "MarkdownRequest": {
        "type": "object",
        "required": [
          "markdown"
        ],
        "properties": {
          "markdown": {
            "type": "string",
            "description": "GitHub-flavored Markdown."
          },
          "css": {
            "type": "string",
            "description": "Added to the HTML as a <style> block."
          }
        }
      },
      "EbookRequest": {
        "type": "object",
        "required": [
          "html",
          "title"
        ],
        "properties": {
          "html": {
            "type": "string"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "css": {
            "type": "string"
          },
          "author": {
            "type": "string"
          },
          "cover": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "Cover image bytes, base64."
          }
        }
      },
      "Me": {
        "type": "object",
        "required": [
          "account",
          "usage",
          "limits"
        ],
        "properties": {
          "account": {
            "type": "object",
            "required": [
              "id",
              "plan",
              "status"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "plan": {
                "type": "string",
                "enum": [
                  "free",
                  "pro"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "canceled"
                ]
              }
            }
          },
          "usage": {
            "type": "object",
            "required": [
              "period",
              "conversions",
              "bytesIn",
              "bytesOut"
            ],
            "properties": {
              "period": {
                "type": "string",
                "description": "UTC calendar month, YYYY-MM.",
                "examples": [
                  "2026-10"
                ]
              },
              "conversions": {
                "type": "integer"
              },
              "bytesIn": {
                "type": "integer"
              },
              "bytesOut": {
                "type": "integer"
              }
            }
          },
          "limits": {
            "type": "object",
            "required": [
              "conversionsPerMonth",
              "maxBodyBytes",
              "requestsPerMinute",
              "engines"
            ],
            "properties": {
              "conversionsPerMonth": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "null means unlimited."
              },
              "maxBodyBytes": {
                "type": "integer"
              },
              "requestsPerMinute": {
                "type": "integer"
              },
              "engines": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "tiger",
                    "lion",
                    "wolf"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}
