---
title: "Fill PDF form fields"
method: POST
path: "/api/pdf-forms/fill"
tags: ["PDF Forms"]
---

# Fill PDF form fields

`POST /api/pdf-forms/fill`

## Request

- Base URL: `https://api.dokmatiq.com`
- URL: `https://api.dokmatiq.com/api/pdf-forms/fill`
- Auth: API key in header `X-API-Key`

Fill form fields in a PDF with the provided values. Optionally flatten the form (convert to static content) and/or protect with a password. Use the inspect endpoint first to discover available field names.

## Headers

- `X-DocGen-Validate` string

## Request body

- PdfFormFillRequest: Base64-encoded PDF
  - `pdfBase64` string, required: Base64-encoded PDF form file
  - `fields` object, required: Field values to fill (key = field name, value = field value). For text fields: the text string. For checkboxes: 'Yes'/'On'/'true' to check, 'Off'/'false' to uncheck. For radio buttons: the value of the option to select. For dropdowns/listboxes: the value to select.
  - `flatten` boolean: Flatten the form after filling. When true, form fields are converted to static text and the PDF is no longer editable. Recommended for final documents.
  - `password` string: Password to protect the filled PDF (optional)

## Response `200`

Filled PDF document

## Other responses

- `400`: Invalid request or PDF has no form fields

---

[API](https://skmtc.dev/dokmatiq/apis/docgen-api.md) · [All operations](https://skmtc.dev/dokmatiq/apis/docgen-api/llms.txt) · [OpenAPI document](https://skmtc.dev/dokmatiq/apis/docgen-api/revisions/3fa1a922764d?raw)
