- Create Category Attribute
Adds a custom attribute to the Category definition and places it on the category form. The attribute's identifier is derived from its title and reported back.
The body is the attribute. Its type says which kind it is, and which fields it takes beyond the ones every attribute has:
type | Fields |
|---|---|
shortText, longText, number, boolean, url, date | isLocalized |
table | isLocalized, templates |
checklist | isSingleSelect, options (at least one) |
imagePack | isLocalized, requiredVariants, additionalVariants, linkingPattern |
file | isLocalized, linkingPattern |
linkItems | targetEntityIdentifier (mandatory), itemLimit, pickerDisplayAttributes, labelAttributes |
Every attribute takes title (mandatory), isFormReadonly, titleTranslations, and where it goes on the form: pageTitle (left out, the last page) and fieldSize (quarter, half, threeQuarters or row; left out, row). attributeSet is for Products and Variants only: Categories refuse it.
A member the type does not declare — one of another type, deleteExistingValues, which only an update takes, or isLocalized on a checklist or a linkItems, which hold a single value shared by every language — is refused with a 400, and nothing is created.
201 Created — the attribute as created, under value.
409 Conflict — the request is well formed, but the tenant's plan does not allow it: a title in a language other than the default when the plan carries no multi-language field titles, a linkingPattern when it carries no automatic linking, or an image or file attribute, or image size variants, beyond the plan's allowance. Nothing is created.
POST /Metadata/Categories/attributes HTTP/1.1
X-API-KEY: your-api-key-here
Content-Type: application/json
{ "type": "shortText", "title": "Box material" }The attribute to create
"type": "shortText"
Mandatory. The attribute's title in the tenant's default language; its identifier is derived from it.
Whether the form renders it read-only. It stays writable through the write operations.
How wide its field is on that page. Left out, a full row.
What it is called in the tenant's other languages.
Which form of an entity with one per attribute set (Products, Variants) a request is made from.
- Sales Layer Catalog APIhttps://api2.saleslayer.com/catalog/Metadata/Categories/attributes
curl -i -X POST \
https://api2.saleslayer.com/catalog/Metadata/Categories/attributes \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: string' \
-d '{
"type": "shortText",
"title": "Box material"
}'{ "value": { "identifier": "cat_boxmaterial", "title": "Box material", "attributeType": "shortText", "isLocalized": false, "isFormReadonly": false, "kind": "custom", "isRequired": false, "isFormRequired": false, "titleTranslations": [] }, "@readLink": "https://api2.saleslayer.com/catalog/Metadata/Categories/attributes('cat_boxmaterial')", "@editLink": "https://api2.saleslayer.com/catalog/Metadata/Categories/attributes('cat_boxmaterial')" }