Updating PDF and HTML template forms through REST API calls

Author: Yuri Gee

Date: 17 Nov 2025

2 minute read time

This article shows how REST API calls can be replayed directly from the browser, either as a fetch or curl request, to update the source of PDF and HTML templates when necessary. A similar approach was previously used for automatically cancelling BPM processes. Since this method leverages programmatic APIs and bypasses the UI editor, any content being updated should be carefully validated before saving, making it a technique best suited for experienced SugarCRM administrators.

Replicating the Request with an Updated Payload

Chrome and similar browsers make it easy to capture and replay REST API requests using the Developer Tools’ Network tab. These requests can then be wrapped as a fetch call for execution in the browser console or converted into a curl command for the command line.

The following images illustrate how the template source HTML is displayed in the Admin -> PDF Manager for Invoice/Quote templates, and how it is represented in the API request to index.php, where an additional <br /> line break tag is inserted via the command text.

Template view in UI Source Editor

The resulting Rest API payload

Additional considerations

When PDF HTML templates are resaved through the UI editor, its rules are applied, which may alter the content. The suggested mechanism is therefore effective in preserving those changes until the template is resaved again. I hope this helps streamline your platform administration, and welcome any feedback you may have.