> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://support.pdfgeneratorapi.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Managing Template Versions

Every time you save a template, a new version is automatically created. The version history lets you review, restore, export, delete versions and with **Advanced Template Management** you can also control which version is used in production.

|| Advanced Template Management is available from the Basic plan and higher. For plan details and feature availability, see the [pricing page](https://pdfgeneratorapi.com/pricing).
---

### Viewing version history

1. Go to the **Templates** tab and find your template.
2. On the right side of the template, click the **three-dot menu (⋮)** and select **Versions**.

![Versions Page](https://storage.crisp.chat/users/helpdesk/website/-/1/1/e/0/11e0e518fc48ce00/image_1hzhps0.png)

The version history shows each version's ID, name, whether it is the production version, who saved it, and when. Using the **three-dot menu (⋮)** next to a version you can **Export**, **Restore as new**, **Promote to production**, or **Delete** it.

|| The **Promote to production** action is only available when **Manual Promotion to Production** is enabled. See [How the production version works](#6-how-the-production-version-works) below for details.

![Template Version History](https://storage.crisp.chat/users/helpdesk/website/-/1/1/e/0/11e0e518fc48ce00/image_osntxh.png)

### Restoring a previous version

If you want to go back to an earlier version without touching the current production version:

1. Open the template's **Versions** page.
2. Find the version you want to restore, click the **three-dot menu (⋮)** next to it, and choose **Restore as new**.
 
This creates a **new template** based on the selected version. The current production version stays intact, so you can make changes to the restored copy without disrupting your live documents.

### Exporting and deleting versions

You can also export or delete versions from the version history. Exporting lets you back up previous versions and the exported file can be uploaded into another workspace via the editor (**File → Import**). Deleting old versions keeps your template library clean.

|| The production version cannot be deleted.
---

### Advanced Template Management

###### How the production version works

The **production** version is the version used when you open the editor or generate a document via the API. By default, for all accounts regardless of plan, the latest template version is automatically promoted to production whenever the template is saved.

Accounts with **Advanced Template Management** (available starting with the Basic plan) can change the **Template Promotion Strategy** under **Settings → General Settings** and choose between:

* **Automatic Promotion to Production (default):** the latest template version is automatically promoted to production upon saving.
* **Manual Promotion to Production:** saving a template creates a new version, but the production version only changes when you manually promote one. This lets you safely edit and test new iterations of a template without affecting the live documents generated via the API.

![Template Promotion Strategy](https://storage.crisp.chat/users/helpdesk/website/-/1/1/e/0/11e0e518fc48ce00/image_a5zut5.png)

**Manual promotion requires:**

●       A plan with **Advanced Template Management** (Basic plan and above, see [pricing](https://pdfgeneratorapi.com/pricing)).
●       The [**Template Management permission**](https://support.pdfgeneratorapi.com/en/article/roles-permissions-for-master-user-1dy7xze/) on your user.
●       The **Template Promotion Strategy** set to **Manual Promotion to Production**.

###### Promoting a version to production

If manual promotion is enabled, you can promote a specific version to production:

1. Open the template's **Versions** page.
2. Find the version you want to make live, click the **three-dot menu (⋮)** next to it, and choose **Promote to production**.

![Promoting a Version to Production](https://storage.crisp.chat/users/helpdesk/website/-/1/1/e/0/11e0e518fc48ce00/image_1pyznai.png)

The **Is Production** column updates to show which version is live.

|| Only one version can be production at a time. Promoting a version replaces the current production version immediately.
---

### Managing versions via the API

Template versions can be fully managed programmatically with the [Template Versions endpoints](https://docs.pdfgeneratorapi.com/v4#tag/Template-Versions):

| Endpoint | Description |
| ---- |
| GET/templates/{templateId}/versions | Returns a paginated list of template versions. Each version includes its ID, checksum, the user who saved it, and an is_production flag. |
| GET/templates/{templateId}/versions/{templateVersion} | Returns the template definition of the specified version. |
| PUT/templates/{templateId}/versions/{templateVersion}/promote | Promotes the specified version to production. Only one version can be production at a time. |
| DELETE/templates/{templateId}/versions/{templateVersion} | Deletes the specified version. Production versions cannot be deleted. |

You can also generate a document from a specific historical version by passing the `version_id` parameter in the [Generate Document](https://docs.pdfgeneratorapi.com/v4#tag/Documents/operation/generateDocument) request. If `version_id`
 is omitted, the designated production version is used: 

```
{
  "template": {
    "id": 123456,
    "version_id": 12,
    "data": { "name": "John Doe" }
  },
  "format": "pdf",
  "output": "url"
}
```

This is useful for testing a draft version through the API before promoting it to production.
---
### Related articles you may find helpful

* [Batch Document Generation: How to generate a document using multiple templates](/en/article/batch-document-generation-how-to-generate-a-document-using-multiple-templates-1e75kbb/)
* [How to Integrate with Make](/en/article/how-to-integrate-with-make-18x0r2x/)
* [How to Make a Copy of Your Template?](/en/article/how-to-make-a-copy-of-your-template-5fi1ud/)