Check out our complete how-to-guides, documentation, and resources below

Empowering developers to build document workflows in minutes.

Create from template with content placeholder

Introduction

Make your document dynamic with Content Placeholders and add content to a document in the creation request. Decide what Content Library Items to add (different countries' terms & conditions, pricing tables with predefined currencies, additional fields or product information, etc.) to the document based on the data merged. In addition, you can prefill fields/variables values, add items to pricing tables, and assign recipients to roles from the specific Content Library Item.

This recipe assumes:

Add Content Placeholder to a template

Easily add Content Placeholder block to a template where you want to add content during document creation.

Template with Content Placeholder onlyTemplate with Content Placeholder only

Template with Content Placeholder only

Locate your template ID, Content Placeholder Block IDs, and Content Library Item IDs to be added to a document

Template IDTemplate ID

Template ID

  • Open the settings section of Content Placeholder to find or change a Block ID or get template details via API.
Content Placeholder Block IDContent Placeholder Block ID

Content Placeholder Block ID

"content_placeholders": [
        {
            "uuid": "a3293bbf-9109-4478-a875-8271e10a99e9",
            "block_id": "Content Placeholder 1",
            "description": "Click here to add content library items"
        }
    ]
  • Open a Content Library Item and find the ID in the same way as for the template.
Sample Pricing Table -> Content Library Item IDSample Pricing Table -> Content Library Item ID

Sample Pricing Table -> Content Library Item ID

Sample Signature Block -> Content Library Item IDSample Signature Block -> Content Library Item ID

Sample Signature Block -> Content Library Item ID

Get Content Library Item Details

Use get content library item details endpoint to understand what structure does it have and what values you can prefill.

  • Sample Pricing Table
{
    "id": "9d9k7VtSQ5KCXfsUQv4GxE",
    "name": "Sample Pricing Table",
    "date_created": "2021-08-11T14:12:20.017074Z",
    "date_modified": "2021-08-11T14:13:38.562290Z",
    "created_by": {
        "id": "ajnN7eGutJZsRKjQrNuPkC",
        "email": "[email protected]",
        "first_name": "Jane",
        "last_name": "Roe",
        "avatar": "https://avatars.pandadoc-static.com/users/ajnN7eGutJZsRKjQrNuPkC/avatar.JPG"
    },
    "metadata": {},
    "tokens": [],
    "fields": [],
    "pricing": {
        "tables": [
            {
                "name": "Pricing Table 1",
                "id": "6cf232ef-1266-43f7-859a-e05a0f65baee",
                "total": "38.25",
                "is_included_in_total": true,
                "summary": {
                    "subtotal": "45",
                    "total": "38.25",
                    "discount": "6.75",
                    "tax": "0"
                },
                "items": [
                    {
                        "id": null,
                        "sku": null,
                        "qty": "5",
                        "name": "Monthly Subscription - Individual Plan",
                        "cost": null,
                        "price": "9",
                        "description": "",
                        "custom_fields": {},
                        "custom_columns": {
                            "Cost": "",
                            "Images": "",
                            "Subtotal": ""
                        },
                        "discount": null,
                        "tax_first": null,
                        "tax_second": null,
                        "subtotal": "45",
                        "options": {
                            "optional": true,
                            "optional_selected": true
                        },
                        "sale_price": "9",
                        "taxes": {},
                        "discounts": {},
                        "fees": {}
                    },
                    {
                        "id": null,
                        "sku": null,
                        "qty": "1",
                        "name": "Monthly Subscription - Business Plan",
                        "cost": null,
                        "price": "49",
                        "description": "",
                        "custom_fields": {},
                        "custom_columns": {
                            "Cost": "",
                            "Images": "",
                            "Subtotal": ""
                        },
                        "discount": null,
                        "tax_first": null,
                        "tax_second": null,
                        "subtotal": "49",
                        "options": {
                            "optional": true,
                            "optional_selected": false
                        },
                        "sale_price": "49",
                        "taxes": {},
                        "discounts": {},
                        "fees": {}
                    }
                ],
                "currency": "USD"
            }
        ],
        "total": "38.25"
    },
    "tags": [],
    "roles": [],
    "version": "2",
    "content_placeholders": []
}
  • Sample Signature Block
{
    "id": "5NfLkZRqa2PeujSVDUCT3Z",
    "name": "Sample Signature Block",
    "date_created": "2021-08-12T08:53:16.607387Z",
    "date_modified": "2021-08-12T08:54:14.435441Z",
    "created_by": {
        "id": "ajnN7eGutJZsRKjQrNuPkC",
        "email": "[email protected]",
        "first_name": "Jane",
        "last_name": "Roe",
        "avatar": "https://avatars.pandadoc-static.com/users/ajnN7eGutJZsRKjQrNuPkC/avatar.JPG"
    },
    "metadata": {},
    "tokens": [],
    "fields": [
        {
            "uuid": "d924a2b7-053c-489a-aa8a-ff2926ded8a0",
            "name": "Signature",
            "title": "",
            "placeholder": "Signature",
            "value": {},
            "assigned_to": {
                "id": "keLAiTCNJUsNo4BZJ8ap5k",
                "name": "Signer",
                "preassigned_person": null,
                "type": "role"
            }
        },
        {
            "uuid": "80222a28-8894-48fc-9e9d-f0f6305d5e9d",
            "name": "Date",
            "title": "",
            "placeholder": "Select date",
            "value": null,
            "assigned_to": {
                "id": "keLAiTCNJUsNo4BZJ8ap5k",
                "name": "Signer",
                "preassigned_person": null,
                "type": "role"
            },
            "merge_field": "Date"
        }
    ],
    "pricing": {},
    "tags": [],
    "roles": [
        {
            "id": "keLAiTCNJUsNo4BZJ8ap5k",
            "name": "Signer",
            "preassigned_person": null
        }
    ],
    "version": "2",
    "content_placeholders": []
}

Structure your Document details

Use the create document endpoint description to decide what content you want to pass to your document.

{  
    "name": "API Sample Document for PandaDoc Template",
    "template_uuid": "{{template_id}}",
    "recipients": [  
        {  
            "email": "[email protected]",
            "first_name": "Jane",
            "last_name": "Roe"
        }
    ],
    "content_placeholders": [
        {
            "block_id": "{{block_id}}",
            "content_library_items": [
                {
                    "id": "{{cli_id}}",
                    "pricing_tables": [
                        {
                            "name": "Pricing Table 1",
                            "options": {  
                                "currency": "USD",
                                "discount": {  
                                    "is_global": true,
                                    "type": "absolute",
                                    "name": "Discount",
                                    "value": 2.26
                                }
                            },
                            "sections": [
                                {
                                    "title": "Sample Section",
                                    "default": true,
                                    "rows": [
                                        {
                                            "options": {
                                                "optional": true,
                                                "optional_selected": true,
                                                "qty_editable": true
                                            },
                                            "data": {
                                                "name": "Placeholder Panda",
                                                "price": 10,
                                                "qty": 3
                                            }
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": "{{cli_id_2}}",
                    "recipients": [
                        {
                            "email": "[email protected]",
                            "first_name": "John",
                            "last_name": "Roe",
                            "role": "Signer"  
                        }
                    ],
                    "fields": {
                        "Date": {
                            "value": "2019-12-31T00:00:00.000Z"
                        }
                    }
                }
            ]
        }
    ]
}

Create the Document

Using your authentication token or API key, and the content-type application/json
POST https://api.pandadoc.com/public/v1/documents
The response will contain the document ID as the element “id”

{
    "id": "YbyruETM8yzgMMaaLQa2RP",
    "name": "API Sample Document from PandaDoc Template",
    "status": "document.uploaded",
    "date_created": "2021-08-20T07:04:15.654510Z",
    "date_modified": "2021-08-20T07:04:15.654510Z",
    "expiration_date": null,
    "version": null,
    "uuid": "YbyruETM8yzgMMaaLQa2RP"
}

Wait for the Document to enter a draft status

See Listening for changes in document status. If you are actively polling your document ID is “id” from the previous step.

Check Document content

As you can see a content placeholder from the template has been replaced with 2 content library items in the document (Sample pricing table and signature block).

Document with replaced content placeholder by content library itemsDocument with replaced content placeholder by content library items

Document with replaced content placeholder by content library items

Send the Document

Once you’ve determined that the document has entered “document.draft” status you can send it with a
POST https://api.pandadoc.com/public/v1/documents/{id}/send
Where {id} is the document ID from above. If you want you can include the optional parameters in your POST to set a subject line and body text

{
  "message": "Hello! This document was sent from the PandaDoc API.",
  "subject": "Please check this test API document from PandaDoc"
}

Do not set the “silent” parameter to “true” unless you don’t want an email to go out with the document link. For more information about why you might want to send silently see “Create a document and share it in real time”

Updated 2 months ago


Create from template with content placeholder


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.