How to Use Variables in Document Titles
Dynamically populate document names using variables and tokens when creating documents via the PandaDoc API.
Problem
You want the document name to include dynamic values (company name, date, deal ID, etc.) that are populated automatically when the document is created via API, so each document gets a unique, meaningful title.
Prerequisites
- A PandaDoc template with a variable set in the template name (configured in the UI)
- A PandaDoc API key or OAuth token
- Familiarity with the Create Document endpoint
Solution
Step 1: Set variables in the template name
In the PandaDoc web app, edit your template's name to include a variable in square brackets, for example: Proposal for [Company.Name].
Step 2: Pass the variable values in the API request
In your create document request, set the name parameter with the variable placeholder and enable detect_title_variables:
{
"name": "Proposal for [Company.Name]",
"detect_title_variables": true,
"template_uuid": "RWVafhmMWniwA5FWnEQVvg",
"tokens": [
{
"name": "Company.Name",
"value": "Panda"
}
]
}The resulting document will be named "Proposal for Panda".
Title variables only resolve if the variable is either defined in the template UI or passed in thetokenssection of the request. Otherwise, the bracketed text appears as plain text in the document name.
Verification
- After creating the document, confirm it reaches
document.draftstatus. - Check the document name in the API response or in the PandaDoc web app to verify the variable was resolved.
Related
- How to Create a Document from a Template — full template-based creation flow
- Choosing between Variables and Fields — when to use tokens vs. fields
- Create Document API reference — full endpoint parameters
Updated about 12 hours ago