docusealco / docuseal

Open source DocuSign alternative. Create, fill, and sign digital documents ✍️
https://www.docuseal.co
GNU Affero General Public License v3.0
5.7k stars 378 forks source link

Update template with API #170

Closed eros404 closed 6 months ago

eros404 commented 6 months ago

Is there a way to add fields to an existing template with the API ?

omohokcoj commented 6 months ago

@eros404 it's possible to add fields using PUT /templates/{id} API but this API is not documented (only form builder UI component is using this API). https://github.com/docusealco/docuseal/blob/master/app/controllers/api/templates_controller.rb#L60

So it's possible to define fields via fields[] list - each field should contain uuid (you can generate it) and submitter_uuid (you can load submitters via /templates/{id}). Field areas should contain attachment_uuid (uuid of the document form the template.schema list).

It's possible to update the entire set of fields - adding/removing specific fields is not possible at the moment. The best way to use it would be if you load existing template fields via /templates/{id} and try to recreate a fields array for PUT request to update some new template.

Let me know if that's sufficient for your use case - alternatively you can use this API to upload a new template PDF and put fields with provided pixel values: https://www.docuseal.co/docs/api#create-a-template-from-existing-pdf

omohokcoj commented 6 months ago

@eros404 please reopen if you need any further assistance with the API. We're not planning to make this api public/documented since there is /template/pdf which can be used to create a new template with fields from an existing PDF file,