How to Create a Document from a Template

Create a document from a PandaDoc template via API, with optional customization of fields, images, pricing, and content.

Problem

You need to create a new document from a PandaDoc template via the API. Templates let you standardize document structure, branding, and content while dynamically filling in recipient details, field values, pricing, and images at creation time.

Prerequisites

  • A PandaDoc API key or OAuth token
  • A PandaDoc template created in the web app (help center guide)
  • The template's UUID (found in the browser address bar: https://app.pandadoc.com/a/#/templates/{ID}/content)

You can use the sample PandaDoc template to test your first request.

Solution

Step 1: Build the request body

At minimum, provide the template UUID and recipients:

{
  "name": "Contract for Acme Corp",
  "template_uuid": "ustHNnVaPCD6MzuoNBbZ8L",
  "recipients": [
    {
      "email": "[email protected]",
      "first_name": "Jane",
      "last_name": "Roe",
      "role": "Signer"
    }
  ]
}

See the Create Document API reference for all available parameters.

Step 2: Send the create request

POST /public/v1/documents

The response returns the document ID with status document.uploaded:

{
  "id": "XHjv8z3SfDuTseFSnhprML",
  "name": "Contract for Acme Corp",
  "status": "document.uploaded",
  "date_created": "2021-07-05T15:05:27.787341Z",
  "date_modified": "2021-07-05T15:05:27.787341Z",
  "uuid": "XHjv8z3SfDuTseFSnhprML"
}

Step 3: Wait for draft status

Document creation is asynchronous. The document is not ready until it reaches document.draft status. See Building a Reliable Document Creation Workflow for polling and webhook strategies.

❗️

Attempting to use a newly created document before it reaches document.draft status will result in a "404 document not found" response.

Customization options

You can customize many aspects of the document at creation time. Each area has a dedicated guide:

WhatGuide
Pre-fill field values (text, date, checkbox, dropdown)How to Pre-Fill Document Fields
Add images to image blocksHow to Add an Image to a Document via API
Populate pricing tables with rows, taxes, and feesHow to Work with Pricing Tables
Populate text blocks with markdown contentHow to Populate and Update Text Blocks
Replace content placeholders with content library itemsHow to Use Content Placeholders
Set or override recipient signing orderHow to Set a Signing Order
Create a document on a colleague's behalfCreate on Member's Behalf
Use variables in the document nameHow to Use Variables in Document Titles

Verification

  1. Check the document status — confirm it reaches document.draft.
  2. Open the document in the PandaDoc web app to verify recipients, fields, and content rendered correctly.
  3. Use the Document Details endpoint to inspect the created document programmatically.

Related