- Update Variant Attribute
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.
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.
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 into | What each item keeps |
|---|---|
shortText, longText, url | Text 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. |
number | A 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. |
boolean | Yes 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. |
date | A value that reads as a date as a whole. Anything else is emptied, and so is every number, boolean, table, imagePack and file. |
checklist | Text 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. |
table | A value that is already a grid, as an item stores one. Anything else is emptied. |
linkItems | Text 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, file | A 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. |
200 OK — the attribute as it now stands, under value.
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" }The change to make
"type": "shortText"
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.
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.
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/Variants/attributes('{attributeId}')
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
}
}'{ "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')" }