1.
Create the base template (POST /templates): registers name, processor, scope, and description, and returns a temporary signed URL for uploading the .docx file.
2.
Upload the .docx file to the signed URL returned in the previous step.
3.
Define the fields (PUT /templates/{id}/fields): the fields sent in step 1 are not persisted as the final configuration — this call is always required for the fields to actually take effect.
4.
Configure conditional rules, if needed (PUT /templates/{id}/fields/rules) — optional, used to show, hide, or make fields required/optional based on the value of other fields.
5.
Activate the template (PUT /templates/{id}/activate): final step, required for the template to become available for document generation. It also needs to be repeated whenever the fields or the conditional rules are changed after the initial activation, since both operations deactivate the template as a side effect.
Field from the flow's initial form: fixed path of start-form and reference equal to the field's identifier.
Field from a phase: path in the format phase-field.<phase-identifier> and reference in the format <phase-identifier>:<field-identifier>.
Field from the technical opinion: fixed path of opinion-field and reference equal to the field's identifier.
Native fields (client basic data, approvals, credit engine, among others): only a fixed path (for example basic-data.name or credit-engine.score), with no reference.
Each phase allows at most one automatic document generation configuration. Creating a new one when one already exists returns an error stating that a configuration already exists for that flow and phase (the message includes the identifier of the existing configuration). To edit an existing configuration, the recommended path is to remove the current one and create a new one — although the direct update call is also available for the case of just repointing the linked template.
Uploading a new file for an existing template does not update it in place — the result is a new template, with a new identifier. The original remains intact (cards that already generated documents from it keep referencing the old identifier), but any automatic document generation configuration, conversation configuration, or trigger that pointed to the old identifier needs to be manually updated.
Defining a template's fields or conditional rules deactivates the template as a side effect — it always needs to be activated again afterward.
If a field references a section (section) that was not declared when the template was created, the field definition call fails with an error stating the section was not found.
The fields payload only accepts a specific set of properties (key, title, type, path, reference, required, options, section, uiComponent, children, rules) — properties such as active, editable, category, index, id, createdAt, updatedAt, and sectionKey are rejected.
A template is always specific to one flow: reusing the identifier of a template created in another flow returns a resource-not-found error.
After a template is created, it may take a few moments before it appears in the listing — indexing is asynchronous. Subsequent calls that depend on the newly created template may fail during that window; we recommend retrying after a few seconds.
Removing a template is irreversible: cards that already generated documents from it end up with a broken download link.
When generating the document (POST .../generate), the fields in clients[] and generalSections[] never include the id property — they use the key (key) declared in the template, prefixed by the parent group when applicable (for example fiadores.nome).