How to Populate and Update Tables
Populate and update table content in PandaDoc documents via the API, including markdown formatting and cell merging.
Problem
You need to populate or update table content in PandaDoc documents via the API -- for example, injecting product data, specifications, or dynamic rows from an external system into a template table.
Prerequisites
- A PandaDoc template with at least one named table
- A PandaDoc API key or OAuth token
- Familiarity with the Create Document from Template or Update Document endpoints
Solution
Step 1: Identify the table structure
Tables follow a hierarchical JSON structure: tables → name + data → sections → header + rows.
Use the Document Details endpoint to check available table names. The name must exactly match an existing table in your template.
Step 2: Populate a table during document creation
Include a tables array in your create document request. Each table has a name and data object containing sections with header and rows:
{
"tables": [
{
"name": "Table 1",
"data": {
"sections": [
{
"header": [
{"text": "Brand"},
{"text": "Category"},
{"text": "Model"}
],
"rows": [
[
{"text": "BMW"},
{"text": "Sedan"},
{"text": "5 Series"}
],
[
{"text": "Toyota"},
{"text": "SUV"},
{"text": "RAV4"}
]
]
}
]
}
}
]
}
Extra columns in the payload are ignored, and updates will not change the table's width. Table and cell styles (font, background) are preserved from the template -- the API updates only cell content.
Step 3: Use markdown in cells
Cell text supports markdown formatting: bold (**), italic (*), links ([text](url)), lists, and numbered lists. Use \n for line breaks.
"rows": [
[
{"text": "Features"},
{"text": "- Item 1\n- Item 2\n- **Item 3**"}
],
[
{"text": "Link"},
{"text": "[PandaDoc](https://app.pandadoc.com/)"}
]
]
Text using[variable]syntax will be interpreted as a PandaDoc variable, not as a markdown link.
Step 4: Merge cells with col_span and row_span (optional)
col_span and row_span (optional)To merge cells horizontally or vertically, add col_span and row_span to cell objects. Set merged-over cells to col_span: 0 and row_span: 0:
"header": [
{
"text": "Attribute",
"col_span": 2,
"row_span": 1
},
{
"text": "",
"col_span": 0,
"row_span": 0
},
{
"text": "Notes",
"col_span": 1,
"row_span": 1
}
]
Step 5: Update tables in an existing document
To modify tables after creation, send a PATCH request with only the tables you want to change. Sections and rows should follow the existing structure to maintain consistency:
PATCH /public/v1/documents/{document_id}
{
"tables": [
{
"name": "Table 1",
"data": {
"sections": [
{
"header": [
{"text": "Brand"},
{"text": "Category"},
{"text": "Model"}
],
"rows": [
[
{"text": "Updated Brand"},
{"text": "Updated Category"},
{"text": "Updated Model"}
]
]
}
]
}
}
]
}Verification
- Confirm the document reaches
document.draftstatus after creation or update. - Open the document in the PandaDoc web app to verify table content, formatting, and merged cells render as expected.
- Use the Document Details endpoint to check the table structure.
Related
- Working with Text Blocks -- managing text block content via API
- Working with Pricing Tables -- pricing-specific table operations
- Update Quotes -- updating quote data via API
- Create a Document from Template -- full template-based document creation
Updated about 1 hour ago
