Zum Inhalt

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_typeone 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_typestring
labelstring
variants[]object[]
variants[].idstring
variants[].document_typestring
variants[].keystring
variants[].namestring
variants[].is_defaultboolean
variants[].languagestring | null
variants[].project_types[]object[]
variants[].project_types[].idstring
variants[].project_types[].keystring
variants[].project_types[].namestring
variants[].active_versionobject | null
variants[].active_version.templatestring
variants[].active_version.versioninteger
variants[].active_version.namestring
variants[].active_version.created_atstring
variants[].active_version.created_bystring | null
variants[].version_countinteger
variants[].latest_versioninteger | null
variants[].urlstring
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)

variantrequiredstringThe variant's id, from list_document_templates.
namerequiredstringWhat changed, in a few words; shown in the version history. Empty: "Fassung <n>".
definitionrequiredobjectThe whole definition: { page, theme, blocks, pageFooter }, as get_document_template returns it.
activatebooleanDefault: true. false stores the version without using it yet.

Response 200

versionobject
version.templatestring
version.versioninteger
version.namestring
version.is_activeboolean
dropped_blocksoptionalinteger
noteoptionalstring
variantobject
variant.idstring
variant.document_typestring
variant.keystring
variant.namestring
variant.is_defaultboolean
variant.languagestring | null
variant.project_types[]object[]
variant.project_types[].idstring
variant.project_types[].keystring
variant.project_types[].namestring
variant.active_versionobject | null
variant.active_version.templatestring
variant.active_version.versioninteger
variant.active_version.namestring
variant.active_version.created_atstring
variant.active_version.created_bystring | null
variant.version_countinteger
variant.latest_versioninteger | null
variant.urlstring
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

idrequiredstringThe variant's id, from list_document_templates.

Query

versionintegerThe version number. Default: the active one.

Response 200

variantobject
variant.idstring
variant.document_typestring
variant.keystring
variant.namestring
variant.is_defaultboolean
variant.languagestring | null
variant.project_types[]object[]
variant.project_types[].idstring
variant.project_types[].keystring
variant.project_types[].namestring
variant.active_versionobject | null
variant.active_version.templatestring
variant.active_version.versioninteger
variant.active_version.namestring
variant.active_version.created_atstring
variant.active_version.created_bystring | null
variant.version_countinteger
variant.latest_versioninteger | null
variant.urlstring
versionobject
version.templatestring
version.versioninteger
version.namestring
version.is_activeboolean
version.created_atstring
version.created_bystring | null
version.documents_sent_with_itinteger
definitionobject
versions[]object[]
versions[].templatestring
versions[].versioninteger
versions[].namestring
versions[].is_activeboolean
versions[].created_atstring
versions[].documents_sent_with_itinteger
bindable_fields[]object[]
bindable_fields[].pathstring
bindable_fields[].labelstring
bindable_fields[].kindstring
bindable_fields[].scopeoptionalstring
bindable_fields[].formatteroptionalstring
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

idrequiredstringThe version's template id, from get_document_template.

Response 200

activated_versioninteger
variantobject
variant.idstring
variant.document_typestring
variant.keystring
variant.namestring
variant.is_defaultboolean
variant.languagestring | null
variant.project_types[]object[]
variant.project_types[].idstring
variant.project_types[].keystring
variant.project_types[].namestring
variant.active_versionobject | null
variant.active_version.templatestring
variant.active_version.versioninteger
variant.active_version.namestring
variant.active_version.created_atstring
variant.active_version.created_bystring | null
variant.version_countinteger
variant.latest_versioninteger | null
variant.urlstring
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.