{
  "openapi": "3.1.0",
  "info": {
    "title": "Fork PDF API",
    "version": "2.1.0",
    "summary": "HTML-to-PDF API with spatial schema v2 geometry, self-healing layout tests, fillable forms, and PDF/A + PDF/UA output.",
    "description": "Fork PDF renders HTML, URLs, or saved dashboard templates to PDF. The API can return the PDF plus a spatial layout map, execute a `testCase` against the rendered DOM, and self-heal layout breaks by applying data patches before delivery.\n\n## Authentication\nSend either `Authorization: Bearer <api-key>` or `x-api-key: <api-key>`, plus `x-project-id: <project-id>` on every authenticated request. The compliance capabilities endpoint is public.\n\n## Response modes\n- **Synchronous JSON** (default): returns a signed `downloadUrl`, `testResults`, and compliance metadata.\n- **Webhook** (`webhook: true`): returns `202` with a pending PDF ID; the final payload is POSTed to your configured webhook.\n- **Stream only** (`streamOnly: true`): returns the raw PDF or ZIP body instead of JSON.\n\n## Limits\n- Request body: 20 MB\n- PDF output: 25 MB\n- Spatial ZIP output: 39 MB\n- Combined output: 40 MB\n- `testResults`: 8 KB (larger results are truncated)\n\nMachine-readable SDK specification for coding agents: https://forkpdf.com/agents/",
    "termsOfService": "https://forkpdf.com/terms/",
    "contact": {
      "name": "Fork PDF Support",
      "url": "https://forkpdf.com/contact/"
    },
    "license": {
      "name": "Proprietary API; SDK MIT",
      "url": "https://forkpdf.com/terms/"
    }
  },
  "externalDocs": {
    "description": "Fork PDF documentation",
    "url": "https://forkpdf.com/docs/"
  },
  "servers": [
    {
      "url": "https://api.forkpdf.com/v1",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "PDF Generation",
      "description": "Render HTML, URLs, or templates into PDFs."
    },
    {
      "name": "PDF Management",
      "description": "List, inspect, download, and delete generated PDFs."
    },
    {
      "name": "Webhooks",
      "description": "Inspect and retry failed asynchronous deliveries."
    },
    {
      "name": "Compliance",
      "description": "Discover PDF/A, PDF/UA, font, and form capabilities."
    }
  ],
  "x-tagGroups": [
    {
      "name": "Generate",
      "tags": [
        "PDF Generation"
      ]
    },
    {
      "name": "Manage",
      "tags": [
        "PDF Management"
      ]
    },
    {
      "name": "Deliver",
      "tags": [
        "Webhooks"
      ]
    },
    {
      "name": "Verify",
      "tags": [
        "Compliance"
      ]
    }
  ],
  "security": [
    {
      "bearerAuth": [],
      "projectId": []
    },
    {
      "apiKeyAuth": [],
      "projectId": []
    }
  ],
  "paths": {
    "/generate-pdf": {
      "post": {
        "tags": [
          "PDF Generation"
        ],
        "summary": "Generate a PDF",
        "operationId": "generatePdf",
        "description": "Generate a PDF from exactly one input source: `url`, `htmlContent`, or `templateId`. The default response is JSON with a signed download URL. Set `webhook: true` for an asynchronous `202` response, or `streamOnly: true` to receive the raw PDF/ZIP body.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              },
              "examples": {
                "minimalHtml": {
                  "summary": "Minimal HTML to PDF",
                  "value": {
                    "htmlContent": "<h1>Invoice</h1><p>Total: $42.00</p>",
                    "format": "A4"
                  }
                },
                "urlWithMargins": {
                  "summary": "URL to A4 with margins",
                  "value": {
                    "url": "https://example.com/invoice",
                    "format": "A4",
                    "waitUntil": "networkidle0",
                    "margins": {
                      "top": "18mm",
                      "right": "16mm",
                      "bottom": "18mm",
                      "left": "16mm"
                    }
                  }
                },
                "spatialTestCase": {
                  "summary": "Spatial output with a layout test",
                  "value": {
                    "htmlContent": "<div id='signature'>Signed by Ada</div>",
                    "format": "A4",
                    "spatial": true,
                    "testCase": "const el = doc.querySelector('#signature'); if (!el) return { success: false }; return { success: true, page: el.pages[0] + 1, x: el.geometry.x, y: el.geometry.y };"
                  }
                },
                "accessibleForm": {
                  "summary": "Fillable, accessible form",
                  "value": {
                    "htmlContent": "<form><label>Name <input name='fullName'></label></form>",
                    "format": "A4",
                    "pdfForm": true,
                    "targetLang": "en",
                    "compliance": {
                      "pdfUa": 2,
                      "pdfA": "4"
                    }
                  }
                },
                "multilingualPdfUa": {
                  "summary": "Stable PDF/UA-2 with per-element language tags",
                  "value": {
                    "htmlContent": "<html lang='en'><body><h1>Report</h1><p lang='fr'>Résumé</p></body></html>",
                    "format": "A4",
                    "compliance": {
                      "pdfUa": 2
                    }
                  }
                },
                "asyncWebhook": {
                  "summary": "Asynchronous webhook generation",
                  "value": {
                    "htmlContent": "<h1>Monthly statement</h1>",
                    "format": "A4",
                    "webhook": true
                  }
                },
                "streamOnly": {
                  "summary": "Raw binary response",
                  "value": {
                    "htmlContent": "<h1>Streamed PDF</h1>",
                    "format": "A4",
                    "streamOnly": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "PDF generated synchronously. When `streamOnly` is true, the body is a PDF or ZIP instead of JSON.",
            "headers": {
              "X-Compliance-Status": {
                "$ref": "#/components/headers/XComplianceStatus"
              },
              "X-PDF-UA": {
                "$ref": "#/components/headers/XPdfUa"
              },
              "X-PDF-A": {
                "$ref": "#/components/headers/XPdfA"
              },
              "X-Font-Embedding": {
                "$ref": "#/components/headers/XFontEmbedding"
              },
              "X-Font-Policy": {
                "$ref": "#/components/headers/XFontPolicy"
              },
              "X-Accessibility-Warnings": {
                "$ref": "#/components/headers/XAccessibilityWarnings"
              },
              "X-Accessibility-Warning-Count": {
                "$ref": "#/components/headers/XAccessibilityWarningCount"
              },
              "X-ForkPDF-SDK-Latest": {
                "$ref": "#/components/headers/XForkPdfSdkLatest"
              },
              "X-ForkPDF-SDK-Status": {
                "$ref": "#/components/headers/XForkPdfSdkStatus"
              },
              "X-ForkPDF-SDK-Upgrade-Url": {
                "$ref": "#/components/headers/XForkPdfSdkUpgradeUrl"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateResponse"
                },
                "examples": {
                  "syncSuccess": {
                    "summary": "Successful synchronous generation",
                    "value": {
                      "success": true,
                      "message": "File successfully generated and saved.",
                      "id": "0190c3d4-7abc-7def-8abc-1234567890ab",
                      "s3Key": "results/retention-24h/org/project/0190c3d4-7abc-7def-8abc-1234567890ab/result.pdf",
                      "testResults": {
                        "success": true,
                        "total_attempts": 1
                      },
                      "downloadUrl": "https://storage.example.com/result.pdf?X-Amz-Expires=900",
                      "sizeBytes": 48213,
                      "complianceStatus": {
                        "fontPolicy": "warn",
                        "fontEmbedding": "verified",
                        "pdfA": "stable",
                        "pdfAFlavor": "4",
                        "pdfUa": "stable",
                        "pdfUaVersion": 2
                      },
                      "warnings": []
                    }
                  }
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "202": {
            "description": "Generation queued. The final payload is delivered to the project webhook.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateQueuedResponse"
                },
                "examples": {
                  "queued": {
                    "summary": "Queued for webhook delivery",
                    "value": {
                      "success": true,
                      "message": "PDF generation queued. You will be notified via webhook.",
                      "id": "0190c3d4-7abc-7def-8abc-1234567890ab",
                      "status": "pending"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          },
          "502": {
            "$ref": "#/components/responses/BadGateway"
          }
        },
        "callbacks": {
          "webhookDelivery": {
            "https://your-project-webhook.example.com": {
              "post": {
                "summary": "Outbound webhook delivery",
                "description": "Fork PDF POSTs the final payload to the project webhook configured in the dashboard. The URL above is a placeholder. Verify the `x-webhook-signature` header before processing the body.",
                "parameters": [
                  {
                    "name": "x-webhook-signature",
                    "in": "header",
                    "required": false,
                    "description": "HMAC-SHA256 signature in the format `t=<unix-timestamp>,v1=<hex-digest>`. Compute HMAC-SHA256 over `<timestamp>.<raw-request-body>` using the project webhook secret.",
                    "schema": {
                      "type": "string"
                    }
                  }
                ],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/WebhookPayload"
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "Webhook accepted by your endpoint."
                  },
                  "400": {
                    "description": "Your webhook endpoint rejected the payload."
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "cURL",
            "label": "cURL",
            "source": "curl -X POST \"https://api.forkpdf.com/v1/generate-pdf\" \\\n  -H \"Authorization: Bearer $FORKPDF_API_KEY\" \\\n  -H \"x-project-id: $FORKPDF_PROJECT_ID\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"htmlContent\": \"<h1>Invoice</h1><p>Total: $42.00</p>\",\n    \"format\": \"A4\"\n  }'"
          },
          {
            "lang": "JavaScript",
            "label": "Node.js SDK",
            "source": "import { ForkPDFClient } from 'forkpdf';\n\nconst client = new ForkPDFClient(\n  process.env.FORKPDF_API_KEY,\n  process.env.FORKPDF_PROJECT_ID\n);\n\nconst result = await client.generate({\n  htmlContent: '<h1>Invoice</h1><p>Total: $42.00</p>',\n  format: 'A4'\n});\n\nconsole.log(result.downloadUrl);"
          }
        ]
      }
    },
    "/pdfs": {
      "get": {
        "tags": [
          "PDF Management"
        ],
        "summary": "List PDFs",
        "operationId": "listPdfs",
        "description": "List active, non-expired PDFs for the authenticated project. Reads are throttled separately from generation.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/Sort"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated PDF list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PdfListResponse"
                },
                "examples": {
                  "list": {
                    "summary": "One completed PDF",
                    "value": {
                      "success": true,
                      "data": [
                        {
                          "id": "0190c3d4-7abc-7def-8abc-1234567890ab",
                          "generationType": "payload",
                          "templateId": null,
                          "status": "completed",
                          "createdAt": "2026-11-10T12:00:00.000Z",
                          "updatedAt": "2026-11-10T12:00:04.000Z",
                          "expiresAt": "2026-11-11T12:00:00.000Z",
                          "testResults": {
                            "success": true,
                            "total_attempts": 1
                          }
                        }
                      ],
                      "meta": {
                        "totalItems": 1,
                        "currentPage": 1,
                        "itemsPerPage": 10,
                        "totalPages": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        },
        "x-codeSamples": [
          {
            "lang": "cURL",
            "label": "cURL",
            "source": "curl \"https://api.forkpdf.com/v1/pdfs?limit=10&page=1&sort=desc\" \\\n  -H \"Authorization: Bearer $FORKPDF_API_KEY\" \\\n  -H \"x-project-id: $FORKPDF_PROJECT_ID\""
          }
        ]
      }
    },
    "/pdfs/{id}": {
      "get": {
        "tags": [
          "PDF Management"
        ],
        "summary": "Get PDF metadata",
        "operationId": "getPdf",
        "description": "Fetch status, timestamps, generation type, and test results for a PDF. Use `/pdfs/{id}/download` to obtain a signed download URL.",
        "parameters": [
          {
            "$ref": "#/components/parameters/PdfId"
          }
        ],
        "responses": {
          "200": {
            "description": "PDF metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PdfDetailResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "delete": {
        "tags": [
          "PDF Management"
        ],
        "summary": "Delete a PDF",
        "operationId": "deletePdf",
        "description": "Queue a PDF for deletion. Deletion is asynchronous; the response is `202 Accepted`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/PdfId"
          }
        ],
        "responses": {
          "202": {
            "description": "Deletion queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/pdfs/{id}/download": {
      "get": {
        "tags": [
          "PDF Management"
        ],
        "summary": "Get a signed download URL",
        "operationId": "getPdfDownloadUrl",
        "description": "Return a 15-minute signed URL for a completed PDF or spatial ZIP. The PDF must have status `completed`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/PdfId"
          }
        ],
        "responses": {
          "200": {
            "description": "Signed download URL.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DownloadUrlResponse"
                },
                "examples": {
                  "download": {
                    "summary": "Signed PDF URL",
                    "value": {
                      "success": true,
                      "downloadUrl": "https://storage.example.com/result.pdf?X-Amz-Expires=900",
                      "isZip": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        },
        "x-codeSamples": [
          {
            "lang": "cURL",
            "label": "cURL",
            "source": "curl \"https://api.forkpdf.com/v1/pdfs/$PDF_ID/download\" \\\n  -H \"Authorization: Bearer $FORKPDF_API_KEY\" \\\n  -H \"x-project-id: $FORKPDF_PROJECT_ID\""
          }
        ]
      }
    },
    "/webhooks/failed": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List failed webhooks",
        "operationId": "listFailedWebhooks",
        "description": "List failed webhook deliveries for the authenticated project, newest first.",
        "responses": {
          "200": {
            "description": "Failed webhook list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookFailureListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/webhooks/failed/{id}/retry": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Retry one failed webhook",
        "operationId": "retryFailedWebhook",
        "description": "Queue a retry for a single failed webhook. Requires the `pdf:generate` permission.",
        "parameters": [
          {
            "$ref": "#/components/parameters/PdfId"
          }
        ],
        "responses": {
          "202": {
            "description": "Webhook queued for retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookRetryResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "description": "The failed webhook payload has expired and cannot be retried.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/webhooks/failed/retry-all": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Retry all failed webhooks",
        "operationId": "retryAllFailedWebhooks",
        "description": "Queue a bulk retry of failed webhooks. Requires the `pdf:generate` permission. Returns `200` when there is nothing to retry or a retry is already in progress.",
        "responses": {
          "200": {
            "description": "No failed webhooks to retry, or a bulk retry is already in progress.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookRetryResponse"
                }
              }
            }
          },
          "202": {
            "description": "Bulk retry job queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookRetryResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/compliance/capabilities": {
      "get": {
        "tags": [
          "Compliance"
        ],
        "summary": "Get compliance capabilities",
        "operationId": "getComplianceCapabilities",
        "description": "Return the supported PDF/A and PDF/UA versions, valid combinations, font policy, and form support. This endpoint is public and cached for five minutes.",
        "security": [],
        "responses": {
          "200": {
            "description": "Compliance capability matrix.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComplianceCapabilities"
                },
                "examples": {
                  "capabilities": {
                    "summary": "Current capability matrix",
                    "value": {
                      "success": true,
                      "pdfA": {
                        "status": "stable",
                        "supported": [
                          "2b",
                          "2u",
                          "2a",
                          "3b",
                          "3u",
                          "3a",
                          "4"
                        ],
                        "standalone": true
                      },
                      "pdfUa": {
                        "status": "stable",
                        "supported": [
                          1,
                          2
                        ],
                        "standalone": true
                      },
                      "combinations": [
                        {
                          "pdfUa": 1,
                          "pdfA": "2b"
                        },
                        {
                          "pdfUa": 1,
                          "pdfA": "2u"
                        },
                        {
                          "pdfUa": 1,
                          "pdfA": "2a"
                        },
                        {
                          "pdfUa": 1,
                          "pdfA": "3b"
                        },
                        {
                          "pdfUa": 1,
                          "pdfA": "3u"
                        },
                        {
                          "pdfUa": 1,
                          "pdfA": "3a"
                        },
                        {
                          "pdfUa": 2,
                          "pdfA": "4"
                        }
                      ],
                      "fontEmbedding": {
                        "status": "verified",
                        "policy": [
                          "warn",
                          "strict"
                        ]
                      },
                      "forms": {
                        "withCompliance": true,
                        "withPdfUa": true,
                        "withPdfA": true
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limited at the edge."
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Use your Fork PDF API key as the bearer token."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Alternative to `Authorization: Bearer`."
      },
      "projectId": {
        "type": "apiKey",
        "in": "header",
        "name": "x-project-id",
        "description": "Fork PDF project ID. Required on every authenticated request."
      }
    },
    "parameters": {
      "PdfId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "PDF UUID returned by generation.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "Items per page. Maximum 100.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 10
        }
      },
      "Page": {
        "name": "page",
        "in": "query",
        "required": false,
        "description": "Page number, starting at 1.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        }
      },
      "Sort": {
        "name": "sort",
        "in": "query",
        "required": false,
        "description": "Sort by creation time.",
        "schema": {
          "type": "string",
          "enum": [
            "asc",
            "desc"
          ],
          "default": "desc"
        }
      }
    },
    "headers": {
      "XComplianceStatus": {
        "description": "Base64-encoded JSON compliance status. Prefer the response body `complianceStatus` when available.",
        "schema": {
          "type": "string"
        }
      },
      "XPdfUa": {
        "description": "Requested PDF/UA version.",
        "schema": {
          "type": "string"
        }
      },
      "XPdfA": {
        "description": "Requested PDF/A flavor.",
        "schema": {
          "type": "string"
        }
      },
      "XFontEmbedding": {
        "description": "Font embedding verification status.",
        "schema": {
          "type": "string"
        }
      },
      "XFontPolicy": {
        "description": "Applied font policy: `warn` or `strict`.",
        "schema": {
          "type": "string"
        }
      },
      "XAccessibilityWarnings": {
        "description": "Base64-encoded JSON accessibility warnings.",
        "schema": {
          "type": "string"
        }
      },
      "XAccessibilityWarningCount": {
        "description": "Number of accessibility warnings.",
        "schema": {
          "type": "integer"
        }
      },
      "XForkPdfSdkLatest": {
        "description": "Latest SDK version when the request identifies an outdated `forkpdf` client.",
        "schema": {
          "type": "string"
        }
      },
      "XForkPdfSdkStatus": {
        "description": "`current` or `outdated`.",
        "schema": {
          "type": "string"
        }
      },
      "XForkPdfSdkUpgradeUrl": {
        "description": "SDK changelog URL for outdated clients.",
        "schema": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Validation error. `code` identifies the specific rule.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key or project ID.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "Insufficient credits or overage limit reached.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The API key lacks the required permission, or the request targets a restricted network address.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "NotFound": {
        "description": "Template, PDF, or failed webhook not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Conflict": {
        "description": "The requested state transition is not allowed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "PayloadTooLarge": {
        "description": "Request or output exceeds a size limit.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "The document could not be healed or the test case failed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limit exceeded.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Unexpected server or database error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "BadGateway": {
        "description": "The rendering engine failed or returned an invalid response.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "PaperFormat": {
        "type": "string",
        "description": "Standard page format. Case-insensitive.",
        "enum": [
          "Letter",
          "Legal",
          "Tabloid",
          "Ledger",
          "A0",
          "A1",
          "A2",
          "A3",
          "A4",
          "A5",
          "A6",
          "letter",
          "legal",
          "tabloid",
          "ledger",
          "a0",
          "a1",
          "a2",
          "a3",
          "a4",
          "a5",
          "a6"
        ],
        "default": "A4"
      },
      "WaitUntil": {
        "type": "string",
        "description": "When the page is considered ready for capture. Use `isProcessed` to wait for `window.isProcessed = true`.",
        "enum": [
          "load",
          "domcontentloaded",
          "networkidle0",
          "networkidle2",
          "isProcessed"
        ],
        "default": "domcontentloaded"
      },
      "TargetLang": {
        "type": "string",
        "description": "Document/form language used for form fonts and PDF document language metadata. For PDF/UA output, set `lang` on the `<html>` element for the document default and on individual HTML elements for language changes; those attributes are preserved as per-element PDF `/Lang` entries when they differ from the document language.",
        "enum": [
          "en",
          "hi",
          "th",
          "ja",
          "zh",
          "ko",
          "ar"
        ]
      },
      "FontPolicy": {
        "type": "string",
        "description": "`warn` reports advisory warnings; `strict` rejects external stylesheets, non-inline fonts, and system-font fallback.",
        "enum": [
          "warn",
          "strict"
        ],
        "default": "warn"
      },
      "EmulateMediaType": {
        "type": "string",
        "enum": [
          "print",
          "screen"
        ],
        "default": "print"
      },
      "Margins": {
        "type": "object",
        "description": "Page margins. Values may be numbers (pixels) or dimension strings such as `20px`, `1in`, `2cm`, or `18mm`. `pt` is not supported.",
        "additionalProperties": false,
        "properties": {
          "top": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 14
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "right": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 14
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "bottom": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 14
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "left": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 14
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          }
        }
      },
      "ComplianceOptions": {
        "type": "object",
        "description": "Stable PDF/UA-1 and PDF/UA-2 output, standalone PDF/A, or supported combinations. PDF/UA-1 combines with PDF/A-2/3; PDF/UA-2 combines with PDF/A-4. Authoring requirements still apply: use semantic HTML, accurate document and element `lang` values, table headers, descriptive link names, and alt text for meaningful figures. Inline SVG figures require image figures with alt text for assistive-technology support.",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "pdfUa": {
            "type": "integer",
            "enum": [
              1,
              2
            ]
          },
          "pdfA": {
            "type": "string",
            "enum": [
              "2b",
              "2u",
              "2a",
              "3b",
              "3u",
              "3a",
              "4"
            ]
          }
        }
      },
      "ComplianceStatus": {
        "type": "object",
        "description": "Per-capability status. PDF/UA-1 and PDF/UA-2 report `stable`; font embedding is verified independently.",
        "properties": {
          "fontPolicy": {
            "type": "string",
            "enum": [
              "warn",
              "strict"
            ]
          },
          "fontEmbedding": {
            "type": "string",
            "enum": [
              "verified"
            ]
          },
          "pdfA": {
            "type": "string",
            "enum": [
              "stable",
              "verified",
              "machine-validated",
              "experimental"
            ]
          },
          "pdfAFlavor": {
            "type": "string",
            "enum": [
              "2b",
              "2u",
              "2a",
              "3b",
              "3u",
              "3a",
              "4"
            ]
          },
          "pdfUa": {
            "type": "string",
            "enum": [
              "stable",
              "verified",
              "machine-validated",
              "experimental"
            ]
          },
          "pdfUaVersion": {
            "type": "integer",
            "enum": [
              1,
              2
            ]
          }
        }
      },
      "TestResults": {
        "type": "object",
        "description": "Arbitrary JSON returned by `testCase`. Typical keys include `success` and `total_attempts`. Results above 8 KB are truncated.",
        "additionalProperties": true
      },
      "Accessibility": {
        "type": "object",
        "properties": {
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "warnings"
        ]
      },
      "GenerateRequest": {
        "type": "object",
        "description": "Provide exactly one of `url`, `htmlContent`, or `templateId`. `data` applies to `htmlContent` and `templateId`. `width` and `height` must be supplied together.",
        "additionalProperties": false,
        "oneOf": [
          {
            "required": [
              "url"
            ]
          },
          {
            "required": [
              "htmlContent"
            ]
          },
          {
            "required": [
              "templateId"
            ]
          }
        ],
        "dependentRequired": {
          "width": [
            "height"
          ],
          "height": [
            "width"
          ]
        },
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Public HTTP or HTTPS URL to render. Internal, loopback, private, link-local, and cloud-metadata addresses are rejected."
          },
          "htmlContent": {
            "type": "string",
            "description": "Raw HTML to render. The total request body is limited to 20 MB. PDF/UA output preserves semantic HTML and per-element `lang` attributes as tagged structure and PDF `/Lang` entries."
          },
          "templateId": {
            "type": "string",
            "format": "uuid",
            "description": "Saved dashboard template UUID."
          },
          "format": {
            "$ref": "#/components/schemas/PaperFormat"
          },
          "width": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 15
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ],
            "description": "Custom page width. Units: px, in, cm, mm. Numbers are pixels. `pt` is not supported. Must be provided with `height`."
          },
          "height": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 15
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ],
            "description": "Custom page height. Units: px, in, cm, mm. Numbers are pixels. `pt` is not supported. Must be provided with `width`."
          },
          "css": {
            "type": "string",
            "description": "CSS injected into the document."
          },
          "js": {
            "type": "string",
            "description": "JavaScript injected into the document."
          },
          "waitUntil": {
            "$ref": "#/components/schemas/WaitUntil"
          },
          "landscape": {
            "type": "boolean",
            "default": false
          },
          "data": {
            "type": "object",
            "description": "JSON payload for the Nunjucks template. Used with `htmlContent` or `templateId`.",
            "additionalProperties": true
          },
          "spatial": {
            "type": "boolean",
            "default": false,
            "description": "Return a ZIP containing the PDF and `data.pb` spatial layout."
          },
          "pdfForm": {
            "type": "boolean",
            "default": false,
            "description": "Convert standard HTML form controls into interactive AcroForm fields."
          },
          "compliance": {
            "$ref": "#/components/schemas/ComplianceOptions"
          },
          "fontPolicy": {
            "$ref": "#/components/schemas/FontPolicy"
          },
          "margins": {
            "$ref": "#/components/schemas/Margins"
          },
          "preferCSSPageSize": {
            "type": "boolean",
            "default": false,
            "description": "Give a CSS `@page` size priority over `width`, `height`, or `format`."
          },
          "omitBackground": {
            "type": "boolean",
            "default": false,
            "description": "Hide the default white background and allow transparency."
          },
          "testCase": {
            "type": "string",
            "description": "JavaScript assertion executed against the rendered spatial DOM. Return `{ success: true, ...custom }` or `{ success: false, reason }`. May return a `patch` object to heal layout issues."
          },
          "targetLang": {
            "$ref": "#/components/schemas/TargetLang"
          },
          "deviceScaleFactor": {
            "type": "number",
            "minimum": 0.1,
            "default": 1,
            "description": "Device pixel density. Use 2 or 3 for Retina rendering."
          },
          "zoom": {
            "type": "number",
            "minimum": 0.1,
            "description": "Viewport zoom factor."
          },
          "emulateMediaType": {
            "$ref": "#/components/schemas/EmulateMediaType"
          },
          "timeout": {
            "type": "integer",
            "minimum": 3000,
            "maximum": 30000,
            "default": 10000,
            "description": "Render timeout in milliseconds."
          },
          "webhook": {
            "type": "boolean",
            "default": false,
            "description": "Queue generation and deliver the final payload to the project webhook. Cannot be combined with `streamOnly`."
          },
          "streamOnly": {
            "type": "boolean",
            "default": false,
            "description": "Return the raw PDF or ZIP body instead of JSON. Cannot be combined with `webhook`."
          },
          "healAttempt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Internal self-healing counter. Only valid with `webhook: true`; the API increments and enforces a maximum of 100."
          },
          "targetPdfId": {
            "type": "string",
            "format": "uuid",
            "description": "UUIDv7 of an existing failed PDF to overwrite/heal. Only failed PDFs in the same project are eligible."
          }
        }
      },
      "GenerateResponse": {
        "type": "object",
        "required": [
          "success",
          "id",
          "downloadUrl"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "message": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "s3Key": {
            "type": "string"
          },
          "testResults": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TestResults"
              },
              {
                "type": "null"
              }
            ]
          },
          "downloadUrl": {
            "type": "string",
            "format": "uri",
            "description": "Signed URL valid for approximately 15 minutes."
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0
          },
          "accessibility": {
            "$ref": "#/components/schemas/Accessibility"
          },
          "compliance": {
            "$ref": "#/components/schemas/ComplianceOptions"
          },
          "complianceStatus": {
            "$ref": "#/components/schemas/ComplianceStatus"
          },
          "warnings": {
            "type": "array",
            "description": "Advisory authoring or accessibility warnings. An empty array does not replace document-specific accessibility review.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "GenerateQueuedResponse": {
        "type": "object",
        "required": [
          "success",
          "id",
          "status"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "message": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "const": "pending"
          }
        }
      },
      "PdfRecord": {
        "type": "object",
        "required": [
          "id",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "generationType": {
            "type": "string",
            "enum": [
              "url",
              "payload",
              "template"
            ]
          },
          "templateId": {
            "oneOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "completed",
              "failed"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "oneOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "expiresAt": {
            "oneOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "testResults": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TestResults"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "PdfListResponse": {
        "type": "object",
        "required": [
          "success",
          "data",
          "meta"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PdfRecord"
            }
          },
          "meta": {
            "type": "object",
            "required": [
              "totalItems",
              "currentPage",
              "itemsPerPage",
              "totalPages"
            ],
            "properties": {
              "totalItems": {
                "type": "integer",
                "minimum": 0
              },
              "currentPage": {
                "type": "integer",
                "minimum": 1
              },
              "itemsPerPage": {
                "type": "integer",
                "minimum": 1
              },
              "totalPages": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        }
      },
      "PdfDetailResponse": {
        "type": "object",
        "required": [
          "success",
          "data"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "data": {
            "$ref": "#/components/schemas/PdfRecord"
          }
        }
      },
      "DownloadUrlResponse": {
        "type": "object",
        "required": [
          "success",
          "downloadUrl",
          "isZip"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "downloadUrl": {
            "type": "string",
            "format": "uri",
            "description": "Signed URL valid for approximately 15 minutes."
          },
          "isZip": {
            "type": "boolean",
            "description": "True when the PDF was generated with `spatial: true` and the result is a ZIP."
          }
        }
      },
      "DeleteResponse": {
        "type": "object",
        "required": [
          "success",
          "message"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "message": {
            "type": "string"
          }
        }
      },
      "WebhookFailure": {
        "type": "object",
        "required": [
          "id",
          "status",
          "failedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "s3Key": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "const": "failed"
          },
          "failedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookFailureListResponse": {
        "type": "object",
        "required": [
          "success",
          "data",
          "meta"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookFailure"
            }
          },
          "meta": {
            "type": "object",
            "required": [
              "totalItems"
            ],
            "properties": {
              "totalItems": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        }
      },
      "WebhookRetryResponse": {
        "type": "object",
        "required": [
          "success",
          "message"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "message": {
            "type": "string"
          },
          "queuedCount": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "WebhookSuccessPayload": {
        "$ref": "#/components/schemas/GenerateResponse"
      },
      "WebhookFailurePayload": {
        "type": "object",
        "required": [
          "id",
          "status",
          "error"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "const": "failed"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "WebhookPayload": {
        "description": "Body POSTed to the project webhook. The `x-webhook-signature` header is `t=<unix>,v1=<hex>`, an HMAC-SHA256 of `\"<t>.<raw-body>\"` using the project webhook secret.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/WebhookSuccessPayload"
          },
          {
            "$ref": "#/components/schemas/WebhookFailurePayload"
          }
        ]
      },
      "ComplianceCapabilities": {
        "type": "object",
        "required": [
          "success",
          "pdfA",
          "pdfUa",
          "combinations",
          "fontEmbedding",
          "forms"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "pdfA": {
            "type": "object",
            "required": [
              "status",
              "supported",
              "standalone"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "verified",
                  "stable",
                  "machine-validated",
                  "experimental"
                ]
              },
              "supported": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "2b",
                    "2u",
                    "2a",
                    "3b",
                    "3u",
                    "3a",
                    "4"
                  ]
                }
              },
              "standalone": {
                "type": "boolean"
              }
            }
          },
          "pdfUa": {
            "type": "object",
            "required": [
              "status",
              "supported",
              "standalone"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "verified",
                  "stable",
                  "machine-validated",
                  "experimental"
                ]
              },
              "supported": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "enum": [
                    1,
                    2
                  ]
                }
              },
              "standalone": {
                "type": "boolean"
              }
            }
          },
          "combinations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "pdfUa",
                "pdfA"
              ],
              "properties": {
                "pdfUa": {
                  "type": "integer",
                  "enum": [
                    1,
                    2
                  ]
                },
                "pdfA": {
                  "type": "string",
                  "enum": [
                    "2b",
                    "2u",
                    "2a",
                    "3b",
                    "3u",
                    "3a",
                    "4"
                  ]
                }
              }
            }
          },
          "fontEmbedding": {
            "type": "object",
            "required": [
              "status",
              "policy"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "verified",
                  "stable",
                  "machine-validated",
                  "experimental"
                ]
              },
              "policy": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "warn",
                    "strict"
                  ]
                }
              }
            }
          },
          "forms": {
            "type": "object",
            "required": [
              "withCompliance",
              "withPdfUa",
              "withPdfA"
            ],
            "properties": {
              "withCompliance": {
                "type": "boolean"
              },
              "withPdfUa": {
                "type": "boolean"
              },
              "withPdfA": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "success",
          "error"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "code": {
            "type": "string",
            "description": "Machine-readable error code, for example `MUTUALLY_EXCLUSIVE_INPUTS`, `PAYMENT_REQUIRED`, or `NOT_FOUND`."
          },
          "error": {
            "type": "string"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "limitBytes": {
            "type": "integer"
          },
          "sizeBytes": {
            "type": "integer"
          },
          "testResultsBytes": {
            "type": "integer"
          },
          "combinedBytes": {
            "type": "integer"
          },
          "testResults": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TestResults"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      }
    }
  }
}
