Skip to content

Update Variant Attribute
Beta

Request

Changes an attribute of the Variant definition, the tenant's own or the platform's. A patch: every field left out, or sent as null, is one the attribute keeps.

Request Body

The body is the change. Its type is the kind the attribute ends up as — the one it has, or the one it is converted into — with the same fields as on create: a short text attribute renamed is sent with "type": "shortText". A list sent replaces the whole list; an empty linkingPattern clears the pattern.

Every attribute takes title, isFormReadonly, titleTranslations (the whole set) and deleteExistingValues, which empties every variant's value whatever else the request changes.

attributeSet chooses the Variant form the change is made from: its id names the attribute set (left out, the default Variant form), and addToEveryAttributeSet places the attribute on every Variant form that does not show it yet.

A member the type does not declare is refused with a 400, and the attribute is left as it was: pageTitle and fieldSize, which only a create takes — the place on the form is changed through the form layout route —, and the members the get attribute route writes back, such as identifier or kind.

Changing the type

Sending another type converts the attribute; only the tenant's own attributes can be converted. What each item keeps depends on the type the attribute ends up as. A value that cannot be carried across is emptied, never shortened nor coerced; "deleteExistingValues": true empties every value instead.

Converted intoWhat each item keeps
shortText, longText, urlText as it is, emptied when longer than the type holds; a number as it reads (12.5); a boolean as 1 or 0; a date as the item stores it, 2026-01-01 10:00:00 (no T, no offset); a checklist as its options and a linkItems as its references, separated by commas; a table as its text, when it fits. An imagePack and a file keep nothing.
numberA value that reads as a number as a whole; a boolean as 1 or 0. Anything else is emptied, and so is every date, table, imagePack and file.
booleanYes when the whole value is a word read as yes (1, y, yes, si, ok, true…), no otherwise; a number is yes only when it is 1. Every date, table, imagePack and file is emptied.
dateA value that reads as a date as a whole. Anything else is emptied, and so is every number, boolean, table, imagePack and file.
checklistText as it is, emptied when longer than it holds, each comma separating one option from the next (Rojo, Azul is tagged with Rojo and Azul); a number as it reads (12.5); a boolean as 1 or 0; a date as text; a linkItems with each reference as an option. Every table, imagePack and file is emptied.
tableA value that is already a grid, as an item stores one. Anything else is emptied.
linkItemsText as it is, emptied when longer than it holds, each stretch between commas read as one reference; a checklist with each option as a reference; a number as it reads (12.5). Every boolean, date, table, imagePack and file is emptied.
imagePack, fileA value naming, separated by commas, only images — or files — the tenant's library already has, no more than the plan allows per item. Anything else is emptied whole, and so is every linkItems, number, boolean, date, table and the other of the two.

Response

200 OK — the attribute as it now stands, under value.

Example

PATCH /Metadata/Variants/attributes('frmt_strapcolour') HTTP/1.1
X-API-KEY: your-api-key-here
Content-Type: application/json
            
{ "type": "shortText", "title": "Band colour" }
Path
attributeIdstringrequired

The identifier of the attribute to change

Headers
X-API-KEYstring

Tenant's API key (required)

Bodyapplication/json

The change to make

One of:

"type": "shortText"

typestringrequired
Value:"shortText"
Discriminator
titlestring or null

The new title. The identifier never follows it.

isFormReadonlyboolean or null
titleTranslationsArray of objects or null(TranslationInput)

What it is called in the tenant's other languages — the whole set, replacing the one it has: a language left out is one it ends up with no title in.

deleteExistingValuesboolean

Whether every item's value is emptied, whatever else the request changes. Left out, each value is carried across a change of type or of localization where the new shape can hold it.

attributeSetobject(AttributeSetPlacementInput)

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

isLocalizedboolean or null
curl -i -X PATCH \
  'https://api2.saleslayer.com/catalog/Metadata/Variants/attributes('\''{attributeId}'\'')' \
  -H 'Content-Type: application/json' \
  -H 'X-API-KEY: string' \
  -d '{
    "type": "shortText",
    "title": "Remarks",
    "attributeSet": {
      "id": 7,
      "addToEveryAttributeSet": true
    }
  }'

Responses

OK

Bodyapplication/json
@etagstring or null
@contextstring or null
valueany or null
Response
{ "value": { "identifier": "frmt_notes", "title": "Remarks", "attributeType": "shortText", "isLocalized": false, "isFormReadonly": false, "kind": "custom", "isRequired": false, "isFormRequired": false, "titleTranslations": [] }, "@readLink": "https://api2.saleslayer.com/catalog/Metadata/Variants/attributes('frmt_notes')", "@editLink": "https://api2.saleslayer.com/catalog/Metadata/Variants/attributes('frmt_notes')" }