> ## 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.

# Product Sets

> An import of product sets.

## PUT

An import of product sets. **Importing product sets using a PUT request will remove all existing product sets not present in the import file!**

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

### 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 product set was removed as a result of this import. Redo the import with this flag set to true if this was intended |         |
    | `name`  | A name to identify the import in logs                                                                                                                             |         |
  </Accordion>

  <Accordion title="Request body example">
    ```json title="application/json" theme={null}
    {
      "WINTER" : {
        "name" : "Winter sale",
        "rule" : "rule incl custom.season { \"winter\" }"
      },
      "STRIPED" : {
        "name" : "All striped items",
        "rule" : "rule incl pattern { \"striped\" }"
      }
    }
    ```
  </Accordion>

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

    Product set definitions.
    Keys following pattern: `[\p{L}\p{N}_\-()<>.:,&+%\[\]|?#�​']{1,200}` and with the value: [ProductSet](#productset)
    Max: 1000 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/product-sets?force=force&name=name" \
    -T request-body.file
    ```
  </Accordion>
</AccordionGroup>

### Response

<AccordionGroup>
  <Accordion title="Response codes">
    | Status | Description                                                                                                                                                                             |
    | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `204`  | The import file was valid and imported into Elevate.                                                                                                                                    |
    | `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 product sets. Using POST to add or remove product sets will not affect product sets not included in the import.

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

### 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 any product set currently referenced by a page will be removed as a result of this import. Redo the import with this flag set to true if this was intended. |         |
    | `name`  | A name to identify the import in logs                                                                                                                                                         |         |
  </Accordion>

  <Accordion title="Request body example">
    ```json title="application/json" theme={null}
    {
      "edit" : {
        "WINTER" : {
          "name" : "Winter specials",
          "rule" : "rule incl custom.season { \"winter\" }"
        }
      },
      "remove" : [ "TEST_PRODUCT_SET_1" ]
    }
    ```
  </Accordion>

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

    | Name   | Type                                 | Description                                                                                                                                                                                                                                                                 |
    | ------ | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | edit   | \<string, [ProductSet](#productset)> | A mapping from product set id to product set definition. Can be used to add new or edit existing product sets. Product sets not included will not be affected.<br /><br />Examples: `{"WINTER":{"name":"Winter specials","rule":"rule incl custom.season { \"winter\" }"}}` |
    | remove | string\[]                            | The ids of product sets to be removed.<br /><br />Examples: `"TEST_PRODUCT_SET_1"`                                                                                                                                                                                          |
  </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/product-sets?force=force&name=name" \
    -T request-body.file
    ```
  </Accordion>
</AccordionGroup>

### Response

<AccordionGroup>
  <Accordion title="Response codes">
    | Status | Description                                                                                                                                                                             |
    | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `204`  | The import file was valid and imported into Elevate.                                                                                                                                    |
    | `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

### ProductSet

| Name   | Type   | Description                                                                                           |
| ------ | ------ | ----------------------------------------------------------------------------------------------------- |
| name\* | string | The name of the product set, displayed in the Elevate application. Min length: `1`. Max length: `80`. |
| rules  | string | A product rule expression restricting the products that the product set may contain.                  |
