Folders help you organize your templates into a hierarchical structure. Besides managing them from the web app, you can use the DocuGenerate API to place templates in folders when creating or updating them, and to list the templates of a specific folder.
In the API, a folder is identified by its path, defined as an ordered array of folder names from root to leaf. For example, the Legal > Contracts folder has the path ["Legal", "Contracts"]. Each template returned by the API contains its path in the folder property, such as "folder": ["Legal", "Contracts"], and a template without a folder has an empty path "folder": [].
When creating a template, send one folder field for each level of the path. Any folders in the path that don’t exist are created automatically, so you don’t need to create them beforehand:
curl -X 'POST' \
'https://api.docugenerate.com/v1/template' \
-H 'Accept: application/json' \
-H 'Authorization: 491c000c5fad32ed7787005b0723ad55' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@Contract.docx' \
-F 'folder=Legal' \
-F 'folder=Contracts'
The path can also be sent as a JSON string, for example -F 'folder=["Legal", "Contracts"]', or with the folder[] field name used by some HTTP libraries. All three formats give the same result.
To move an existing template, send its new path when updating the template. For example, to move a template from its current Legal > Contracts folder to the Legal > Agreements folder:
curl -X 'PUT' \
'https://api.docugenerate.com/v1/template/UgnZ7HeRvVIEC9nDlSbC' \
-H 'Accept: application/json' \
-H 'Authorization: 491c000c5fad32ed7787005b0723ad55' \
-H 'Content-Type: multipart/form-data' \
-F 'folder=Legal' \
-F 'folder=Agreements'
To move a template out of any folder, send an empty path:
curl -X 'PUT' \
'https://api.docugenerate.com/v1/template/UgnZ7HeRvVIEC9nDlSbC' \
-H 'Accept: application/json' \
-H 'Authorization: 491c000c5fad32ed7787005b0723ad55' \
-H 'Content-Type: multipart/form-data' \
-F 'folder=[]'
To only list the templates of a folder when querying the templates, repeat the folder query parameter for each level of the path:
curl -X 'GET' \
'https://api.docugenerate.com/v1/template?folder=Legal&folder=Contracts' \
-H 'Accept: application/json' \
-H 'Authorization: 491c000c5fad32ed7787005b0723ad55'
As when filtering templates in the web app, only the templates placed directly in that folder are returned. Templates in its subfolders aren’t included, so ?folder=Legal returns the templates in the Legal folder, but not the ones in the Legal > Contracts subfolder.
The API manages the folder of each template, but it doesn’t provide endpoints for the folders themselves. To rename or move a folder along with all its templates, or to delete a folder, use the web app.