---
title: "Fill a PDF template"
method: POST
path: "/api/v1/fill/{castEid}.pdf"
tags: ["PDF"]
---

# Fill a PDF template

`POST /api/v1/fill/{castEid}.pdf`

Fills a PDF template (Cast) with the provided data and returns the resulting PDF.

Templates are created and managed in the Anvil dashboard or via the GraphQL `createCast` mutation.
Each template defines named fields (text, date, checkbox, signature, etc.) that can be populated via
this endpoint. The field data can be supplied as a flat object keyed by field ID
or alias, or as an array of objects for multi-page repeating templates.

Supports both JSON and multipart/form-data request bodies. When using
multipart/form-data, string values for `fontSize` and `page` are automatically
parsed.

Requires API key (Basic auth) or OAuth authentication. Development API keys
produce watermarked PDFs; production keys produce clean PDFs and count toward
your plan's usage.

## Path parameters

- `castEid` string, required

## Query parameters

- `versionNumber` integer

## Request body

- FillPdfRequest
  - `title` string — Custom title for the generated PDF. Overrides the template's default title.
  - `data` union, required — The field data to fill into the template. Can be a single object keyed by field ID or alias, or an array of objects for multi-page / repeating fills. Each value can be a primitive (string, number, boolean), or a value object with a `value` key alongside styling overrides.
    - object
    - object[]
  - `textColor` string — Default text color for all fields, as a CSS hex color (e.g. `#FF0000`).
  - `fontSize` integer — Default font size in points for all fields.
  - `fontFamily` string — Default font family name for all fields.
  - `borderColor` string — Default border color for field bounding boxes, as a CSS hex color.
  - `verticalAlignment` 'top' | 'middle' | 'bottom' — Default vertical alignment for text within fields.
  - `defaultCheckboxCharacter` string — The character used to represent a checked checkbox.
  - `defaultMakeCheckboxSquare` boolean — When true, checkbox fields are rendered as squares instead of the default shape.
  - `useInteractiveFields` boolean — When true, the filled PDF will contain interactive AcroForm fields that can be edited by the recipient in a PDF viewer. Requires a paid plan.
  - `drawDebugBoxes` boolean — When true, draws visible bounding boxes around each field for debugging layout issues.
  - `stripAnnotations` boolean — When true, removes all PDF annotations from the output.
  - `defaultReadOnly` boolean — Controls whether interactive AcroForm fields default to read-only. Only applicable when `useInteractiveFields` is true. Defaults to false when `useInteractiveFields` is enabled.
  - `outputFormat` 'pdf' | 'url' — Controls the response format. When set to `url`, the filled PDF is uploaded to cloud storage and a JSON response with a short-lived signed URL is returned instead of the binary PDF. The signed URL expires 5 minutes after generation. Defaults to `pdf` (binary PDF response).

## Response `200`

The filled PDF document.

## Other responses

- `400` — Validation error — invalid or missing fields in the request body.
- `401` — Authentication required — API key or OAuth token is missing or invalid.
- `404` — Template not found — no Cast exists with the given EID, or the authenticated user lacks access.
- `415` — Unsupported media type — Content-Type must be application/json or multipart/form-data.
- `429` — Concurrency limit exceeded — too many simultaneous requests on a development API key.

---

[API](https://skmtc.net/useanvil/apis/anvil-api.md) · [All operations](https://skmtc.net/useanvil/apis/anvil-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/useanvil/anvil-api/revisions/ce258d1167ca/schema)
