Using Dynamic Templates

🚧

To modify templates on a per-customer basis, we recommend using template overrides.

Overview

Dynamic templates allow a template to be programmatically created and applied to an importer via our external API.

Dynamic templates are often used to...

  • Surface slightly different template variations based on a specific user
  • Allow the user to configure their own templates outside of OneSchema (i.e. select which columns they plan to upload or to create new data types within your application)
  • Programmatically edit templates

Using Dynamic Templates

OneSchema templates are serializable as JSON. There are four endpoints related to templates:


Template keys

A template key is an identifier used to tell the OneSchema embedded importer which template to apply. Each template has a defined template key which must be unique for a given OneSchema dashboard.

A template key must be specified in the embed code prior to launching the importer. Once an embedded session loads, changes made to its applied template will not impact the session.


Sample workflows

Updating a template

  1. GET the existing template
  2. DELETE the existing template
  3. POST the updated template (suggested: use the same template key as previous template)

Creating per-user templates

  1. Optional: GET an existing base-template to be modified
  2. POST a new template (suggested: use a unique datetime-stamped template key)
  3. Programmatically set the template key in the embed code
  4. On import success, DELETE the custom template

OR

  1. Periodically GET a list of all templates and DELETE those which are no longer needed