How to Add an Image to a Document via API

Personalize the documents with dynamically added images.

Problem

You need to add a picture to your document, with a different image each time. The image is stored or generated in your CRM or other system.

Prerequisites

  • PandaDoc account and access to API
  • Valid API authentication credentials
  • Basic familiarity with REST API calls

Solution

You need to have an image block in the template, and then specify which image should be populated into this block.

Let's break down this process step-by-step.

Step 1: Add an Image Block to the Template

Open the template and drag-and-drop an Image block to the desired location. Open the properties to customize the Image Name. You'll use this name later to pass the image via the API.


Step 2: Include Image Parameter in Document Create or Update Request

Add the images field to the payload for Create or Update Document endpoints. Identify the image blocks by their respective names.

Read this guide if you need to learn how to create a document from a template via API.

"images":[
  {
    "name": "Image 1",
    "urls": [
      "https://media.istockphoto.com/id/175009379/pt/foto/panda-gigante-urso-comer-bambu.jpg?s=1024x1024&w=is&k=20&c=Fsq08jl0CFinrgUR_LLPW3iSK7-oyY37lV1r789XtM0="
    ]
  },
  {
    "name": "Image 2",
    "urls": [
      "https://media.istockphoto.com/id/175009379/pt/foto/panda-gigante-urso-comer-bambu.jpg?s=1024x1024&w=is&k=20&c=Fsq08jl0CFinrgUR_LLPW3iSK7-oyY37lV1r789XtM0="
    ]
  }
]

You can pass only one URL per image block, but you can populate multiple image blocks in a single request.

The URL must be publicly accessible. The image is then downloaded and stored on PandaDoc servers.


Step 3: Automate Image Mapping

You might use multiple templates with different numbers of image blocks.

To automate image mapping, use the Template Details and Document Details endpoints. Both return the list of available images and their names.

For mapping purposes, give your image blocks names based on the function of the image.


Verification

Create a document via API and open it in the Editor using its ID. Verify that the image is in place.


What’s Next

Learn how to manage Tables and other blocks via API