# Push Predefined values

By
The Quable Team
Published 2023-09-10

What are predefined values?
Why pushing predefined values first?
Available endpoints overview
Get predefined values from a specific attribute
Create a predefined value
Modify an existing predefined value
Delete an existing predefined value



# What are predefined values?

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

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.


# 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:
GET /api/predefined-values?attribute.id=collection

Get a specific predefined value, if it already exists:
GET /api/predefined-values/attribute=collection;code=Summer28

Create a new predefined value, if it does not exist already:
POST /api/predefined-values

Update an existing predefined value:
PUT /api/predefined-values/attribute=collection;code=Summer28

Delete an existing predefined-value:
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").

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 HTTP 200 code .
The ressources will be available in a table named hydra:member.

{
    "@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:

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 HTTP 201 code .

{
    "@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:

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 HTTP 201 code .

{
    "@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:

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 HTTP 204 code and the response body will be empty.

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