# Product Templates

Manage product templates. Product templates define a set of attributes which are common for all product instances based on that template.

## Retrieving all product templates

> Retrieves all product templates. You can filter the results with query parameters.\
> \
> A product template defines a set of attributes which are common for all product instances based on that template.

```json
{"openapi":"3.0.0","info":{"title":"Product Service","version":"0.0.1"},"tags":[{"name":"Product Templates","description":"Manage product templates. Product templates define a set of attributes which are common for all product instances based on that template."}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["product.product_template_read"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"product.product_manage":"Needed to manage products.","product.product_publish":"Needed to publish products.","product.product_unpublish":"Needed to unpublish products.","product.product_read_unpublished":"Needed to retrieve unpublished products.","product.product_read_by_vendor":"The scope allows vendor to read products with assigned vendor.","product.product_manage_by_vendor":"The scope allows vendor to manage products with assigned vendor.","product.price_manage":"Needed to manage product prices.","product.product_template_read":"Needed for reading product templates.","product.product_template_manage":"Needed for updating and removing a product template."}}}}},"schemas":{"productTemplatesResponse":{"title":"productTemplatesResponse","type":"array","items":{"$ref":"#/components/schemas/productTemplateResponse"}},"productTemplateResponse":{"allOf":[{"$ref":"#/components/schemas/productTemplateCreation"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/productTemplateMetadata"}}}]},"productTemplateCreation":{"title":"productTemplateCreation","type":"object","allOf":[{"$ref":"#/components/schemas/productTemplateBase"},{"type":"object","properties":{"id":{"type":"string","description":"Identifier of the product template."}}}]},"productTemplateBase":{"type":"object","properties":{"name":{"type":"object","description":"Localized product template name in a form of a map of translations.","additionalProperties":{"type":"string"}},"attributes":{"type":"array","description":"List of attributes related to the product template.","items":{"$ref":"#/components/schemas/productTemplateAttribute"}}},"required":["name","attributes"]},"productTemplateAttribute":{"title":"productTemplateAttribute","type":"object","properties":{"key":{"type":"string","description":"An identifier of the attribute. The key is used as a field name in a product instance created based on the product template. The key can contain only alphanumeric characters. "},"name":{"type":"object","additionalProperties":{"type":"string"},"description":"Localized resource name in a form of a map of translations."},"type":{"type":"string","description":"Attribute type. Correct values: `TEXT`, `NUMBER`, `BOOLEAN`, `DATETIME`. Regardless of the chosen type, the defaultValue and values fields are validated. The DATETIME values must be compliant with the ISO 8601 standard, for example: 2022-03-31T09:52:15.423Z."},"metadata":{"type":"object","description":"Metadata contains additional information about the attribute.","properties":{"mandatory":{"type":"boolean","description":"Indicates whether the attribute should be treated as a mandatory."},"variantAttribute":{"type":"boolean","description":"Indicates whether the attribute is a variant-specific attribute. Variant attributes are taken into account during variants creation.\nIf the value is set to true, then the 'values' array cannot be null."},"defaultValue":{"description":"The attribute stores a default value for the attribute.","oneOf":[{"type":"string"},{"type":"boolean"},{"type":"number"}]}}},"values":{"allOf":[{"$ref":"#/components/schemas/values"},{"type":"object","description":"If the values are populated then the attribute behaves as an enum property. In other words, the attribute in a product instance can contain only values mentioned in this array. For each\nattribute the value should consist of object with key and localized names."}]}},"required":["key","name","type","metadata"]},"values":{"type":"array","items":{"$ref":"#/components/schemas/value"}},"value":{"type":"object","properties":{"key":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"productTemplateMetadata":{"title":"productTemplateMetadata","type":"object","properties":{"variantAttributesSchema":{"type":"string","description":"Schema url of the variant attributes."},"templateAttributesSchema":{"type":"string","description":"Schema url of the template attributes."},"createdAt":{"type":"string","description":"Date and time when the object was created, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"modifiedAt":{"type":"string","description":"Date and time when the object was last modified, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"version":{"type":"number","description":"Version of the object. The value is required during update operation."}}},"coreErrorMessage":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."}}}},"responses":{"common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}},"common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}},"common_response_InternalServerError_500":{"description":"Internal Server Error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}}},"parameters":{"header_x_total_count":{"name":"X-Total-Count","in":"header","required":false,"schema":{"type":"boolean"},"description":"Flag indicating whether the total number of retrieved results should be returned."},"header_accept_language":{"name":"Accept-Language","in":"header","required":false,"schema":{"type":"string"},"description":"The Accept-Language request HTTP header defines which languages the client is able to understand, and which locale variant is preferred. If empty, the default system language is assumed. It can be a priority list working as a fallback mechanism."},"query_page_number":{"name":"pageNumber","in":"query","required":false,"schema":{"type":"integer"},"description":"The page number to be retrieved where the size of the pages must be specified by the pageSize parameter. The number of the first page is 1."},"query_page_size":{"name":"pageSize","in":"query","required":false,"schema":{"type":"integer","default":60},"description":"The number of documents being retrieved on the page."},"query_sort":{"name":"sort","in":"query","required":false,"schema":{"type":"string"},"description":"Fields to sort the response data by following order of the parameters from left to right.\nCan contain multiple fields in format: `field name:sort direction` separated by a comma.\nThe colon with `sort direction` parameter is redundant and descending order is taken only if it is equal to `desc` or `DESC`.\nAscending order is considered in any other case.\nWhile sorting by a localised field the following rule is taken into account:\n  1. If a localized field contains information about a language, then the language should be used. For example `name.en:ASC`. In that case en language is used for sorting the name property. The language suffix takes precedence over `Accept-Language` header.\n  2. If a localized field does not contain information about a language, then the `Accept-Language` header is used. For example `name:ASC` and `Accept-Language: de`. In that case `de` is used for sorting the name property.\n  3. If a localized field does not contain information about language and `Accept-Language` header contains `*`, then the default language from configuration service is used as a language. For example `name:ASC` and `Accept-Language: *` and default language is pl then pl is used as a language for name property.\n  4. If a localized field does not contains information about language and `Accept-Language` header does not exists in the request, then the default language from configuration service is used.  \"\n"},"query_q_param_product_template":{"name":"q","in":"query","required":false,"schema":{"type":"string"},"description":"Standard query parameter used to search for specific values.   \n* Searching for an item by string property: `q=id:31065d5b-b62e`, where `id` is the field name and `31065d5b-b62e` is its required value.   \n* Searching for an item by localized field property: `q=name.en:T-s` where `name` is the name of the field, `en` is a language code and `T-s` is a required value of this field.   This query works only for localized fields, which are stored in a Map format where `key` is a language code and `value` is translation to particular language.   + Searching for items by date property. All numer-based property queries are valid also for dates. In that case the date should be placed within double quotes: `q=metadata.createdAt:(>=\"2021-05-18T07:27:27.455Z\" AND <\"2021-05-20T07:27:27.455Z\")`   + Searching for items with non existing or empty property: `q=name.en:null` where `name.en` is a name of fields that has value `null`.   + Searching for items with existing property: `q=attributes:exists` where `attributes` is a name of field that has `non null` value.   + Searching for items by multiple specific values: `q=id:(5c3325baa9812100098ff48f,5c3325d1a9812100098ff494)` where `id` is name of field and strings within a bracket are it''s required value.   + Searching for items by multiple fields: `q=id:5c3325baa9812100098ff48f name.en:T-s` where `id` and ''name.en'' are the names of fields. All documents that contain given values of these fields are returned. Multiple fields separated by space can be specified. Multiple values for each field can be also specified in a format presented above.   + Searching for items with string fields conforming to a regex: `q=name.en:~ABCD12` or `q=name.en:(~AB CD)` - in case of searching for strings with space, where `name` is the name of field and `ABCD12` or `AB CD` is it''s querying regex.'\n"}}},"paths":{"/product/{tenant}/product-templates":{"get":{"summary":"Retrieving all product templates","tags":["Product Templates"],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/productTemplatesResponse"}}}},"400":{"$ref":"#/components/responses/common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/common_response_Forbidden_403"},"500":{"$ref":"#/components/responses/common_response_InternalServerError_500"}},"operationId":"GET-product-list-templates","description":"Retrieves all product templates. You can filter the results with query parameters.\n\nA product template defines a set of attributes which are common for all product instances based on that template.","parameters":[{"$ref":"#/components/parameters/header_x_total_count"},{"$ref":"#/components/parameters/header_accept_language"},{"$ref":"#/components/parameters/query_page_number"},{"$ref":"#/components/parameters/query_page_size"},{"$ref":"#/components/parameters/query_sort"},{"$ref":"#/components/parameters/query_q_param_product_template"}]}}}}
```

## Creating a new product template

> Creates a new product template. \
> \
> A product template defines a set of attributes which are common for all product instances based on that template.

```json
{"openapi":"3.0.0","info":{"title":"Product Service","version":"0.0.1"},"tags":[{"name":"Product Templates","description":"Manage product templates. Product templates define a set of attributes which are common for all product instances based on that template."}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["product.product_template_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"product.product_manage":"Needed to manage products.","product.product_publish":"Needed to publish products.","product.product_unpublish":"Needed to unpublish products.","product.product_read_unpublished":"Needed to retrieve unpublished products.","product.product_read_by_vendor":"The scope allows vendor to read products with assigned vendor.","product.product_manage_by_vendor":"The scope allows vendor to manage products with assigned vendor.","product.price_manage":"Needed to manage product prices.","product.product_template_read":"Needed for reading product templates.","product.product_template_manage":"Needed for updating and removing a product template."}}}}},"responses":{"common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}},"common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}},"common_response_InternalServerError_500":{"description":"Internal Server Error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}}},"schemas":{"coreErrorMessage":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."}}},"productTemplateCreation":{"title":"productTemplateCreation","type":"object","allOf":[{"$ref":"#/components/schemas/productTemplateBase"},{"type":"object","properties":{"id":{"type":"string","description":"Identifier of the product template."}}}]},"productTemplateBase":{"type":"object","properties":{"name":{"type":"object","description":"Localized product template name in a form of a map of translations.","additionalProperties":{"type":"string"}},"attributes":{"type":"array","description":"List of attributes related to the product template.","items":{"$ref":"#/components/schemas/productTemplateAttribute"}}},"required":["name","attributes"]},"productTemplateAttribute":{"title":"productTemplateAttribute","type":"object","properties":{"key":{"type":"string","description":"An identifier of the attribute. The key is used as a field name in a product instance created based on the product template. The key can contain only alphanumeric characters. "},"name":{"type":"object","additionalProperties":{"type":"string"},"description":"Localized resource name in a form of a map of translations."},"type":{"type":"string","description":"Attribute type. Correct values: `TEXT`, `NUMBER`, `BOOLEAN`, `DATETIME`. Regardless of the chosen type, the defaultValue and values fields are validated. The DATETIME values must be compliant with the ISO 8601 standard, for example: 2022-03-31T09:52:15.423Z."},"metadata":{"type":"object","description":"Metadata contains additional information about the attribute.","properties":{"mandatory":{"type":"boolean","description":"Indicates whether the attribute should be treated as a mandatory."},"variantAttribute":{"type":"boolean","description":"Indicates whether the attribute is a variant-specific attribute. Variant attributes are taken into account during variants creation.\nIf the value is set to true, then the 'values' array cannot be null."},"defaultValue":{"description":"The attribute stores a default value for the attribute.","oneOf":[{"type":"string"},{"type":"boolean"},{"type":"number"}]}}},"values":{"allOf":[{"$ref":"#/components/schemas/values"},{"type":"object","description":"If the values are populated then the attribute behaves as an enum property. In other words, the attribute in a product instance can contain only values mentioned in this array. For each\nattribute the value should consist of object with key and localized names."}]}},"required":["key","name","type","metadata"]},"values":{"type":"array","items":{"$ref":"#/components/schemas/value"}},"value":{"type":"object","properties":{"key":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}}},"parameters":{"header_content_language":{"name":"Content-Language","in":"header","required":false,"schema":{"type":"string"},"description":"The Content-Language request HTTP header defines a language or multiple languages of the request body.\n\n* If the `Content-Language` header is set to `*`, the localized fields should be provided as maps of translations, where the keys are language codes and values are the fields in their respective languages.\n* If the `Content-Language` header is set to a specific language, the localized fields should be provided as strings.\n* If the `Content-Language` header is empty, the endpoint interprets the localized fields as being provided in the default language or the languages defined in the Configuration Service.\n\n**Note**: You can provide the localized fields only in languages defined in the Configuration Service. In case the fields are provided in languages that are not defined in the Configuration Service, the request is rejected.\n"}}},"paths":{"/product/{tenant}/product-templates":{"post":{"summary":"Creating a new product template","operationId":"POST-product-create-template","responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Identifier of the newly created product template."}}}}}},"400":{"$ref":"#/components/responses/common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/common_response_Forbidden_403"},"500":{"$ref":"#/components/responses/common_response_InternalServerError_500"}},"tags":["Product Templates"],"description":"Creates a new product template. \n\nA product template defines a set of attributes which are common for all product instances based on that template.","parameters":[{"$ref":"#/components/parameters/header_content_language"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/productTemplateCreation"}}}}}}}}
```

## Retrieving a product template

> Retrieves a specified product template's details.\
> \
> A product template defines a set of attributes which are common for all product instances based on that template.

```json
{"openapi":"3.0.0","info":{"title":"Product Service","version":"0.0.1"},"tags":[{"name":"Product Templates","description":"Manage product templates. Product templates define a set of attributes which are common for all product instances based on that template."}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["product.product_template_read"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"product.product_manage":"Needed to manage products.","product.product_publish":"Needed to publish products.","product.product_unpublish":"Needed to unpublish products.","product.product_read_unpublished":"Needed to retrieve unpublished products.","product.product_read_by_vendor":"The scope allows vendor to read products with assigned vendor.","product.product_manage_by_vendor":"The scope allows vendor to manage products with assigned vendor.","product.price_manage":"Needed to manage product prices.","product.product_template_read":"Needed for reading product templates.","product.product_template_manage":"Needed for updating and removing a product template."}}}}},"schemas":{"productTemplateResponse":{"allOf":[{"$ref":"#/components/schemas/productTemplateCreation"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/productTemplateMetadata"}}}]},"productTemplateCreation":{"title":"productTemplateCreation","type":"object","allOf":[{"$ref":"#/components/schemas/productTemplateBase"},{"type":"object","properties":{"id":{"type":"string","description":"Identifier of the product template."}}}]},"productTemplateBase":{"type":"object","properties":{"name":{"type":"object","description":"Localized product template name in a form of a map of translations.","additionalProperties":{"type":"string"}},"attributes":{"type":"array","description":"List of attributes related to the product template.","items":{"$ref":"#/components/schemas/productTemplateAttribute"}}},"required":["name","attributes"]},"productTemplateAttribute":{"title":"productTemplateAttribute","type":"object","properties":{"key":{"type":"string","description":"An identifier of the attribute. The key is used as a field name in a product instance created based on the product template. The key can contain only alphanumeric characters. "},"name":{"type":"object","additionalProperties":{"type":"string"},"description":"Localized resource name in a form of a map of translations."},"type":{"type":"string","description":"Attribute type. Correct values: `TEXT`, `NUMBER`, `BOOLEAN`, `DATETIME`. Regardless of the chosen type, the defaultValue and values fields are validated. The DATETIME values must be compliant with the ISO 8601 standard, for example: 2022-03-31T09:52:15.423Z."},"metadata":{"type":"object","description":"Metadata contains additional information about the attribute.","properties":{"mandatory":{"type":"boolean","description":"Indicates whether the attribute should be treated as a mandatory."},"variantAttribute":{"type":"boolean","description":"Indicates whether the attribute is a variant-specific attribute. Variant attributes are taken into account during variants creation.\nIf the value is set to true, then the 'values' array cannot be null."},"defaultValue":{"description":"The attribute stores a default value for the attribute.","oneOf":[{"type":"string"},{"type":"boolean"},{"type":"number"}]}}},"values":{"allOf":[{"$ref":"#/components/schemas/values"},{"type":"object","description":"If the values are populated then the attribute behaves as an enum property. In other words, the attribute in a product instance can contain only values mentioned in this array. For each\nattribute the value should consist of object with key and localized names."}]}},"required":["key","name","type","metadata"]},"values":{"type":"array","items":{"$ref":"#/components/schemas/value"}},"value":{"type":"object","properties":{"key":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"productTemplateMetadata":{"title":"productTemplateMetadata","type":"object","properties":{"variantAttributesSchema":{"type":"string","description":"Schema url of the variant attributes."},"templateAttributesSchema":{"type":"string","description":"Schema url of the template attributes."},"createdAt":{"type":"string","description":"Date and time when the object was created, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"modifiedAt":{"type":"string","description":"Date and time when the object was last modified, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"version":{"type":"number","description":"Version of the object. The value is required during update operation."}}},"coreErrorMessage":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."}}},"productErrorMessage":{"allOf":[{"$ref":"#/components/schemas/coreErrorMessage"},{"type":"object","properties":{"productId":{"type":"string","description":"Identifier of the product."}}}]}},"responses":{"common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}},"product_NotFound_404":{"description":"Resource has not been found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/productErrorMessage"}}}},"common_response_InternalServerError_500":{"description":"Internal Server Error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}}},"parameters":{"header_accept_language":{"name":"Accept-Language","in":"header","required":false,"schema":{"type":"string"},"description":"The Accept-Language request HTTP header defines which languages the client is able to understand, and which locale variant is preferred. If empty, the default system language is assumed. It can be a priority list working as a fallback mechanism."},"query_version_parameter_product_template":{"name":"version","in":"query","required":false,"schema":{"type":"string"},"description":"Version of the product template. If the parameter is not provided, the latest version of product template is returned."}}},"paths":{"/product/{tenant}/product-templates/{product-template-id}":{"get":{"summary":"Retrieving a product template","tags":["Product Templates"],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/productTemplateResponse"}}}},"401":{"$ref":"#/components/responses/common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/common_response_Forbidden_403"},"404":{"$ref":"#/components/responses/product_NotFound_404"},"500":{"$ref":"#/components/responses/common_response_InternalServerError_500"}},"operationId":"GET-product-retrieve-template","parameters":[{"$ref":"#/components/parameters/header_accept_language"},{"$ref":"#/components/parameters/query_version_parameter_product_template"}],"description":"Retrieves a specified product template's details.\n\nA product template defines a set of attributes which are common for all product instances based on that template."}}}}
```

## Updating a product template

> Updates a specified product template by replacing all of its existing data with data from the request body. \
> \
> \*\*Note\*\*: Every product template update creates a new version of the template. Products based on previous versions are not automatically updated. In order to see the changes (for example new attributes) on the product level, you need to update the template version in applicable products.

```json
{"openapi":"3.0.0","info":{"title":"Product Service","version":"0.0.1"},"tags":[{"name":"Product Templates","description":"Manage product templates. Product templates define a set of attributes which are common for all product instances based on that template."}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["product.product_template_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"product.product_manage":"Needed to manage products.","product.product_publish":"Needed to publish products.","product.product_unpublish":"Needed to unpublish products.","product.product_read_unpublished":"Needed to retrieve unpublished products.","product.product_read_by_vendor":"The scope allows vendor to read products with assigned vendor.","product.product_manage_by_vendor":"The scope allows vendor to manage products with assigned vendor.","product.price_manage":"Needed to manage product prices.","product.product_template_read":"Needed for reading product templates.","product.product_template_manage":"Needed for updating and removing a product template."}}}}},"responses":{"common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}},"common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}},"product_NotFound_404":{"description":"Resource has not been found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/productErrorMessage"}}}},"common_response_Conflict_409":{"description":"There are three possible reasons:\n1. Product with given code already exists, please choose unique code for your product\n2. Optimistic locking failed. If user sends metadata/version attribute which is outdated (someone else updated product in the time user was performing his changes). User should retrieve the latest product data and retry the request.\n3. Optimistic locking failed. User did not provide metadata/version attribute in update request, but someone else updated product while it was internally handled by product service. Resending the same request can result in successful update, but the update can override recently persisted changes.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessageWithDetails"}}}},"common_response_InternalServerError_500":{"description":"Internal Server Error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}}},"schemas":{"coreErrorMessage":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."}}},"productErrorMessage":{"allOf":[{"$ref":"#/components/schemas/coreErrorMessage"},{"type":"object","properties":{"productId":{"type":"string","description":"Identifier of the product."}}}]},"coreErrorMessageWithDetails":{"type":"object","allOf":[{"$ref":"#/components/schemas/coreErrorMessage"},{"type":"object","properties":{"details":{"type":"array","description":"Error message details.","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}]},"productTemplateUpdate":{"title":"productTemplateUpdate","allOf":[{"$ref":"#/components/schemas/productTemplateBase"},{"type":"object","properties":{"metadata":{"type":"object","properties":{"version":{"type":"number","description":"Version of the object. The value is required while product template update."}},"required":["version"]}}}],"required":["name","attributes","metadata"]},"productTemplateBase":{"type":"object","properties":{"name":{"type":"object","description":"Localized product template name in a form of a map of translations.","additionalProperties":{"type":"string"}},"attributes":{"type":"array","description":"List of attributes related to the product template.","items":{"$ref":"#/components/schemas/productTemplateAttribute"}}},"required":["name","attributes"]},"productTemplateAttribute":{"title":"productTemplateAttribute","type":"object","properties":{"key":{"type":"string","description":"An identifier of the attribute. The key is used as a field name in a product instance created based on the product template. The key can contain only alphanumeric characters. "},"name":{"type":"object","additionalProperties":{"type":"string"},"description":"Localized resource name in a form of a map of translations."},"type":{"type":"string","description":"Attribute type. Correct values: `TEXT`, `NUMBER`, `BOOLEAN`, `DATETIME`. Regardless of the chosen type, the defaultValue and values fields are validated. The DATETIME values must be compliant with the ISO 8601 standard, for example: 2022-03-31T09:52:15.423Z."},"metadata":{"type":"object","description":"Metadata contains additional information about the attribute.","properties":{"mandatory":{"type":"boolean","description":"Indicates whether the attribute should be treated as a mandatory."},"variantAttribute":{"type":"boolean","description":"Indicates whether the attribute is a variant-specific attribute. Variant attributes are taken into account during variants creation.\nIf the value is set to true, then the 'values' array cannot be null."},"defaultValue":{"description":"The attribute stores a default value for the attribute.","oneOf":[{"type":"string"},{"type":"boolean"},{"type":"number"}]}}},"values":{"allOf":[{"$ref":"#/components/schemas/values"},{"type":"object","description":"If the values are populated then the attribute behaves as an enum property. In other words, the attribute in a product instance can contain only values mentioned in this array. For each\nattribute the value should consist of object with key and localized names."}]}},"required":["key","name","type","metadata"]},"values":{"type":"array","items":{"$ref":"#/components/schemas/value"}},"value":{"type":"object","properties":{"key":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}}},"parameters":{"header_content_language":{"name":"Content-Language","in":"header","required":false,"schema":{"type":"string"},"description":"The Content-Language request HTTP header defines a language or multiple languages of the request body.\n\n* If the `Content-Language` header is set to `*`, the localized fields should be provided as maps of translations, where the keys are language codes and values are the fields in their respective languages.\n* If the `Content-Language` header is set to a specific language, the localized fields should be provided as strings.\n* If the `Content-Language` header is empty, the endpoint interprets the localized fields as being provided in the default language or the languages defined in the Configuration Service.\n\n**Note**: You can provide the localized fields only in languages defined in the Configuration Service. In case the fields are provided in languages that are not defined in the Configuration Service, the request is rejected.\n"}}},"paths":{"/product/{tenant}/product-templates/{product-template-id}":{"put":{"summary":"Updating a product template","operationId":"PUT-product-update-template","responses":{"204":{"description":"No Content"},"400":{"$ref":"#/components/responses/common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/common_response_Forbidden_403"},"404":{"$ref":"#/components/responses/product_NotFound_404"},"409":{"$ref":"#/components/responses/common_response_Conflict_409"},"500":{"$ref":"#/components/responses/common_response_InternalServerError_500"}},"tags":["Product Templates"],"description":"Updates a specified product template by replacing all of its existing data with data from the request body. \n\n**Note**: Every product template update creates a new version of the template. Products based on previous versions are not automatically updated. In order to see the changes (for example new attributes) on the product level, you need to update the template version in applicable products.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/productTemplateUpdate"}}},"description":""},"parameters":[{"$ref":"#/components/parameters/header_content_language"}]}}}}
```

## Deleting a product template

> Deletes a specified product template. Only product templates which are not used in products and parent variants can be deleted.

```json
{"openapi":"3.0.0","info":{"title":"Product Service","version":"0.0.1"},"tags":[{"name":"Product Templates","description":"Manage product templates. Product templates define a set of attributes which are common for all product instances based on that template."}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["product.product_template_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"product.product_manage":"Needed to manage products.","product.product_publish":"Needed to publish products.","product.product_unpublish":"Needed to unpublish products.","product.product_read_unpublished":"Needed to retrieve unpublished products.","product.product_read_by_vendor":"The scope allows vendor to read products with assigned vendor.","product.product_manage_by_vendor":"The scope allows vendor to manage products with assigned vendor.","product.price_manage":"Needed to manage product prices.","product.product_template_read":"Needed for reading product templates.","product.product_template_manage":"Needed for updating and removing a product template."}}}}},"responses":{"common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}},"common_response_InternalServerError_500":{"description":"Internal Server Error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/coreErrorMessage"}}}}},"schemas":{"coreErrorMessage":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."}}}}},"paths":{"/product/{tenant}/product-templates/{product-template-id}":{"delete":{"summary":"Deleting a product template","operationId":"DELETE-product-remove-template","requestBody":{"content":{"application/json":{"schema":{"type":"object"}}},"required":false},"responses":{"204":{"description":"No Content"},"401":{"$ref":"#/components/responses/common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/common_response_Forbidden_403"},"500":{"$ref":"#/components/responses/common_response_InternalServerError_500"}},"tags":["Product Templates"],"description":"Deletes a specified product template. Only product templates which are not used in products and parent variants can be deleted."}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.emporix.io/api-references/api-guides/products-labels-and-brands/product-service/api-reference/product-templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
