Reference
Document templates
GET/api/v1/document-templatesList document templates
Per document type (quote, order_confirmation, service_spec, terms, dpa, service_report, invoice, sepa_mandate, commission_statement, credit_note) its variants (layouts): which is the default, which project types are routed to it, and its active version. New documents use the variant their project type is routed to, otherwise the default. Like opening the page, the first look at a document type stores its built-in layout as version 1 of the default variant. get_document_template reads a version's definition. catalog.manage only.scope catalog
Query
| document_type | one of quote, order_confirmation, service_spec, terms, dpa, service_report, invoice, sepa_mandate, commission_statement, credit_noteOnly this document type. Default: all. |
Response 200
| document_type | string |
| label | string |
| variants[] | object[] |
| variants[].id | string |
| variants[].document_type | string |
| variants[].key | string |
| variants[].name | string |
| variants[].is_default | boolean |
| variants[].language | string | null |
| variants[].project_types[] | object[] |
| variants[].project_types[].id | string |
| variants[].project_types[].key | string |
| variants[].project_types[].name | string |
| variants[].active_version | object | null |
| variants[].active_version.template | string |
| variants[].active_version.version | integer |
| variants[].active_version.name | string |
| variants[].active_version.created_at | string |
| variants[].active_version.created_by | string | null |
| variants[].version_count | integer |
| variants[].latest_version | integer | null |
| variants[].url | string |
Schema
{
"type": "array",
"items": {
"type": "object",
"properties": {
"document_type": {
"type": "string"
},
"label": {
"type": "string"
},
"variants": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"document_type": {
"type": "string"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
},
"is_default": {
"type": "boolean"
},
"language": {
"type": [
"string",
"null"
]
},
"project_types": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"key",
"name"
],
"additionalProperties": false
}
},
"active_version": {
"anyOf": [
{
"type": "object",
"properties": {
"template": {
"type": "string"
},
"version": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"name": {
"type": "string"
},
"created_at": {
"type": "string"
},
"created_by": {
"type": [
"string",
"null"
]
}
},
"required": [
"template",
"version",
"name",
"created_at",
"created_by"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"version_count": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"latest_version": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"url": {
"type": "string"
}
},
"required": [
"id",
"document_type",
"key",
"name",
"is_default",
"language",
"project_types",
"active_version",
"version_count",
"latest_version",
"url"
],
"additionalProperties": false
}
}
},
"required": [
"document_type",
"label",
"variants"
],
"additionalProperties": false
}
}Refusals are problems with a code — see Errors.
POST/api/v1/document-templatesSave document template
Saves a definition as the variant's next version, as the editor does: versions are never overwritten. By default the new version is activated at once, as the editor's save does; with activate: false it is stored as a draft that activate_document_template can switch on later. Start from get_document_template's definition and send the whole tree back changed -- blocks and pageFooter must both be lists. The definition is normalised like the editor's: unknown block kinds and unreadable properties are dropped (the answer counts dropped blocks), blocks without an id get one. A change applies to documents created from then on; quotes, order confirmations, service reports and invoices already sent or issued keep the version they were frozen with. catalog.manage only.scope catalog
Body (JSON)
| variantrequired | stringThe variant's id, from list_document_templates. |
| namerequired | stringWhat changed, in a few words; shown in the version history. Empty: "Fassung <n>". |
| definitionrequired | objectThe whole definition: { page, theme, blocks, pageFooter }, as get_document_template returns it. |
| activate | booleanDefault: true. false stores the version without using it yet. |
Response 200
| version | object |
| version.template | string |
| version.version | integer |
| version.name | string |
| version.is_active | boolean |
| dropped_blocksoptional | integer |
| noteoptional | string |
| variant | object |
| variant.id | string |
| variant.document_type | string |
| variant.key | string |
| variant.name | string |
| variant.is_default | boolean |
| variant.language | string | null |
| variant.project_types[] | object[] |
| variant.project_types[].id | string |
| variant.project_types[].key | string |
| variant.project_types[].name | string |
| variant.active_version | object | null |
| variant.active_version.template | string |
| variant.active_version.version | integer |
| variant.active_version.name | string |
| variant.active_version.created_at | string |
| variant.active_version.created_by | string | null |
| variant.version_count | integer |
| variant.latest_version | integer | null |
| variant.url | string |
Schema
{
"type": "object",
"properties": {
"version": {
"type": "object",
"properties": {
"template": {
"type": "string"
},
"version": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"name": {
"type": "string"
},
"is_active": {
"type": "boolean"
}
},
"required": [
"template",
"version",
"name",
"is_active"
],
"additionalProperties": false
},
"dropped_blocks": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"note": {
"type": "string"
},
"variant": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"document_type": {
"type": "string"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
},
"is_default": {
"type": "boolean"
},
"language": {
"type": [
"string",
"null"
]
},
"project_types": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"key",
"name"
],
"additionalProperties": false
}
},
"active_version": {
"anyOf": [
{
"type": "object",
"properties": {
"template": {
"type": "string"
},
"version": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"name": {
"type": "string"
},
"created_at": {
"type": "string"
},
"created_by": {
"type": [
"string",
"null"
]
}
},
"required": [
"template",
"version",
"name",
"created_at",
"created_by"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"version_count": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"latest_version": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"url": {
"type": "string"
}
},
"required": [
"id",
"document_type",
"key",
"name",
"is_default",
"language",
"project_types",
"active_version",
"version_count",
"latest_version",
"url"
],
"additionalProperties": false
}
},
"required": [
"version",
"variant"
],
"additionalProperties": false
}Refusals are problems with a code — see Errors.
GET/api/v1/document-templates/{id}Get document template
One version of a variant with its definition exactly as save_document_template takes it, plus the variant's version history and the fields a text block may bind to. Default: the active version. The definition is { page: { marginTop, marginRight, marginBottom, marginLeft, footerTop } in points, theme, blocks: [...], pageFooter: [...] }. Each block has an id, a kind (stack, row, frame, text, divider, spacer, image, wordmark, pageBreak, repeat, table), optional style, label, when (a condition), keepTogether, minPresenceAhead; stack/row/frame/repeat have children, a table has columns with cell blocks. A text block's content may hold {{field.path}} bindings and **bold**. catalog.manage only.scope catalog
Path
| idrequired | stringThe variant's id, from list_document_templates. |
Query
| version | integerThe version number. Default: the active one. |
Response 200
| variant | object |
| variant.id | string |
| variant.document_type | string |
| variant.key | string |
| variant.name | string |
| variant.is_default | boolean |
| variant.language | string | null |
| variant.project_types[] | object[] |
| variant.project_types[].id | string |
| variant.project_types[].key | string |
| variant.project_types[].name | string |
| variant.active_version | object | null |
| variant.active_version.template | string |
| variant.active_version.version | integer |
| variant.active_version.name | string |
| variant.active_version.created_at | string |
| variant.active_version.created_by | string | null |
| variant.version_count | integer |
| variant.latest_version | integer | null |
| variant.url | string |
| version | object |
| version.template | string |
| version.version | integer |
| version.name | string |
| version.is_active | boolean |
| version.created_at | string |
| version.created_by | string | null |
| version.documents_sent_with_it | integer |
| definition | object |
| versions[] | object[] |
| versions[].template | string |
| versions[].version | integer |
| versions[].name | string |
| versions[].is_active | boolean |
| versions[].created_at | string |
| versions[].documents_sent_with_it | integer |
| bindable_fields[] | object[] |
| bindable_fields[].path | string |
| bindable_fields[].label | string |
| bindable_fields[].kind | string |
| bindable_fields[].scopeoptional | string |
| bindable_fields[].formatteroptional | string |
Schema
{
"type": "object",
"properties": {
"variant": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"document_type": {
"type": "string"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
},
"is_default": {
"type": "boolean"
},
"language": {
"type": [
"string",
"null"
]
},
"project_types": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"key",
"name"
],
"additionalProperties": false
}
},
"active_version": {
"anyOf": [
{
"type": "object",
"properties": {
"template": {
"type": "string"
},
"version": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"name": {
"type": "string"
},
"created_at": {
"type": "string"
},
"created_by": {
"type": [
"string",
"null"
]
}
},
"required": [
"template",
"version",
"name",
"created_at",
"created_by"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"version_count": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"latest_version": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"url": {
"type": "string"
}
},
"required": [
"id",
"document_type",
"key",
"name",
"is_default",
"language",
"project_types",
"active_version",
"version_count",
"latest_version",
"url"
],
"additionalProperties": false
},
"version": {
"type": "object",
"properties": {
"template": {
"type": "string"
},
"version": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"name": {
"type": "string"
},
"is_active": {
"type": "boolean"
},
"created_at": {
"type": "string"
},
"created_by": {
"type": [
"string",
"null"
]
},
"documents_sent_with_it": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
},
"required": [
"template",
"version",
"name",
"is_active",
"created_at",
"created_by",
"documents_sent_with_it"
],
"additionalProperties": false
},
"definition": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {}
},
"versions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"template": {
"type": "string"
},
"version": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"name": {
"type": "string"
},
"is_active": {
"type": "boolean"
},
"created_at": {
"type": "string"
},
"documents_sent_with_it": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
},
"required": [
"template",
"version",
"name",
"is_active",
"created_at",
"documents_sent_with_it"
],
"additionalProperties": false
}
},
"bindable_fields": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": {
"type": "string"
},
"label": {
"type": "string"
},
"kind": {
"type": "string"
},
"scope": {
"type": "string"
},
"formatter": {
"type": "string"
}
},
"required": [
"path",
"label",
"kind"
],
"additionalProperties": false
}
}
},
"required": [
"variant",
"version",
"definition",
"versions",
"bindable_fields"
],
"additionalProperties": false
}Refusals are problems with a code — see Errors.
POST/api/v1/document-templates/{id}/activateActivate document template
Makes an existing version the one new documents of its variant are rendered with -- an earlier one to go back, or a draft saved with activate: false. The version's template id comes from get_document_template. A change applies to documents created from then on; quotes, order confirmations, service reports and invoices already sent or issued keep the version they were frozen with. catalog.manage only.scope catalog
Path
| idrequired | stringThe version's template id, from get_document_template. |
Response 200
| activated_version | integer |
| variant | object |
| variant.id | string |
| variant.document_type | string |
| variant.key | string |
| variant.name | string |
| variant.is_default | boolean |
| variant.language | string | null |
| variant.project_types[] | object[] |
| variant.project_types[].id | string |
| variant.project_types[].key | string |
| variant.project_types[].name | string |
| variant.active_version | object | null |
| variant.active_version.template | string |
| variant.active_version.version | integer |
| variant.active_version.name | string |
| variant.active_version.created_at | string |
| variant.active_version.created_by | string | null |
| variant.version_count | integer |
| variant.latest_version | integer | null |
| variant.url | string |
Schema
{
"type": "object",
"properties": {
"activated_version": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"variant": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"document_type": {
"type": "string"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
},
"is_default": {
"type": "boolean"
},
"language": {
"type": [
"string",
"null"
]
},
"project_types": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"key",
"name"
],
"additionalProperties": false
}
},
"active_version": {
"anyOf": [
{
"type": "object",
"properties": {
"template": {
"type": "string"
},
"version": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"name": {
"type": "string"
},
"created_at": {
"type": "string"
},
"created_by": {
"type": [
"string",
"null"
]
}
},
"required": [
"template",
"version",
"name",
"created_at",
"created_by"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"version_count": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"latest_version": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"url": {
"type": "string"
}
},
"required": [
"id",
"document_type",
"key",
"name",
"is_default",
"language",
"project_types",
"active_version",
"version_count",
"latest_version",
"url"
],
"additionalProperties": false
}
},
"required": [
"activated_version",
"variant"
],
"additionalProperties": false
}Refusals are problems with a code — see Errors.