{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pressa-dev/json-schema/pressa-dev-compile-success-schema.json",
  "title": "CompileSuccess",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pressa-dev-openapi.json#/components/schemas/CompileSuccess",
  "type": "object",
  "required": [
    "job_id",
    "pdf_url",
    "pages"
  ],
  "properties": {
    "job_id": {
      "type": "string",
      "format": "uuid"
    },
    "pdf_url": {
      "type": "string",
      "format": "uri",
      "description": "Signed URL. Fetchable with no credentials until it expires."
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "pages": {
      "type": "integer",
      "description": "Pages in the PDF at `pdf_url`. For a preview this is what was delivered; `total_pages` is what the document has."
    },
    "compilation_time_ms": {
      "type": "integer"
    },
    "assets_count": {
      "type": "integer"
    },
    "font_substitutions": {
      "type": "array",
      "description": "Present when the document asked for fonts the compile image does not have (Arial, Helvetica, Times New Roman, Calibri, Cambria, Georgia and other commercial fonts) and Pressa compiled them as installed fonts with the same metrics where one exists (Arial as Arimo, Times New Roman as Tinos, Calibri as Carlito), otherwise the closest free design. xelatex and lualatex only. Also on a failed compile, whose log shows the installed names.",
      "items": {
        "type": "object",
        "properties": {
          "requested": {
            "type": "string"
          },
          "used": {
            "type": "string"
          }
        }
      }
    },
    "redefined_commands": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Present when the document used \\newcommand on a name LaTeX itself defines (\\H, \\vec, \\top and a few more), which cannot compile, and Pressa let the document's own definition win (\\let\\H\\relax before it). Names pdflatex uses to set accented letters are left alone, so their error and diagnosis stay."
    },
    "studio_url": {
      "type": "string",
      "format": "uri",
      "description": "Browser editor link. Absent for anonymous compiles."
    },
    "anonymous": {
      "type": "boolean",
      "description": "Present and true when the compile used the keyless tier."
    },
    "remaining_today": {
      "type": "integer",
      "description": "Anonymous tier only."
    },
    "note": {
      "type": "string",
      "description": "Anonymous tier only. Human- and agent-readable upgrade guidance."
    },
    "next_step": {
      "$ref": "#/$defs/NextStep"
    },
    "usage": {
      "type": "object",
      "description": "Monthly counters for accounts; daily counters for the anonymous tier."
    },
    "quota_grace": {
      "type": "boolean",
      "description": "Present and true when this compilation exceeded the plan's monthly limit and drew on the paid-plan grace buffer. Grace compilations are not charged."
    },
    "grace_remaining": {
      "type": "integer",
      "description": "Compilations left in the grace buffer before requests start failing."
    },
    "warning": {
      "type": "string",
      "description": "Present with `quota_grace` (capacity is about to run out) and with `preview` (what was delivered and which plan covers the whole document). Human- and agent-readable; relay it."
    },
    "preview": {
      "type": "boolean",
      "description": "Present and true when the document exceeded the plan's page or source-size limit. The PDF at `pdf_url` is what the plan delivers of it. Accounts only; anonymous callers get 413/422 instead."
    },
    "truncated": {
      "type": "boolean",
      "description": "With `preview`: true when the PDF holds only the first `pages` of a `total_pages` document, false when the source was over the plan's size limit but every page fit."
    },
    "total_pages": {
      "type": "integer",
      "description": "With `preview`: how many pages the whole document has. `pages` is how many were delivered."
    },
    "plan_required": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "free",
        "starter",
        "pro",
        "business"
      ],
      "description": "With `preview`: the smallest plan whose page and source-size limits cover the whole document. Null when even Business does not."
    },
    "upgrade_url": {
      "type": "string",
      "format": "uri"
    }
  },
  "$defs": {
    "NextStep": {
      "type": "object",
      "description": "What the caller should do to get past this response.",
      "properties": {
        "action": {
          "type": "string",
          "enum": [
            "obtain_api_key",
            "retry_without_assets"
          ]
        },
        "signup_url": {
          "type": "string",
          "format": "uri"
        },
        "env_var": {
          "type": "string"
        },
        "header": {
          "type": "string"
        },
        "remove_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "card_required": {
          "type": "boolean"
        }
      }
    }
  }
}