Document Template endpoint — writable fields and setting template content via the API

Hi team,

Working with the documenttemplate endpoint. I can create and update the record fine, but I can’t find any way to populate the actual template content/layout, and I wanted to confirm whether that’s expected. What I’ve found:

  • Create + metadata works. POST /documenttemplate.json succeeds. Interestingly, template_type (e.g. Invoice) and related_object (e.g. Job) both persist on the created record even though they aren’t in the published DocumentTemplateCreate schema (confirmed by reading the record back).
  • .file is rejected on this object. GET, POST and PUT to /documenttemplate/{uuid}.file all return 400 Bad Request — "File attachment not supported on this object".
  • Not modeled as an attachment. GET /attachment.json?$filter=related_object_uuid eq '{template_uuid}' returns [], and no attachment uses related_object = 'documenttemplate'.

So a template created via the API is a working record with the right type/related object, but no content. Is there a supported way to set/populate a document template’s layout via the API — or is template content intentionally not writable? If there’s an approved approach for duplicating a template’s design programmatically, I’d love a pointer.

Thanks!

Hi Miciah,

Yes, your understanding matches the supported API surface we publish: the documenttemplate create/update endpoints support the record fields exposed in the schema, not the actual Word/template layout content.

In the published schema, DocumentTemplateCreate contains uuid and name, while template_type and related_object are returned on retrieval as read-only fields, so we wouldn’t treat those as supported writable fields even if you can observe them persisting in some cases.

The supported API use case is producing a document from an existing template, using /platform_produce_document; that endpoint combines a template with an object, and lets you specify an existing templateUUID that you can look up via the DocumentTemplate endpoint.

For template design/content management, the documented workflow is still through the Online Dashboard under Settings > Document Templates, where templates can be downloaded, edited in Word, and uploaded back into ServiceM8.

So there isn’t a supported API method we can point to for populating a document template’s layout or duplicating a template design programmatically.

Thanks,
Cody

It would be good if the API could be extended for programmatically uploading/attaching/replacing the actual document docx template for documents (quotes, invoices) and forms.

1 Like

Thanks Cody.

This makes sense from the lens of generating the document by knowing which documents exists, and even the option to update the document template record. I guess I just understand the option to create the record from the API if you still have to Settings > Document Templates to apply the edited Word doc, which is needed to create a proper and complete template record.

Hi Miciah,

That’s a fair read of the current split: the REST API exposes the document template as a record, but the documented create/update schema only includes the record UUID and name rather than the DOCX layout/content itself.

Where that’s useful today is mainly for workflows that need to reference or select existing templates, for example producing a document via /platform_produce_document, where templateUUID can be supplied and looked up through the DocumentTemplate endpoint.

For the actual template design, the documented workflow is still to manage the Word template through the Online Dashboard, including downloading, editing in Word, then uploading the modified template back under Settings > Document Templates.

So you’re right that API-created records don’t currently provide a complete end-to-end path for creating a usable custom template design from scratch.

Thanks,
Cody