How to Pre-Fill Document Fields

Pre-fill text, date, checkbox, and dropdown fields when creating a document from a template via the PandaDoc API.

Problem

You need to pre-fill interactive fields (text, date, checkbox, dropdown) with values when creating a document from a template via the API, so recipients see pre-populated data instead of empty fields.

Prerequisites

  • A PandaDoc template with interactive fields assigned to roles
  • A PandaDoc API key or OAuth token
  • Familiarity with the Create Document endpoint
🚧

You cannot pre-fill Signature fields.

Solution

Step 1: Map template merge fields to API field keys

Each field in your template has a merge field name that you use as the key in the API request. To find it:

  1. Open your template in the PandaDoc web app.
  2. Click on a field to open its properties.
Field properties

Field properties

  1. Scroll down to Merge Field and note (or set) a meaningful name:

Step 2: Include field values in the create request

Add a fields object to your create document request body. Each key is the merge field name, and the value depends on the field type:

"fields": {
    "Favorite.Color": {
        "value": "PandaDoc green"
    },
    "Delivery": {
        "value": "Same Day Delivery"
    },
    "Like": {
        "value": true
    },
    "Date": {
        "value": "2019-12-31T00:00:00.000Z"
    }
}

Date field formatting

Pass date values in ISO 8601 format: "value": "2019-02-21T00:00:00.000Z".

The display format is controlled by the date field settings in your template, not by the API value. The API value determines which date is selected; the template determines how it appears to recipients.

Verification

  1. After creating the document, confirm it reaches document.draft status.
  2. Open the document in the PandaDoc web app and verify that fields display the expected pre-filled values.
  3. Use the Document Details endpoint to inspect field values programmatically.

Related