Skip to content

Conversation

@lauraneto
Copy link
Contributor

Fixes #20443

In recent versions the flow of requests from the client when creating a document type with a template was:

  1. Create a template.
  2. Create a document type with the template id returned in 1.

In 1., the document type still didn't exist, so a "generic" template was being created.
Additionally, if the creation of the document type failed, the "orphan" template would remain.
This PR adds a new endpoint to the Management API:

POST /umbraco/management/api/v1/document-type/{guid}/template
{
  "alias": "templateAlias",
  "name": "templateName",
  "isDefault": false // Whether to set this template as the default for the document type
}

With the above in place, I adjusted the flow to:

  1. Create document type (with no template)
  2. Create template using the new endpoint (which will assign the template as default as well)

This way, a template is only created if the content type was actually created, and the generated template will know which model to reference.

The idea while building the new endpoint was also that you can also create templates for document types later on, default or not.

Testing
Create a Document Type with Template and verify that the generated template references the typed model and looks the same as in V13.
Also, ensure that creating templates through the backoffice still works as expected.

…ted for a content type

Add id, name and alias to the request payload to allow creating multiple templates for the same document type

Small adjustments

Remove unused import and unnecessary async

Switched content type template creation to content type controller

Missing constant export

# Conflicts:
#	src/Umbraco.Web.UI.Client/src/packages/core/backend-api/sdk.gen.ts
@lauraneto lauraneto changed the title Adjust the document type creation flow so that a template can be created for a content type Adjust the document type creation flow so that a template can be created for a content type (closes #20443) Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating a doctype with template does not yield a strongly typed templated

2 participants