# Push Predefined values

---

[What are predefined values?](#what-are-predefined-values)
[Why pushing predefined values first?](#why-pushing-predefined-values-first)
[Available endpoints overview](#available-endpoints-overview)
[Get predefined values from a specific attribute](#get-predefined-values-from-a-specific-attribute)
[Create a predefined value](#create-a-predefined-value)
[Modify an existing predefined value](#modify-an-existing-predefined-value)
[Delete an existing predefined value](#delete-an-existing-predefined-value)

---

!!!warning
Pushing predefined values works the same way for **documents** and for **assets**. You can refer to the process below to import both. Importing predefined values is optional and only applies if your ERP contains attributes with predefined values for documents and/or for assets.
!!!

---

## What are predefined values?

Predefined values are the values used to fill an attribute in your PIM or product database.

!!!primary Example
For instance in retail, "Occasion" would be an attribute, that has "Sport" and "Party" as predefined values.
!!!

The predefined values depend on your industry. They help enrich the product description and impact filtering.

---

## Why pushing predefined values first?

In order to import the document object (the product sheet), the **collection** attribute's predefined values must already be available in Quable PIM. Therefore, the values must be imported **before** the document object.

!!!primary
This constraint only applies to simple-list or multiple-choice list attributes that require predefined values.
!!!

---

## Available endpoints overview

Let's say your ERP has an attribute "Collection" for which you want two predefined values: "Summer28" and "Summer29".
Below are the available endpoints to add, get or edit predefined values:

**Gather all the available predefined values for this specific attribute:**
[!badge variant="primary" text="GET"] /api/predefined-values?attribute.id=_collection_

**Get a specific predefined value, if it already exists:**
[!badge variant="primary" text="GET"] /api/predefined-values/attribute=_collection_;code=_Summer28_

**Create a new predefined value, if it does not exist already:**
[!badge variant="secondary" text="POST"] /api/predefined-values

**Update an existing predefined value:**
[!badge variant="warning" text="PUT"] /api/predefined-values/attribute=_collection_;code=_Summer28_

**Delete an existing predefined-value:**
[!badge variant="danger" text="DELETE"] /api/predefined-values/attribute=_collection_;code=_Summer28_

---

## Get predefined values from a specific attribute

Here is how to get predefined values from a specific attribute (here, the attribute is named "collection").

```shell
curl --location --globoff --request GET 'https://{{instance}}.quable.com/api/predefined-values?attribute.id[]=collection' \
--header 'Authorization: Bearer _api-token_'
```

In case of success, the response will be an [!badge variant="success" text="HTTP 200 code"] .
The ressources will be available in a table named <hydra:member>.

==- Response
```json
{
    "@context": "/api/contexts/PredefinedValue",
    "@id": "/api/predefined-values",
    "@type": "hydra:Collection",
    "hydra:member": [
        {
            "@type": "PredefinedValue",
            "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_beach",
            "legacyId": 328,
            "attribute": {
                "@type": "attributes",
                "@id": "/api/attributes/cr_occasion",
                "id": "cr_occasion"
            },
            "name": {
                "en_GB": "Beach",
                "en_US": "Beach",
                "fr_FR": "Plage"
            },
            "description": [],
            "dateCreated": "2021-08-06T13:37:06+00:00",
            "dateModified": "2021-08-06T13:37:06+00:00",
            "id": "attribute=cr_occasion;code=cr_beach"
        },
        {
            "@type": "PredefinedValue",
            "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_ceremony",
            "legacyId": 326,
            "attribute": {
                "@type": "attributes",
                "@id": "/api/attributes/cr_occasion",
                "id": "cr_occasion"
            },
            "name": {
                "en_GB": "Ceremony",
                "en_US": "Ceremony",
                "fr_FR": "Cérémonie"
            },
            "description": [],
            "dateCreated": "2021-08-06T13:37:06+00:00",
            "dateModified": "2021-08-06T13:37:06+00:00",
            "id": "attribute=cr_occasion;code=cr_ceremony"
        },
        {
            "@type": "PredefinedValue",
            "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_evening",
            "legacyId": 325,
            "attribute": {
                "@type": "attributes",
                "@id": "/api/attributes/cr_occasion",
                "id": "cr_occasion"
            },
            "name": {
                "en_GB": "Evening",
                "en_US": "Evening",
                "fr_FR": "Soirée"
            },
            "description": [],
            "dateCreated": "2021-08-06T13:37:06+00:00",
            "dateModified": "2021-08-06T13:37:06+00:00",
            "id": "attribute=cr_occasion;code=cr_evening"
        },
        {
            "@type": "PredefinedValue",
            "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_sport",
            "legacyId": 471,
            "attribute": {
                "@type": "attributes",
                "@id": "/api/attributes/cr_occasion",
                "id": "cr_occasion"
            },
            "name": {
                "en_US": "Sport",
                "fr_FR": "Sport"
            },
            "description": [],
            "dateCreated": "2023-08-23T07:20:43+00:00",
            "dateModified": "2023-08-23T07:20:43+00:00",
            "id": "attribute=cr_occasion;code=cr_sport"
        },
        {
            "@type": "PredefinedValue",
            "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_summer",
            "legacyId": 324,
            "attribute": {
                "@type": "attributes",
                "@id": "/api/attributes/cr_occasion",
                "id": "cr_occasion"
            },
            "name": {
                "en_GB": "Summer",
                "en_US": "Summer",
                "fr_FR": "Eté"
            },
            "description": [],
            "dateCreated": "2021-08-06T13:37:06+00:00",
            "dateModified": "2021-08-06T13:37:06+00:00",
            "id": "attribute=cr_occasion;code=cr_summer"
        },
        {
            "@type": "PredefinedValue",
            "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_swim",
            "legacyId": 473,
            "attribute": {
                "@type": "attributes",
                "@id": "/api/attributes/cr_occasion",
                "id": "cr_occasion"
            },
            "name": {
                "en_US": "Swim wear",
                "fr_FR": "Natation"
            },
            "description": [],
            "dateCreated": "2023-09-18T09:21:08+00:00",
            "dateModified": "2023-09-18T09:21:08+00:00",
            "id": "attribute=cr_occasion;code=cr_swim"
        },
        {
            "@type": "PredefinedValue",
            "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_work",
            "legacyId": 327,
            "attribute": {
                "@type": "attributes",
                "@id": "/api/attributes/cr_occasion",
                "id": "cr_occasion"
            },
            "name": {
                "en_GB": "Work",
                "en_US": "Work",
                "fr_FR": "Travail"
            },
            "description": [],
            "dateCreated": "2021-08-06T13:37:06+00:00",
            "dateModified": "2021-08-06T13:37:06+00:00",
            "id": "attribute=cr_occasion;code=cr_work"
        }
    ],
    "hydra:totalItems": 7,
    "hydra:view": {
        "@id": "/api/predefined-values?attribute.id%5B%5D=cr_occasion",
        "@type": "hydra:PartialCollectionView"
    },
    "hydra:search": {
        "@type": "hydra:IriTemplate",
        "hydra:template": "/api/predefined-values{?search,attribute.id,attribute.id[]}",
        "hydra:variableRepresentation": "BasicRepresentation",
        "hydra:mapping": [
            {
                "@type": "IriTemplateMapping",
                "variable": "search",
                "property": "search",
                "required": false
            },
            {
                "@type": "IriTemplateMapping",
                "variable": "attribute.id",
                "property": "attribute.code",
                "required": false
            },
            {
                "@type": "IriTemplateMapping",
                "variable": "attribute.id[]",
                "property": "attribute.code",
                "required": false
            }
        ]
    }
}
```
===

Visit the API reference documentation for more details (coming soon).

---

## Create a predefined value

Here is how:

```shell
curl --location --request POST 'https://{{instance}}.quable.com//api/predefined-values' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer _api-token_'
--data '{
    "id": "cr-swim",
    "attribute": {
        "id": "cr-occasion"
    },
    "description": {
        "fr_FR": "Tenues de natation",
        "en_US": "Swim wear"
    },
    "name": {
        "fr_FR": "Natation",
        "en_US": "Swim wear"
    }
}'
```

In case of success, the response will be an [!badge variant="success" text="HTTP 201 code"].

==- Response
```json
{
    "@context": {
        "@vocab": "https://education-developers.quable.com/api/docs.jsonld#",
        "hydra": "http://www.w3.org/ns/hydra/core#",
        "legacyId": "PredefinedValueOutput/legacyId",
        "attribute": "PredefinedValueOutput/attribute",
        "name": "PredefinedValueOutput/name",
        "description": "PredefinedValueOutput/description",
        "dateCreated": "PredefinedValueOutput/dateCreated",
        "dateModified": "PredefinedValueOutput/dateModified"
    },
    "@type": "PredefinedValue",
    "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_swim",
    "legacyId": 473,
    "attribute": {
        "@context": {
            "@vocab": "https://education-developers.quable.com/api/docs.jsonld#",
            "hydra": "http://www.w3.org/ns/hydra/core#",
            "type": "EavAttributeOutput/type",
            "helpText": "EavAttributeOutput/helpText",
            "isVisible": "EavAttributeOutput/isVisible",
            "isEditable": "EavAttributeOutput/isEditable",
            "isFilterable": "EavAttributeOutput/isFilterable",
            "isPrimary": "EavAttributeOutput/isPrimary",
            "isRequired": "EavAttributeOutput/isRequired",
            "attributeSets": "EavAttributeOutput/attributeSets",
            "options": "EavAttributeOutput/options",
            "dateCreated": "EavAttributeOutput/dateCreated",
            "dateModified": "EavAttributeOutput/dateModified",
            "attributeGroup": "EavAttributeOutput/attributeGroup",
            "documentType": "EavAttributeOutput/documentType",
            "description": "EavAttributeOutput/description",
            "name": "EavAttributeOutput/name",
            "documentTypeCode": "EavAttributeOutput/documentTypeCode",
            "legacyId": "EavAttributeOutput/legacyId",
            "visible": "EavAttributeOutput/visible",
            "editable": "EavAttributeOutput/editable",
            "filterable": "EavAttributeOutput/filterable",
            "primary": "EavAttributeOutput/primary",
            "required": "EavAttributeOutput/required"
        },
        "@type": "attributes",
        "@id": "/api/attributes/cr_occasion",
        "id": "cr_occasion"
    },
    "name": {
        "en_US": "Swim wear",
        "fr_FR": "Natation"
    },
    "description": [],
    "dateCreated": "2023-09-18T09:21:08+00:00",
    "dateModified": "2023-09-18T09:21:08+00:00",
    "id": "attribute=cr_occasion;code=cr_swim"
}
```
===

Visit the API reference documentation for more details (coming soon).

---

## Modify an existing predefined value

Here is how:

```shell
curl --location --request PUT 'https://{{instance}}.quable.com//api/predefined-values/attribute=cr_occasion;code=cr_sport'\
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer _api-token_'
--data '{
    "id": "cr_sport",
    "attribute": {
        "id": "cr_occasion"
    },
    "name": {
        "fr_FR": "Equipement de sport",
        "en_US": "Sports gears"
    }
}'
```

In case of success, the response will be an [!badge variant="success" text="HTTP 201 code"].

==- Response
```json
{
    "@context": {
        "@vocab": "https://education-developers.quable.com/api/docs.jsonld#",
        "hydra": "http://www.w3.org/ns/hydra/core#",
        "legacyId": "PredefinedValueOutput/legacyId",
        "attribute": "PredefinedValueOutput/attribute",
        "name": "PredefinedValueOutput/name",
        "description": "PredefinedValueOutput/description",
        "dateCreated": "PredefinedValueOutput/dateCreated",
        "dateModified": "PredefinedValueOutput/dateModified"
    },
    "@type": "PredefinedValue",
    "@id": "/api/predefined-values/attribute=cr_occasion;id=cr_sport",
    "legacyId": 471,
    "attribute": {
        "@context": {
            "@vocab": "https://education-developers.quable.com/api/docs.jsonld#",
            "hydra": "http://www.w3.org/ns/hydra/core#",
            "type": "EavAttributeOutput/type",
            "helpText": "EavAttributeOutput/helpText",
            "isVisible": "EavAttributeOutput/isVisible",
            "isEditable": "EavAttributeOutput/isEditable",
            "isFilterable": "EavAttributeOutput/isFilterable",
            "isPrimary": "EavAttributeOutput/isPrimary",
            "isRequired": "EavAttributeOutput/isRequired",
            "attributeSets": "EavAttributeOutput/attributeSets",
            "options": "EavAttributeOutput/options",
            "dateCreated": "EavAttributeOutput/dateCreated",
            "dateModified": "EavAttributeOutput/dateModified",
            "attributeGroup": "EavAttributeOutput/attributeGroup",
            "documentType": "EavAttributeOutput/documentType",
            "description": "EavAttributeOutput/description",
            "name": "EavAttributeOutput/name",
            "documentTypeCode": "EavAttributeOutput/documentTypeCode",
            "legacyId": "EavAttributeOutput/legacyId",
            "visible": "EavAttributeOutput/visible",
            "editable": "EavAttributeOutput/editable",
            "filterable": "EavAttributeOutput/filterable",
            "primary": "EavAttributeOutput/primary",
            "required": "EavAttributeOutput/required"
        },
        "@type": "attributes",
        "@id": "/api/attributes/cr_occasion",
        "id": "cr_occasion"
    },
    "name": {
        "en_US": "Sports gears",
        "fr_FR": "Equipement de sport"
    },
    "description": [],
    "dateCreated": "2023-08-23T07:20:43+00:00",
    "dateModified": "2023-08-23T07:20:43+00:00",
    "id": "attribute=cr_occasion;code=cr_sport"
}
```
===

Visit the API reference documentation for more details (coming soon).

---

## Delete an existing predefined value

Here is how:

```shell
curl --location --request DELETE 'https://{{instance}}.quable.com/api/predefined-values/attribute=cr_occasion;code=cr_sport' \
--header 'Authorization: Bearer _api-token_'
```

In case of success, the response will be an [!badge variant="success" text="HTTP 204 code"] and the response body will be empty.

Visit the API reference documentation for more details (coming soon).

---
