Custom attributes in OCAPI request and response documents
Key Takeaway
In OCAPI, each custom attribute appears directly in request and response documents as its own property with the c_ prefix. A request can set a c_ property only when the client's write_attributes allows it. HTML and Image properties can be read but not set.
Business objects in B2C Commerce, such as products, baskets, orders and customers, can carry custom attributes beside their standard ones. In OCAPI documents, each of these appears as a custom property whose name starts with c_. The Shop API and the Data API let an external system read custom properties in response documents and set them in request documents. An integration that exchanges custom data depends on four things: the c_ naming, the supported value types and documents, the client's read and write permissions, and the hooks that add custom properties.
How custom properties look in documents
OCAPI lets you set custom properties of business objects in request documents and read them in response documents. Both the Shop API and the Data API support custom properties.
Every custom property name starts with the prefix c_. Because of the prefix, custom properties have their own namespace, so a custom property name stays separate from the standard property names. A custom property sits directly in the document as a property of its own, alongside the standard properties.
GET /dw/shop/v24_5/products/creative-zen-v
{
...
"c_mediaFormat" : ["0010", "0020", "0030", "0040"],
"c_memorySize" : "1GB",
"c_tabDescription" : "The ZEN V player was designed...",
...
}The Shop API response for the product creative-zen-v holds three custom properties directly in the product document. c_memorySize comes back as a single string value. c_mediaFormat comes back as a JSON array of strings.