# Templates

The templates system is used manage templates and render content from existing templates. Templates can be used, for
instance, when sending emails and text messages. Custom branding and dynamic fields can be added into
templates.

 - [Management](https://docs.peachfinance.com/api-docs/api-public/templates/management.md): ## Management The templates system consists of two main components: Template Descriptors and Template Versions (also sometimes simply referred to as "templates"). A Template Descriptor is a configurat
 - [Content](https://docs.peachfinance.com/api-docs/api-public/templates/content.md): ## Content
 - [Syntax](https://docs.peachfinance.com/api-docs/api-public/templates/syntax.md): ### Syntax Peach uses <a href="https://jinja.palletsprojects.com/">Jinja templating</a>. Therefore all templates use Jinja template syntax, and *must be a valid Jinja template to render*.
 - [Rendering Context](https://docs.peachfinance.com/api-docs/api-public/templates/rendering-context.md): ### Rendering Context When a template is rendered, context variables are passed into the template. If a template looks like: ``` Hello {{foo}}, your loan is due on {{bar}}. ``` then the context varia
 - [GET /communicator/templatedescriptors](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.list_template_descriptors.md)
 - [POST /communicator/templatedescriptors](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.create_template_descriptor.md)
 - [DELETE /communicator/templatedescriptors/{descriptorId}](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.delete_template_descriptor.md)
 - [GET /communicator/templatedescriptors/{descriptorId}](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.get_template_descriptor.md)
 - [PUT /communicator/templatedescriptors/{descriptorId}](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.update_template_descriptor.md)
 - [GET /communicator/templatedescriptors/{descriptorId}/templates](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.list_template_versions_by_descriptor.md): List all template versions for the given template descriptor.
 - [GET /communicator/templates](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.list_template_versions.md): List all template versions. Deprecated in favor of `/v2/communicator/templates`. This dumps all template versions (regardless of active status) without paging.
 - [POST /communicator/templates](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.create_template_version.md): Create a new template versions. By default the new version will not be active until it is activated with <a href="/api-docs/api-public/templates/peach.communicator.handlers.activate_template_version">
 - [GET /communicator/templates/export](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.export_templates.md): Export all template descriptors and template versions for a company. The export is in JSON format. It can be used with the import endpoint to restore templates.
 - [POST /communicator/templates/import](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.import_templates.md): Import exported template descriptors and template versions for a company. The exported data should come from the `/communicator/templates/export` endpoint. The import will create new template descript
 - [GET /communicator/templates/{templateVersionId}](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.get_template_version.md)
 - [PUT /communicator/templates/{templateVersionId}](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.update_template_version.md)
 - [PUT /communicator/templates/{templateVersionId}/activate](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.activate_template_version.md): Set's the given template version as active. A template descriptor can have exactly one "active" version. The active template version is what's used to generate the content of the messages.
 - [POST /communicator/templates/{templateVersionId}/preview](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.preview_template_version.md): Render the template contents of the given Template Version using the given context. The three contents are returned in a single JSON response, they are `contentHtml`, `contentText` and `subjectLine`.
 - [POST /communicator/templates/{templateVersionId}/render](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.render_template_version.md): Render a file (`text`, `html` or `pdf`) from this Template Version and download it. Only the content matching the `fmt` query parameter is returned in the file. The rendered template file is then down
 - [GET /communicator/templates/{templateVersionId}/vars](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.get_template_vars.md): List all context variables used in the given template version. If a template looks like: ``` Hello {{name}}, Your loan {{loanName}} is due on {{dueDate}}. Thanks, {{companyName}} {{SOME_MACRO()}}
 - [GET /v2/communicator/templates](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.list_template_versions_modern.md): List all Templates Versions for all Template Descriptors.
 - [DELETE /communicator/templates/{templateVersionId}](https://docs.peachfinance.com/api-docs/api-public/templates/peach.communicator.handlers.delete_template_version.md): Deleting template versions is not allowed. Template versions are historical records. This endpoint is retained for backwards compatibility but responds with a 400 error.
