How to add simple attribute to product using Management API
Bluestone PIM has several attribute types that can be added to a product.
Read more about attributes in Bluestone PIM.
All calls to manage product attributes requires product and attribute id. If you don't know it, see how to find a product or attribute.
The more complex attributes have dedicated endpoints for management. Use the dictionary, column and matrix endpoints for that.
URL
POST https://mapi.bluestonepim.com/pim/products/{id}/attributes
Add attribute without value to product
Request body
{
"definitionId": "{attribute id}"
}
Response
If successful, this will result in a 201 - Created response. This means the attribute has been added to the product with an empty value. A value can be added later using an update endpoint.
The request will fail with a 409 - Conflict if the attribute is already added to the product.
Add attribute with value to product
Values can be added using a "values" list property in the request. The expected content of the values list will differ based on the attribute type.
The JSON type should always be string and the endpoint will not fail if the content does not match the attribute type. This is by design, because the PIM must be able to receive data of poor quality. Validation and reports will enable the user to correct it afterwards.
Here is an overview of simple attribute types and an example request body.
Text attribute
{
"definitionId": "{attribute id}",
"values": ["Sample text content"],
}
Integer attribute
{
"definitionId": "{attribute id}",
"values": ["123"],
}
Decimal attribute
{
"definitionId": "{attribute id}",
"values": ["123.0"],
}
Boolean attribute
{
"definitionId": "{attribute id}",
"values": ["true"],
}
Date attribute
{
"definitionId": "{attribute id}",
"values": ["2022-01-01"],
}
Date and time attribute
{
"definitionId": "{attribute id}",
"values": ["2022-01-01 13:37:00"],
}
Multiline attribute
{
"definitionId": "{attribute id}",
"values": ["This is the first line\nThis is the second line"],
}
Formatted text attribute - content type: Markdown
{
"definitionId": "{attribute id}",
"values": ["This _text_ contains **markdown**."],
}
Formatted text attribute - content type: HTML
{
"definitionId": "{attribute id}",
"values": ["<p>This text contains <b>HTML</b>.</p>"],
}
Single select attribute
{
"definitionId": "{attribute id}",
"values": ["5da42f4052faff000c476117"],
}
For the single select attribute, the id of the selected option must be passed. This can be found in the attribute definition.
Multi select attribute
{
"definitionId": "{attribute id}",
"values": ["5db038d4590801000caa534a","5db038d4590801000caa534b"],
}
For a multi select attribute, the id of the selected options must be passed. This can be found in the attribute definition.
Time attribute
{
"definitionId": "{attribute id}",
"values": ["13:37:00"],
}
Regular expression attribute
{
"definitionId": "{attribute id}",
"values": ["Sample text content"],
}
Accepts a text as input. The regular expression is managed in the attribute definition and will only be used to validate the content in PIM UI and sync report.
Compound attribute
Does not accept a value. The compound attribute displays a combination of values from other attributes in the PIM UI and API's.