> ## Documentation Index
> Fetch the complete documentation index at: https://product-discovery.developer.voyado.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> An import of templates for response object customization, used with the query parameter 'templateId'.

## PUT

An import of templates for response object customization, used with the query parameter 'templateId'. **Importing templates with PUT will remove all existing templates not in the import!**

```http theme={null}
PUT https://{cluster-id}.elevate-api.cloud/api/admin/v4/import/templates
```

### Request

<AccordionGroup>
  <Accordion title="Request header parameters">
    | Name                 | Description                                                                                                                                                                                                                                  | Example            |
    | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
    | `Api-Key`\*          | API key supplied during onboarding.                                                                                                                                                                                                          | `123456789..`      |
    | `Content-Encoding`\* | Content should be gzip encoded for all production requests. For manual test purposes, uncompressed small bodies may be provided using query parameter 'bypass-compression-for-manual-test=true' and omitted Content-Encoding (or 'identity') | `gzip`             |
    | `Content-Type`       | application/json                                                                                                                                                                                                                             | `application/json` |
  </Accordion>

  <Accordion title="Request query parameters">
    | Name    | Description                                                                                                                                                    | Example |
    | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
    | `force` | If false, the import will fail if an existing template was removed as a result of this import. Redo the import with this flag set to true if this is intended. |         |
    | `name`  | A name to identify the import in logs                                                                                                                          |         |
  </Accordion>

  <Accordion title="Request body example">
    ```json title="application/json" theme={null}
    {
      "lightTemplate" : {
        "products" : {
          "first" : {
            "fields" : [ "brand", "title", "link", "sellingPrice", "listPrice", "inStock", "custom.material" ],
            "variants" : {
              "all" : {
                "fields" : [ "label", "inStock", "sellingPrice", "listPrice", "custom.campaign" ]
              }
            }
          },
          "rest" : {
            "fields" : [ "link", "swatch" ],
            "maxVariants" : 0
          }
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="Request body schema">
    #### TemplateBody

    Template definitions for response object customization. Template Ids must be alphanumeric and up to 25 characters.
    Keys following pattern: `[a-zA-Z0-9]{1,25}` and with the value: [TemplateSettings](#templatesettings)
    Max: 5 keys
  </Accordion>

  <Accordion title="Example request">
    ```bash title="bash" theme={null}
    curl -i \
    -X PUT \
    -H 'Api-Key: 123456789..' \
    -H 'Content-Encoding: null' \
    -H 'Content-Type: null' \
    "https://{cluster-id}.elevate-api.cloud/api/admin/v4/import/templates?force=force&name=name" \
    -T request-body.file
    ```
  </Accordion>
</AccordionGroup>

### Response

<AccordionGroup>
  <Accordion title="Response codes">
    | Status | Description                                                                                                                                                                             |
    | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `204`  | The import file was valid.                                                                                                                                                              |
    | `403`  | Incorrect cluster credentials.                                                                                                                                                          |
    | `404`  | Cluster not found.                                                                                                                                                                      |
    | `409`  | An import is currently in progress.                                                                                                                                                     |
    | `500`  | Server error such as cluster unavailable or busy. If 5xx errors persist, contact <a href="mailto:support@voyado.com">support</a> and attach any information found in the response body. |
  </Accordion>
</AccordionGroup>

## POST

An import of templates for response object customization, used with the query parameter 'templateId'. Using POST to add or remove templates will not affect templates not included in the import.

```http theme={null}
POST https://{cluster-id}.elevate-api.cloud/api/admin/v4/import/templates
```

### Request

<AccordionGroup>
  <Accordion title="Request header parameters">
    | Name                 | Description                                                                                                                                                                                                                                  | Example            |
    | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
    | `Api-Key`\*          | API key supplied during onboarding.                                                                                                                                                                                                          | `123456789..`      |
    | `Content-Encoding`\* | Content should be gzip encoded for all production requests. For manual test purposes, uncompressed small bodies may be provided using query parameter 'bypass-compression-for-manual-test=true' and omitted Content-Encoding (or 'identity') | `gzip`             |
    | `Content-Type`       | application/json                                                                                                                                                                                                                             | `application/json` |
  </Accordion>

  <Accordion title="Request query parameters">
    | Name   | Description                           | Example |
    | ------ | ------------------------------------- | ------- |
    | `name` | A name to identify the import in logs |         |
  </Accordion>

  <Accordion title="Request body example">
    ```json title="application/json" theme={null}
    {
      "edit" : {
        "lightTemplate" : {
          "products" : {
            "first" : {
              "fields" : [ "brand", "title", "link", "sellingPrice", "listPrice", "inStock" ],
              "variants" : {
                "all" : {
                  "fields" : [ "label", "inStock", "sellingPrice", "listPrice" ]
                }
              }
            },
            "rest" : {
              "fields" : [ "link", "swatch" ],
              "maxVariants" : 0
            }
          }
        }
      },
      "remove" : [ "oldTemplate" ]
    }
    ```
  </Accordion>

  <Accordion title="Request body schema">
    #### TemplatePostBody

    | Name   | Type                                             | Description                                                                                                                                                                                                                                                                                                                                                                                  |
    | ------ | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | edit   | \<string, [TemplateSettings](#templatesettings)> | Template definitions for response object customization. Template IDs must be alphanumeric and up to 25 characters.<br /><br />Examples: `{"lightTemplate":{"products":{"first":{"fields":["brand","title","link","sellingPrice","listPrice","inStock"],"variants":{"all":{"fields":["label","inStock","sellingPrice","listPrice"]}}},"rest":{"fields":["link","swatch"],"maxVariants":0}}}}` |
    | remove | string\[]                                        | IDs of templates to remove.<br /><br />Examples: `"oldTemplate"`                                                                                                                                                                                                                                                                                                                             |
  </Accordion>

  <Accordion title="Example request">
    ```bash title="bash" theme={null}
    curl -i \
    -X POST \
    -H 'Api-Key: 123456789..' \
    -H 'Content-Encoding: null' \
    -H 'Content-Type: null' \
    "https://{cluster-id}.elevate-api.cloud/api/admin/v4/import/templates?name=name" \
    -T request-body.file
    ```
  </Accordion>
</AccordionGroup>

### Response

<AccordionGroup>
  <Accordion title="Response codes">
    | Status | Description                                                                                                                                                                             |
    | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `204`  | The import file was valid.                                                                                                                                                              |
    | `403`  | Incorrect cluster credentials.                                                                                                                                                          |
    | `404`  | Cluster not found.                                                                                                                                                                      |
    | `409`  | An import is currently in progress.                                                                                                                                                     |
    | `500`  | Server error such as cluster unavailable or busy. If 5xx errors persist, contact <a href="mailto:support@voyado.com">support</a> and attach any information found in the response body. |
  </Accordion>
</AccordionGroup>

## Inner Schemas

### ProductTemplate

| Name        | Type                                              | Description                                                                                                                                                                          |
| ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| fields\*    | string\[]                                         | The product level attributes to include. Custom attributes can be included by prefixing them with `custom.`, or the special `custom.*` can be used to include all custom attributes. |
| maxVariants | integer                                           | The max number of variants to include. If not specified, all variants will be included. Min: `0`.<br /><br />Examples: `0`                                                           |
| variants    | [VariantTemplateMapping](#varianttemplatemapping) | The definition of the product's variants for either `all` or the `first` and `rest` of the variants. Required unless maxVariants is not set to 0.                                    |

### ProductTemplateMapping

| Name  | Type                                | Description                                                             |
| ----- | ----------------------------------- | ----------------------------------------------------------------------- |
| all   | [ProductTemplate](#producttemplate) | All products/variants. Only if first and rest are not used.             |
| first | [ProductTemplate](#producttemplate) | The first product/variant in the list.                                  |
| rest  | [ProductTemplate](#producttemplate) | The remaining products/variants in the list. Required if first is used. |

### TemplateSettings

| Name       | Type                                              | Description                                                                                        |
| ---------- | ------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| products\* | [ProductTemplateMapping](#producttemplatemapping) | The definition of the group's products for either `all` or the `first` and `rest` of the products. |

### VariantTemplate

| Name     | Type      | Description                                                                                                                                                                          |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| fields\* | string\[] | The variant level attributes to include. Custom attributes can be included by prefixing them with `custom.`, or the special `custom.*` can be used to include all custom attributes. |

### VariantTemplateMapping

| Name  | Type                                | Description                                                             |
| ----- | ----------------------------------- | ----------------------------------------------------------------------- |
| all   | [VariantTemplate](#varianttemplate) | All products/variants. Only if first and rest are not used.             |
| first | [VariantTemplate](#varianttemplate) | The first product/variant in the list.                                  |
| rest  | [VariantTemplate](#varianttemplate) | The remaining products/variants in the list. Required if first is used. |
