Document Creation Strategies

When creating documents within Joyfill there are two strategies you can use: Raw Document and Document from Template.

Raw Document

With this method you pass the raw files and fields on the body param. These params will be used for creating the document.

Can the template body param be used with this strategy?

Yes. The template will only be used as the source reference to the template you specified. The custom files and fields will be used for the actual document creation.

Why would anyone pass in raw files and fields with the template param?

This is usually done when the document from template creation cycle is managed on the client side. This strategy allows the new document with all the modifications, updates, etc. and the reference to the original template to all be created with a single request.

Example Body

{
  "name": "New Document",
  "group": "group_id",
  "files": [JoyDocFileObject, ...],
  "fields": [JoyDocFieldObject, ...],
  ...
}

Document From Template

With this method you can leave the files and fields params empty and simply pass the template param on the body and the Joyfill API will use the template to generate a new document with files and fields from the template.

Example Body

{
  "name": "New Document",
  "group": "group_id",
  "template": "temp_identifier",
  ...
}
Language