Document templates

Create a document template

Stores a draft. It renders only once published, or as a preview. At most 500 templates per account, archived ones included.

post/v1/document-templates

Request

  • Base URL: https://api.ironfang.com/render
  • URL: https://api.ironfang.com/render/v1/document-templates
  • Auth: HTTP bearer

Request body

namestring required
sample_dataobject

Data for previews and validation when a request gives none. Keep it synthetic.

schemaobject

The data the template needs, as a strict subset of JSON Schema: type (object, array, string, number, integer, boolean), properties, required, items, maxItems, maxLength, enum, nullable, default and description; any other keyword is refused. The top level is an object. Data is checked against it before anything renders. A required field is never defaulted; an optional one missing from the data gets its default, or null, so {{if .notes}} is a test rather than an error. Fields declared integer are whole numbers, so {{if gt .days 30}} works.

sourcestring required

HTML in Go's html/template syntax: {{.customer.name}}, {{range .lines}}...{{end}}, {{if .notes}}...{{end}}. Values are escaped for where they land - text, attributes, URLs (a javascript: URL becomes #ZgotmplZ), CSS and scripts. Functions: the html/template builtins (and, or, not, eq, ne, lt, le, gt, ge, len, index, slice), fixed N value (a number to N decimal places), mul, add, upper, lower and printf (widths at most 64). {{define}}, {{template}} and {{block}} are not supported. A field the template reads that the data lacks is an error, never an empty string: declare optional fields in the schema. Rendering is bounded: 100,000 loop iterations, 8 MiB of HTML and 2 s. Saving refuses a source that does not compile.

Response

Created.

namestring required
sample_dataobject

Data for previews and validation when a request gives none. Keep it synthetic.

schemaobject

The data the template needs, as a strict subset of JSON Schema: type (object, array, string, number, integer, boolean), properties, required, items, maxItems, maxLength, enum, nullable, default and description; any other keyword is refused. The top level is an object. Data is checked against it before anything renders. A required field is never defaulted; an optional one missing from the data gets its default, or null, so {{if .notes}} is a test rather than an error. Fields declared integer are whole numbers, so {{if gt .days 30}} works.

sourcestring required

HTML in Go's html/template syntax: {{.customer.name}}, {{range .lines}}...{{end}}, {{if .notes}}...{{end}}. Values are escaped for where they land - text, attributes, URLs (a javascript: URL becomes #ZgotmplZ), CSS and scripts. Functions: the html/template builtins (and, or, not, eq, ne, lt, le, gt, ge, len, index, slice), fixed N value (a number to N decimal places), mul, add, upper, lower and printf (widths at most 64). {{define}}, {{template}} and {{block}} are not supported. A field the template reads that the data lacks is an error, never an empty string: declare optional fields in the schema. Rendering is bounded: 100,000 loop iterations, 8 MiB of HTML and 2 s. Saving refuses a source that does not compile.

archived_atstring date-time

Set once archived. Archived templates render only by revision number.

created_atstring date-time
idstring uuid
published_revisioninteger nullable

The revision unversioned renders use; null until first published.

updated_atstring date-time

Changes

No recorded changes to this operation across all 1 revision of this API.