Skip to content

Create Category Attribute
Beta

Request

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.

Request Body

The body is the attribute. Its type says which kind it is, and which fields it takes beyond the ones every attribute has:

typeFields
shortText, longText, number, boolean, url, dateisLocalized
tableisLocalized, templates
checklistisSingleSelect, options (at least one)
imagePackisLocalized, requiredVariants, additionalVariants, linkingPattern
fileisLocalized, linkingPattern
linkItemstargetEntityIdentifier (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.

Response

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.

Example

POST /Metadata/Categories/attributes HTTP/1.1
X-API-KEY: your-api-key-here
Content-Type: application/json
            
{ "type": "shortText", "title": "Box material" }
Headers
X-API-KEYstring

Tenant's API key (required)

Bodyapplication/json

The attribute to create

One of:

"type": "shortText"

typestringrequired
Value:"shortText"
Discriminator
titlestring or null

Mandatory. The attribute's title in the tenant's default language; its identifier is derived from it.

isFormReadonlyboolean

Whether the form renders it read-only. It stays writable through the write operations.

pageTitlestring or null

The page of the form it is placed on, by title. Left out, the last page.

fieldSizestring or null

How wide its field is on that page. Left out, a full row.

Enum:"quarter""half""threeQuarters""row"
titleTranslationsArray of objects or null(TranslationInput)

What it is called in the tenant's other languages.

attributeSetobject(AttributeSetPlacementInput)

Which form of an entity with one per attribute set (Products, Variants) a request is made from.

isLocalizedboolean

Whether it holds one value per language. Only accepted for a type that can.

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"
  }'

Responses

Created

Bodyapplication/json
@etagstring or null
@contextstring or null
valueany or null
Response
{ "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')" }