Working with Text Blocks

Text blocks can be managed through the API using document creation and update operations. This guide shows you how to structure text block data with markdown formatting and how to create and update text blocks effectively.

Text Block Structure in JSON

Text blocks in API requests follow a simple structure:

  • Texts: A list containing multiple text block objects.
  • Name: The text block's identifier (must match the name defined in your template).
  • Data: The rich text content with markdown formatting support.

Example JSON Structure

{
    "texts": [
        {
            "name": "Legal Terms Section",
            "data": "## Terms of Service\nThis document outlines the terms and conditions.\n- **Acceptance:** By using our service, you agree to these terms.\n- **Changes:** We may update these terms at any time."
        }
    ]
}

Resulted Text Block

The above JSON will render as formatted content in your document:

Markdown Formatting in Text Blocks

You can include comprehensive Markdown formatting in text blocks. Here are examples covering the most commonly used Markdown features:

Example JSON with Markdown:

{
    "texts": [
        {
            "name": "Product Description",
            "data": "# Product Overview\n\n**Bold text** and *italic text* for emphasis.\n\n## Features\n- Feature 1\n- Feature 2\n- Feature 3\n\n### Numbered Benefits\n1. First benefit\n2. Second benefit\n3. Third benefit\n\n[Visit our website](https://pandadoc.com) for more information.\n\n> This is an important note in a blockquote. \nDocument create date: [Document.CreatedDate]"
        }
    ]
}

Resulted Text Block

The markdown will render as:

How to Create Documents with Text Blocks

To populate text blocks when creating a document from a template:

  1. Identify your text block names from your template
  2. Structure your request with the texts array
  3. Include markdown formatting in the data field as needed
POST /public/v1/documents
{
    "template_uuid": "your-template-id",
    "name": "Contract with Custom Terms",
    "texts": [
        {
            "name": "Introduction",
            "data": "# Welcome\nThank you for choosing our services."
        },
        {
            "name": "Terms Section", 
            "data": "## Payment Terms\n- Payment due within **30 days**\n- Late fees apply after grace period"
        }
    ]
}

How to Update Text Blocks in Existing Documents

To modify text blocks in an existing document:

  1. Get the document ID you want to update
  2. Prepare your text block updates with the same structure
  3. Send the PATCH request with only the blocks you want to change
PATCH /public/v1/documents/{document_id}
{
    "texts": [
        {
            "name": "Legal Terms Section",
            "data": "## Updated Terms\nThese terms have been revised as of today.\n\n*Please review carefully.*"
        }
    ]
}

How to Retrieve Text Block Names

To see which text blocks are available in a document:

GET /public/v1/documents/{document_id}/details

The Document Details response will include a texts array showing available text block names:

{
    "texts": [
        {
            "name": "Legal Terms Section"
        },
        {
            "name": "Product Description"
        }
    ]
}

Notes

  • Ensure that name exactly matches an existing text block name in your template when updating.
  • Markdown that includes [variable] will be interpreted as a PandaDoc variable, not as a link.
  • Text block styles (font, size, color) are preserved from the template - only content is updated.
  • Use \n for line breaks in JSON strings, or format your JSON with proper line breaks.
  • All standard Markdown formatting is supported: headers, emphasis, lists, links, blockquotes, and more.