Create a Template From a Site
/sites/management/api/v1/sites/{id}/templates
Create a template from a site, copying the site artifacts, such as assets. The name for the template must be specified, but a description for the template is optional.
Introduced in release 19.4.1.
Authorization
To invoke this operation, the authenticated user or client application must have one of the following roles:
- CECDeveloperUser
- CECSitesAdministrator
- CECContentAdministrator
To invoke this operation, the authenticated user or client application must have been shared with the resource and have one of the following sharing roles:
- Owner
- Manager
- Contributor
- Downloader
- Viewer
Granular Security
When creating a template from an SST site, the resulting template will enforce granular security. Sites requested from this template are then required to specify a Security Category upon creation. If this is not the behavior desired, the template can be edited after creation to disable this feature.
Asynchronous Processing
This operation only supports asynchronous processing. A Prefer
header with the value of respond-async
must be included in the request. An accepted response will include a Location
header, which provides the location of a status resource that can be polled to obtain information about the asynchronous processing.
For more information about reading the status see Get the Progress of a Template Related Job.
Path Alternative Identifiers
The default identifier for a Site resource is the Site Identifier. The Site resource supports alternative identifiers.
nameSite Name
Instead of the site identifier, the site name can be used to uniquely identify a site in the resource path. The default resource path parameter for a site is the site identifier, but when working with sites the human-readable site name is sometimes easier.
http://api.example.com/sites/management/api/v1/sites/name:MyNewProduct/templates
Introduced in release 19.4.1.
Successful Response Examples
This operation responds with the following success (2xx) responses. For a full list of response HTTP status codes and example bodies, consult the Response section of this operation.
202Accepted - Create a Template Specifying a Name and Description
Create a template from a site specifying a name and description.
Request
POST https://api.example.com/sites/management/api/v1/sites/{id}/templates
Request Headers
Prefer=respond-async
Request Body
{ "name": "AccessThemeNew", "description": "A new access theme template based on the site created from the original access theme template." }
202Accepted - Create an Enterprise Template from a Standard Site
Create an enterprise template from a standard site.
Request
POST https://api.example.com/sites/management/api/v1/sites/{id}/templates
Request Headers
Prefer=respond-async
Request Body
{ "name": "AcmeProductLaunch", "type": "enterprise" }
Client Error Response Examples
This operation responds with the following client error (4xx) responses, with exception details in the response body or reported through the asynchronous job. For a full list of response HTTP status codes and example bodies, consult the Response section of this operation.
400Bad Request - Invalid Template Name
The provided template name cannot be used because it contains characters or words that are not allowed. The reason the template name is invalid will be reported in the error message.
Error Code
OCE-SITEMGMT-009047
Resolution - Remove Spaces
Change the template name so that it does not contain spaces.
Resolution - Check Characters
Use only letters, numbers, hyphens, and underscores in template names.
Where This Error Can be Returned
- This error can be returned in the response body.
- This error will not be returned in the asynchronous job status.
Exception Detail Fields
This error type includes the following fields/values in the response:
Field Name | Description |
templateName | Invalid template name. |
reason | Reason the template name is invalid. Valid values are:
|
For detailed information about this exception detail type, consult the InvalidTemplateNameExceptionDetail schema in the definitions section of the swagger document.
Example Response Body
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1", "title": "Invalid Template Name", "status": "400", "detail": "Template name '{templateName}' cannot be used to create a template.", "o:errorCode": "OCE-SITEMGMT-009047", "templateName": "CafeSupremo", "reason": "tooLong" }
400Bad Request - Unpublished Site Items
Some content used by the site has not been published to the site's channel.
Error Code
OCE-SITEMGMT-009137
Resolution - Publish Content
Ensure all content has been targeted and published to the site's channel.
Where This Error Can be Returned
- This error will never be returned in the response body.
- This error can be returned in the asynchronous job status.
Example Response Body
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1", "title": "Unpublished Site Items", "status": "400", "detail": "Some content used by the site has not been published to the site's channel.", "o:errorCode": "OCE-SITEMGMT-009137" }
403Forbidden - Sites Administrator Role Required
The Sites Administrator role is required to create resources of this type.
Error Code
OCE-SITEMGMT-009140
Resolution - Change Sites System Settings
Creation of sites, templates, themes and components can be restricted to sites administrators. Update the Sites System settings to allow creation of sites resources of this type by non admin users.
Where This Error Can be Returned
- This error can be returned in the response body.
- This error can be returned in the asynchronous job status.
Exception Detail Fields
This error type includes the following fields/values in the response:
Field Name | Description |
resourceType | Resource type that can only be created by Sites Administrators. Valid values are:
|
name | Name of resource being created, if available. |
For detailed information about this exception detail type, consult the SitesAdminRoleRequiredExceptionDetail schema in the definitions section of the swagger document.
Example Response Body
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1", "title": "Sites Administrator Role Required", "status": "403", "detail": "The Sites Administrator role is required to create resources of this type.", "o:errorCode": "OCE-SITEMGMT-009140", "resourceType": "site", "name": "value" }
Introduced in release 22.5.2.
404Not Found - Site Not Found
The site does not exist or has been deleted, or the authenticated user or client application does not have access to the site.
Error Code
OCE-SITEMGMT-009003
Resolution - Check Identifier
Check that the site identifier is valid.
Resolution - Check Membership
Check that the authenticated user is a member of the site or a site administrator.
Where This Error Can be Returned
- This error can be returned in the response body.
- This error will not be returned in the asynchronous job status.
Exception Detail Fields
This error type includes the following fields/values in the response:
Field Name | Description |
site | Site that does not exist or is not visible to the authenticated user. |
For detailed information about this exception detail type, consult the SiteNotFoundExceptionDetail schema in the definitions section of the swagger document.
Example Response Body
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1", "title": "Site Not Found", "status": "404", "detail": "Site does not exist or has been deleted, or the authenticated user or client application does not have access to the site.", "o:errorCode": "OCE-SITEMGMT-009003", "site": { "id": "FCA9C0E5CDCB549A19FFB85987A2352778961003B8A0" } }
409Conflict - Template Already Exists
A template with the same name or identity already exists. Template names and identities must be unique across all templates.
Error Code
OCE-SITEMGMT-009040
Resolution - Change the Template Name
If clashing on name during a copy or rename, choose a different name.
Resolution - Change the Conflict Resolution Name
If clashing on name during an import, choose a different name for the template conflict resolution.
Resolution - Change the Conflict Resolution Action
If clashing on identity during an import, change the template conflict resolution type to overwrite
, create
, or skip
.
Where This Error Can be Returned
- This error can be returned in the response body.
- This error will not be returned in the asynchronous job status.
Exception Detail Fields
This error type includes the following fields/values in the response:
Field Name | Description |
template | Duplicate template. |
name | Duplicate name. |
itemGuid | Duplicate identity Guid. |
For detailed information about this exception detail type, consult the TemplateAlreadyExistsExceptionDetail schema in the definitions section of the swagger document.
Example Response Body
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1", "title": "Template Already Exists", "status": "409", "detail": "A template with the same name or identity already exists.", "o:errorCode": "OCE-SITEMGMT-009040", "template": { "id": "F30F08EB205D44AD20B5A48D1B1B3DD7D74F45978AB6" }, "name": "CafeSupremo", "itemGuid": "value" }
Introduced in release 19.4.1.
409Conflict - Site Deleted
The operation cannot be performed on a soft deleted site. This error can only occur when the includeDeleted
query parameter is set to true
.
Error Code
OCE-SITEMGMT-009059
Resolution - Restore Site
Restore the site and then try the operation again.
Where This Error Can be Returned
- This error can be returned in the response body.
- This error will not be returned in the asynchronous job status.
Exception Detail Fields
This error type includes the following fields/values in the response:
Field Name | Description |
site | Site that is soft deleted, if the site identifier has been provided. |
For detailed information about this exception detail type, consult the SiteDeletedExceptionDetail schema in the definitions section of the swagger document.
Example Response Body
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1", "title": "Site Deleted", "status": "409", "detail": "The operation cannot be performed as the site has been soft deleted.", "o:errorCode": "OCE-SITEMGMT-009059", "site": { "id": "FCA9C0E5CDCB549A19FFB85987A2352778961003B8A0" } }
Introduced in release 19.4.1.
409Conflict - Site Content Not Ready
The site contains content assets in a "not ready" state.
Error Code
OCE-SITEMGMT-009144
Where This Error Can be Returned
- This error will never be returned in the response body.
- This error can be returned in the asynchronous job status.
Exception Detail Fields
This error type includes the following fields/values in the response:
Field Name | Description |
site | Site on which the operation is being performed. |
For detailed information about this exception detail type, consult the SiteContentNotReadyErrorExceptionDetail schema in the definitions section of the swagger document.
Example Response Body
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1", "title": "Site Content Not Ready", "status": "409", "detail": "The site contains content assets in a \"not ready\" state.", "o:errorCode": "OCE-SITEMGMT-009144", "site": { "id": "FCA9C0E5CDCB549A19FFB85987A2352778961003B8A0" } }
Request
- application/json
-
id: string
Immutable identifier for the site.
-
Prefer(optional): string
Request asynchronous processing of the request using a
respond-async
header value.
Name and description for the template and whether to export published assets.
object
-
description(optional):
string
Maximum Length:
1000
Optional description. There is no restriction on the contents of the description; it can be a single line or multiple lines with any characters.
Introduced in release 19.4.1. -
includeUnpublished(optional):
boolean
Include unpublished content items and digital assets in your template. If set to
Introduced in release 19.4.1.true
then both published and unpublished content items and digital assets are included in the template. If set tofalse
then only published content items and digital assets are included in the template. If not specified the default is to include only published content items and digital assets. -
links(optional):
array links
HATEOS link to related resources and actions or actions on this resource. Must include at least a 'self' link that contains a link to the canonical representation of the resource.
-
name:
string
Maximum Length:
242
Name of the template.
Introduced in release 19.4.1. -
type(optional):
string
Type of template to create. If set to
enterprise
then the created template will be an enterprise template even if the site is not an enterprise site. If set toinherit
then the template type will inherit the type from the site. If not specified the default is for the template inherit the type from the site.Valid values are:
-
inherit
- Template type will be inherited from the site -
enterprise
- Create an enterprise template
-
{
"name":"AccessThemeNew",
"description":"A new access theme template based on the site created from the original access theme template."
}
array
HATEOS link to related resources and actions or actions on this resource. Must include at least a 'self' link that contains a link to the canonical representation of the resource.
object
REST HATEOAS link and related metadata. If responses provide links (for example, a self
link to the resource itself) the links provided will include one or more of the properties defined on this link structure.
-
href(optional):
string
The target resource URI. URI RFC3986 or URI Template RFC6570. If the value is set to URI Template, then the
templated
property must be set totrue
. -
mediaType(optional):
string
Media type, as defined by RFC 2046, describing the link target.
-
method(optional):
string
HTTP method for requesting the target of the link.
Valid values are:
-
OPTIONS
- HTTP OPTIONS -
HEAD
- HTTP HEAD -
GET
- HTTP GET -
POST
- HTTP POST -
PUT
- HTTP PUT -
PATCH
- HTTP PATCH -
DELETE
- HTTP DELETE
-
-
profile(optional):
string(uri)
Link to the metadata of the resource, such as JSON-schema, that describes the resource expected when dereferencing the target resource.
-
rel(optional):
string
Name of the link relation that, in addition to the type property, can be used to retrieve link details.
-
templated(optional):
boolean
Boolean flag that specifies the
href
property is a URI or URI Template. The property can be assumed to befalse
if the property is not present.
Response
202 Response
400 Response
-
object
ExceptionDetail
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
-
object
InvalidTemplateNameExceptionDetail-allOf[1]
object
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
-
detail(optional):
string
Description specific to this occurrence of the problem. The human-readable, potentially multi-line details describing the problem in more details.
-
instance(optional):
string(uri)
URI to the link that provides more detail about the error.
-
o:errorCode(optional):
string
Application error code, which is different from HTTP error code. This code should be used to check for specific errors, rather than comparing fields such as the
title
ordetail
. -
o:errorDetails(optional):
array o:errorDetails
Multiple errors can be organized in a hierarchical structure.
-
o:errorPath(optional):
string
XPath or JSON path to indicate where the error occurs.
-
status(optional):
integer(int32)
Corresponding HTTP status code for the error.
-
title(optional):
string
Short, human-readable summary of the problem. It is not advisable to use the title as a way of checking for specific errors, use the
o:errorCode
for this purpose. -
type(optional):
string(uri)
Absolute URI that identifies the problem type. When this URI dereferenced, it should provide a human-readable summary of the problem, for example, as a HTML page.
object
-
reason(optional):
string
Reason the template name is invalid.
Valid values are:
-
tooLong
- Name is too long -
invalidCharacters
- Name contains invalid characters -
startWithSpace
- Name starts with a space -
endWithSpace
- Name ends with a space -
internalWord
- Name is a restricted internal word -
empty
- Name is empty
-
-
templateName(optional):
string
Maximum Length:
242
Invalid template name.
array
Multiple errors can be organized in a hierarchical structure.
-
object
ExceptionDetail
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
{
"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title":"Invalid Template Name",
"status":"400",
"detail":"Template name '{templateName}' cannot be used to create a template.",
"o:errorCode":"OCE-SITEMGMT-009047",
"templateName":"CafeSupremo",
"reason":"tooLong"
}
401 Response
403 Response
-
allOf
SitesAdminRoleRequiredExceptionDetail
Introduced in release 22.5.2.
-
object
ExceptionDetail
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
-
object
SitesAdminRoleRequiredExceptionDetail-allOf[1]
object
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
-
detail(optional):
string
Description specific to this occurrence of the problem. The human-readable, potentially multi-line details describing the problem in more details.
-
instance(optional):
string(uri)
URI to the link that provides more detail about the error.
-
o:errorCode(optional):
string
Application error code, which is different from HTTP error code. This code should be used to check for specific errors, rather than comparing fields such as the
title
ordetail
. -
o:errorDetails(optional):
array o:errorDetails
Multiple errors can be organized in a hierarchical structure.
-
o:errorPath(optional):
string
XPath or JSON path to indicate where the error occurs.
-
status(optional):
integer(int32)
Corresponding HTTP status code for the error.
-
title(optional):
string
Short, human-readable summary of the problem. It is not advisable to use the title as a way of checking for specific errors, use the
o:errorCode
for this purpose. -
type(optional):
string(uri)
Absolute URI that identifies the problem type. When this URI dereferenced, it should provide a human-readable summary of the problem, for example, as a HTML page.
object
-
name(optional):
string
Name of resource being created, if available.
Introduced in release 22.5.2. -
resourceType(optional):
string
Resource type that can only be created by Sites Administrators.
Valid values are:
-
site
- Site resource -
template
- Template resource -
theme
- Theme resource -
component
- Component resource
-
array
Multiple errors can be organized in a hierarchical structure.
-
object
ExceptionDetail
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
{
"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title":"Sites Administrator Role Required",
"status":"403",
"detail":"The Sites Administrator role is required to create resources of this type.",
"o:errorCode":"OCE-SITEMGMT-009140",
"resourceType":"site",
"name":"value"
}
404 Response
-
Cache-Control: string
Directives for caching mechanisms.
-
Content-Length: string
Size of the response body.
-
Content-Type: string
Content type of the response.
-
object
ExceptionDetail
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
-
object
SiteNotFoundExceptionDetail-allOf[1]
object
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
-
detail(optional):
string
Description specific to this occurrence of the problem. The human-readable, potentially multi-line details describing the problem in more details.
-
instance(optional):
string(uri)
URI to the link that provides more detail about the error.
-
o:errorCode(optional):
string
Application error code, which is different from HTTP error code. This code should be used to check for specific errors, rather than comparing fields such as the
title
ordetail
. -
o:errorDetails(optional):
array o:errorDetails
Multiple errors can be organized in a hierarchical structure.
-
o:errorPath(optional):
string
XPath or JSON path to indicate where the error occurs.
-
status(optional):
integer(int32)
Corresponding HTTP status code for the error.
-
title(optional):
string
Short, human-readable summary of the problem. It is not advisable to use the title as a way of checking for specific errors, use the
o:errorCode
for this purpose. -
type(optional):
string(uri)
Absolute URI that identifies the problem type. When this URI dereferenced, it should provide a human-readable summary of the problem, for example, as a HTML page.
object
-
site(optional):
string
Site that does not exist or is not visible to the authenticated user.
array
Multiple errors can be organized in a hierarchical structure.
-
object
ExceptionDetail
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
{
"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title":"Site Not Found",
"status":"404",
"detail":"Site does not exist or has been deleted, or the authenticated user or client application does not have access to the site.",
"o:errorCode":"OCE-SITEMGMT-009003",
"site":{
"id":"FCA9C0E5CDCB549A19FFB85987A2352778961003B8A0"
}
}
409 Response
-
allOf
TemplateAlreadyExistsExceptionDetail
Introduced in release 19.4.1.
-
object
ExceptionDetail
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
-
object
TemplateAlreadyExistsExceptionDetail-allOf[1]
object
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
-
detail(optional):
string
Description specific to this occurrence of the problem. The human-readable, potentially multi-line details describing the problem in more details.
-
instance(optional):
string(uri)
URI to the link that provides more detail about the error.
-
o:errorCode(optional):
string
Application error code, which is different from HTTP error code. This code should be used to check for specific errors, rather than comparing fields such as the
title
ordetail
. -
o:errorDetails(optional):
array o:errorDetails
Multiple errors can be organized in a hierarchical structure.
-
o:errorPath(optional):
string
XPath or JSON path to indicate where the error occurs.
-
status(optional):
integer(int32)
Corresponding HTTP status code for the error.
-
title(optional):
string
Short, human-readable summary of the problem. It is not advisable to use the title as a way of checking for specific errors, use the
o:errorCode
for this purpose. -
type(optional):
string(uri)
Absolute URI that identifies the problem type. When this URI dereferenced, it should provide a human-readable summary of the problem, for example, as a HTML page.
object
-
itemGuid(optional):
string
Duplicate identity Guid.
Introduced in release 22.4.3. -
name(optional):
string
Maximum Length:
242
Duplicate name.
Introduced in release 22.4.3. -
template(optional):
string
Duplicate template.
Introduced in release 19.4.1.
array
Multiple errors can be organized in a hierarchical structure.
-
object
ExceptionDetail
In addition to HTTP error code and error messages, it is often desirable to provide additional information to the client when a request fails. In such cases, the additional information will be included in the response body.
{
"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title":"Template Already Exists",
"status":"409",
"detail":"A template with the same name or identity already exists.",
"o:errorCode":"OCE-SITEMGMT-009040",
"template":{
"id":"F30F08EB205D44AD20B5A48D1B1B3DD7D74F45978AB6"
},
"name":"CafeSupremo",
"itemGuid":"value"
}
{
"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title":"Site Deleted",
"status":"409",
"detail":"The operation cannot be performed as the site has been soft deleted.",
"o:errorCode":"OCE-SITEMGMT-009059",
"site":{
"id":"FCA9C0E5CDCB549A19FFB85987A2352778961003B8A0"
}
}