Create a product attribute
Create a new product attribute.
Upon successful creation, a 201 CREATED status code is returned and product attribute can be found in response body.
| Field | Mandatory | Description | Applies to | Example |
|---|---|---|---|---|
| name | YES | product attribute friendly name | ALL | "name": "In stock" |
| type_class | YES | product attribute type (see available types at the begining of this section) | ALL | "type_class": "BooleanAttribute" |
| description | product attribute description | ALL | "description": "this attribute is used to indicate when a proudct is in stock or not" | |
| product_families * (extra information given right under this table) | list of product families that will contain the new attribute. It's also possible to indicate at what level of the family the attribute will be placed | ALL | "product_families": [{"id": "6422dd98d732cac61a58431e", "attribute_level": "parent_level"}, {"id": "6422dd98d732cac61a58431f", "attribute_level": "variant_level"}] | |
| options | array of available options | MultiselectAttribute, DropdownAttribute | "options": ["red", "blue", "white"] | |
| manual_sorting | Boolean. When true, options will respect options array order, when false options will be sorted alphabetically using english rules. Default value is manual_sorting = true | MultiselectAttribute, DropdownAttribute | "manual_sorting": false | |
| sort_ascending | Boolean. Options values will be sorted in ascending (true) or descending (false) order. Default value is sort_ascending = true. If manual_sorting = true this option has no effect | MultiselectAttribute, DropdownAttribute | "manual_sorting": false | |
| attributes | array of attributes related to a completeness attribute | CompletenessAttribute | [ {"id": null, "label": "sku"} , {"id": "...", "label": "in_stock"} ] |
product_families field
This field is a list of dictionaries. These dictionaries must follow the following fields
| field | mandatory | description |
|---|---|---|
| id | yes | id of the Product Family that the attribute is going to belong to. |
| attribute_level | no | To indicate whether the attributes will not be inherited ("no_level"), inherited from level 1 ("parent_level") or from level 2 ("variant_level"). Default: "no_level". |
The "parent_level" and "variant_level" options are available only when automatic inheritance is active on the account. Contact your account manager for more information.
Example
More examples can be found in example requests
1.- Create new True/ False (Boolean) attribute named "In Stock"
{ "name":"In Stock", "type_class":"BooleanAttribute"}Response
{ "data": [ { "id": "5d0b4ea525abd700016fc037", "label": "in_stock", "name": "In Stock", "groups": [], "type_class": "BooleanAttribute" } ]}Authorization
bearerAuth Obtain a token via POST /auth/api/get-token (15 minute lifetime), then send it as Authorization: Bearer <token>.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
curl -X POST 'https://example.com/api/v1/attributes/product' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "In Stock", "type_class": "BooleanAttribute", "description": "this attribute is used to indicate when a producto is in stock or not"}'{ "data": [ { "id": "5d0b4ea525abd700016fc037", "label": "in_stock", "name": "In Stock", "groups": [], "type_class": "BooleanAttribute" } ]}