{"openapi":"3.0.0","info":{"title":"Anvil API","version":"1.0.0","description":"REST APIs for Anvil's document automation platform. Includes PDF filling, PDF generation, and more."},"servers":[{"url":"https://app.useanvil.com","description":"Production"}],"paths":{"/api/v1/fill/{castEid}.pdf":{"post":{"operationId":"fillPdf","summary":"Fill a PDF template","description":"Fills a PDF template (Cast) with the provided data and returns the resulting PDF.\n\nTemplates are created and managed in the Anvil dashboard or via the GraphQL `createCast` mutation.\nEach template defines named fields (text, date, checkbox, signature, etc.) that can be populated via\nthis endpoint. The field data can be supplied as a flat object keyed by field ID\nor alias, or as an array of objects for multi-page repeating templates.\n\nSupports both JSON and multipart/form-data request bodies. When using\nmultipart/form-data, string values for `fontSize` and `page` are automatically\nparsed.\n\nRequires API key (Basic auth) or OAuth authentication. Development API keys\nproduce watermarked PDFs; production keys produce clean PDFs and count toward\nyour plan's usage.\n","tags":["PDF"],"security":[{"basicAuth":[]},{"oauth2":[]}],"parameters":[{"name":"castEid","in":"path","required":true,"description":"The EID (external identifier) of the PDF template (Cast) to fill.","schema":{"type":"string"}},{"name":"versionNumber","in":"query","required":false,"description":"The version number of the template to use. If omitted, the latest\npublished version is used. Use this to pin fills to a specific\ntemplate revision.\n","schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FillPdfRequest"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/FillPdfRequest"}}}},"responses":{"200":{"description":"The filled PDF document.","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Validation error — invalid or missing fields in the request body."},"401":{"description":"Authentication required — API key or OAuth token is missing or invalid."},"404":{"description":"Template not found — no Cast exists with the given EID, or the authenticated user lacks access."},"415":{"description":"Unsupported media type — Content-Type must be application/json or multipart/form-data."},"429":{"description":"Concurrency limit exceeded — too many simultaneous requests on a development API key."}}}},"/api/v1/generate-pdf":{"post":{"operationId":"generatePdf","summary":"Generate a PDF from HTML or Markdown","description":"Generates a PDF document from either Markdown content or raw HTML/CSS.\nThe generation mode is determined automatically: if the request body\ncontains `type: \"html\"` or the `data` property includes an `html` key,\nHTML-to-PDF rendering is used; otherwise, Markdown-to-PDF rendering is used.\n\n**Markdown mode** accepts structured content blocks (headings, labels,\nbody text, and tables) and renders them into a styled PDF with optional\nlogo, timestamp, and custom page dimensions.\n\n**HTML mode** accepts raw HTML and optional CSS, rendering them directly\ninto a PDF with optional custom page dimensions.\n\nSupports both JSON and multipart/form-data request bodies. Requires API\nkey (Basic auth) or OAuth authentication.\n","tags":["PDF"],"security":[{"basicAuth":[]},{"oauth2":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/GenerateMarkdownPdfRequest"},{"$ref":"#/components/schemas/GenerateHtmlPdfRequest"}]}},"multipart/form-data":{"schema":{"oneOf":[{"$ref":"#/components/schemas/GenerateMarkdownPdfRequest"},{"$ref":"#/components/schemas/GenerateHtmlPdfRequest"}]}}}},"responses":{"200":{"description":"The generated PDF document.","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Validation error — invalid or missing fields in the request body."},"401":{"description":"Authentication required — API key or OAuth token is missing or invalid."},"415":{"description":"Unsupported media type — Content-Type must be application/json or multipart/form-data."},"429":{"description":"Concurrency limit exceeded — too many simultaneous requests on a development API key."}}}}},"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"Use your API key as the username with an empty password."},"oauth2":{"type":"oauth2","flows":{}}},"schemas":{"FillPdfRequest":{"type":"object","required":["data"],"properties":{"title":{"type":"string","description":"Custom title for the generated PDF. Overrides the template's default title."},"data":{"description":"The field data to fill into the template. Can be a single object keyed by\nfield ID or alias, or an array of objects for multi-page / repeating fills.\nEach value can be a primitive (string, number, boolean), or a value object\nwith a `value` key alongside styling overrides.\n","oneOf":[{"type":"object","additionalProperties":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"object","description":"A value object with optional per-field styling overrides.","properties":{"value":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}}]}},{"type":"array","items":{"type":"object","additionalProperties":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"object","properties":{"value":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}}]}}}]},"textColor":{"type":"string","description":"Default text color for all fields, as a CSS hex color (e.g. `#FF0000`)."},"fontSize":{"type":"integer","description":"Default font size in points for all fields.","minimum":5,"maximum":30},"fontFamily":{"type":"string","description":"Default font family name for all fields."},"borderColor":{"type":"string","description":"Default border color for field bounding boxes, as a CSS hex color."},"verticalAlignment":{"type":"string","description":"Default vertical alignment for text within fields.","enum":["top","middle","bottom"]},"defaultCheckboxCharacter":{"type":"string","description":"The character used to represent a checked checkbox."},"defaultMakeCheckboxSquare":{"type":"boolean","description":"When true, checkbox fields are rendered as squares instead of the default shape."},"useInteractiveFields":{"type":"boolean","description":"When true, the filled PDF will contain interactive AcroForm fields\nthat can be edited by the recipient in a PDF viewer. Requires a paid plan.\n"},"drawDebugBoxes":{"type":"boolean","description":"When true, draws visible bounding boxes around each field for debugging layout issues."},"stripAnnotations":{"type":"boolean","description":"When true, removes all PDF annotations from the output."},"defaultReadOnly":{"type":"boolean","description":"Controls whether interactive AcroForm fields default to read-only.\nOnly applicable when `useInteractiveFields` is true. Defaults to false\nwhen `useInteractiveFields` is enabled.\n"},"outputFormat":{"type":"string","description":"Controls the response format. When set to `url`, the filled PDF is\nuploaded to cloud storage and a JSON response with a short-lived signed\nURL is returned instead of the binary PDF. The signed URL expires 5\nminutes after generation. Defaults to `pdf` (binary PDF response).\n","enum":["pdf","url"],"default":"pdf"}}},"PageOptions":{"type":"object","description":"Custom page dimensions and margins for the generated PDF.","properties":{"width":{"type":"string","description":"Page width with unit (e.g. `8.5in`, `210mm`)."},"height":{"type":"string","description":"Page height with unit (e.g. `11in`, `297mm`)."},"margin":{"type":"string","description":"Shorthand margin for all sides (e.g. `0.5in`, `10mm 20mm`)."},"marginTop":{"type":"string","description":"Top margin with unit."},"marginRight":{"type":"string","description":"Right margin with unit."},"marginBottom":{"type":"string","description":"Bottom margin with unit."},"marginLeft":{"type":"string","description":"Left margin with unit."},"pageCount":{"type":"string","description":"Position to render page numbers on each page.","enum":["topLeft","topRight","topCenter","bottomLeft","bottomRight","bottomCenter"]}}},"GenerateMarkdownPdfRequest":{"type":"object","required":["data"],"description":"Generate a PDF from structured Markdown-style content blocks.\nEach item in the `data` array represents a content section that\ncan contain headings, labeled values, body text, or tables.\n","properties":{"title":{"type":"string","description":"The document title. Used as the PDF metadata title and in the output filename."},"data":{"type":"array","description":"An array of content blocks that make up the PDF body. Each block\ncan contain one or more of: `heading`, `label`, `content`, `table`.\n","minItems":1,"items":{"type":"object","properties":{"heading":{"type":"string","description":"A section heading rendered in a larger, bold font."},"label":{"type":"string","description":"A label rendered in bold, typically used for key-value pairs."},"content":{"type":"string","description":"Body text content, rendered as a paragraph. Supports Markdown formatting."},"table":{"type":"object","description":"A table rendered inline in the PDF.","required":["rows"],"properties":{"rows":{"type":"array","description":"Table data as a 2D array of strings (array of rows, each row is an array of cell values).","items":{"type":"array","items":{"type":"string"}}},"columnOptions":{"type":"array","description":"Per-column display options.","items":{"type":"object","properties":{"align":{"type":"string","description":"Horizontal text alignment for this column.","enum":["left","center","right"]},"width":{"type":"string","description":"Column width as a percentage or pixel value (e.g. `25%`, `100px`)."}}}},"verticalAlign":{"type":"string","description":"Vertical alignment of cell content.","enum":["top","center","bottom"]},"firstRowHeaders":{"type":"boolean","description":"When true, the first row is rendered as a header row with bold styling."},"rowGridlines":{"type":"boolean","description":"When true, horizontal gridlines are drawn between rows."},"columnGridlines":{"type":"boolean","description":"When true, vertical gridlines are drawn between columns."}}},"fontSize":{"type":"integer","description":"Font size override for this content block.","minimum":5,"maximum":30},"textColor":{"type":"string","description":"Text color override for this block, as a CSS hex color."},"fontFamily":{"type":"string","description":"Font family override for this content block."}}}},"textColor":{"type":"string","description":"Default text color for the document, as a CSS hex color (e.g. `#333333`)."},"fontSize":{"type":"integer","description":"Default font size in points for the document.","minimum":5,"maximum":30},"fontFamily":{"type":"string","description":"Default font family for the document."},"logo":{"description":"A logo image to display at the top of the PDF. Set to `false` to\nexplicitly disable any default logo. Provide an object with a\nbase64-encoded or URL image source to include a logo.\n","oneOf":[{"type":"boolean","enum":[false]},{"type":"object","required":["src"],"properties":{"src":{"type":"string","description":"Image source: a base64-encoded data URI or an HTTPS URL."},"maxWidth":{"oneOf":[{"type":"string"},{"type":"number"}],"description":"Maximum width of the logo in pixels."},"maxHeight":{"oneOf":[{"type":"string"},{"type":"number"}],"description":"Maximum height of the logo in pixels."}}}]},"includeTimestamp":{"type":"boolean","description":"When true, a timestamp is printed on the PDF showing when it was generated."},"page":{"$ref":"#/components/schemas/PageOptions"},"outputFormat":{"type":"string","description":"Controls the response format. When set to `url`, the generated PDF is\nuploaded to cloud storage and a JSON response with a short-lived signed\nURL is returned instead of the binary PDF. The signed URL expires 5\nminutes after generation. Defaults to `pdf` (binary PDF response).\n","enum":["pdf","url"],"default":"pdf"}}},"GenerateHtmlPdfRequest":{"type":"object","required":["data"],"description":"Generate a PDF by rendering raw HTML and optional CSS.","properties":{"title":{"type":"string","description":"The document title. Used as the PDF metadata title and in the output filename."},"type":{"type":"string","description":"Set to `html` to explicitly select HTML-to-PDF rendering.","enum":["html"]},"data":{"type":"object","required":["html"],"description":"The HTML content and optional CSS to render into a PDF.","properties":{"html":{"type":"string","description":"The HTML markup to render. This is the full body content of the PDF."},"css":{"type":"string","description":"Optional CSS stylesheet applied to the HTML content during rendering."}}},"page":{"$ref":"#/components/schemas/PageOptions"},"outputFormat":{"type":"string","description":"Controls the response format. When set to `url`, the generated PDF is\nuploaded to cloud storage and a JSON response with a short-lived signed\nURL is returned instead of the binary PDF. The signed URL expires 5\nminutes after generation. Defaults to `pdf` (binary PDF response).\n","enum":["pdf","url"],"default":"pdf"}}}}},"tags":[]}