--- title: Attribute metadata description: Describe a catalog's attributes and their raw values — a display label, a unit, a currency, a colour swatch or an image — without changing the catalog itself. slug: indexing/attribute-metadata docKind: guide hub: luigisbox-ai --- A catalog holds raw attributes and raw values: `material`, `Stainless steel`, `EUR`. Attribute metadata is what you put beside them so a storefront can present them — a display label, a unit of measure, a currency code, a colour swatch, an image. It is stored next to the catalog rather than in it, so describing an attribute never needs a re-ingest and survives the next feed run. Metadata belongs to one object type of the catalog. `title` on `product` and `title` on `category` are different attributes, described separately, and every endpoint below names the object type in its path: 1–64 characters with no `/`, `:` or whitespace, anything else being a `422`. Every endpoint below needs a token for the `https://api..luigisbox.ai/catalog` audience. Reading needs a grant to read the catalog's metadata; writing needs a grant to write it, held per catalog. ## Setting metadata One `PATCH` describes any number of attributes and values at once. ```bash curl -X PATCH 'https://api.eu1.luigisbox.ai/catalog/v1/lbc_8w3k2p/types/product/attribute-metadata' \ -H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ -d '{ "items": [ { "attribute_name": "material", "version": 41, "metadata": { "label": "Material" }, "values": { "Stainless steel": { "metadata": { "label": "Steel", "color": "#C0C0C0" } } } }, { "attribute_name": "size", "version": null, "metadata": { "label": "Size", "unit": "cm" } } ] }' ``` The response is every attribute the request named that holds metadata afterwards, exactly as [reading it back](#reading-it-back) returns it: ```json { "items": [ { "attribute_name": "material", "metadata": { "label": "Material" }, "values": { "Aluminium": { "metadata": { "label": "Alu" } }, "Stainless steel": { "metadata": { "label": "Steel", "color": "#C0C0C0" } } }, "value_count": 2, "version": 42 }, { "attribute_name": "size", "metadata": { "label": "Size", "unit": "cm" }, "values": {}, "value_count": 0, "version": 43 } ] } ``` `values` holds every one of the attribute's raw values that carries metadata, in the shape you send them — including values this request did not name, like `Aluminium` above — and `value_count` is how many there are. `version` changes on every change to the attribute — its own metadata or any of its values — and is what you send back to change it. ### Everything merges A `PATCH` changes only what it names, at every level. An attribute, a value or a single key you leave out is untouched, so two systems can describe different attributes of one catalog without overwriting each other. `null` is how you clear something, and what it clears depends on where it sits: | `null` at | Clears | | --- | --- | | a key inside `metadata` | that key | | `metadata` of an attribute | the attribute's own metadata, leaving its values alone | | a value inside `values` | that value's metadata | | `values` of an attribute | every one of its values' metadata | Sending both `"metadata": null` and `"values": null` in one item removes all of the attribute's metadata. An attribute left with nothing stops existing: it disappears from the listing rather than reading back as an empty map. ### Each item names the version it is based on Every item carries `version`: the attribute's current version, which you get from the `version` field of the listing or of a `PATCH` response, or `null` for an attribute that carries no metadata yet — one the listing does not return. An item without it is refused with `422`. Every item applies or none does, so a request never leaves half its attributes changed. If any item's version is not current, nothing is written and the `412` names each stale item by its index in `items`: ```json { "reason": "1 of 2 attributes changed since the version sent; read them again and reapply your change", "exception_details": { "error_code": "entity_version_stale", "stale_items": [{ "index": 1, "current_version": 58 }] }, "request_id": "01JQ8H3Z9K2F7M4N6P8R0S2T4V" } ``` `current_version` is `null` where the attribute no longer carries metadata at all. Read those attributes again — one [`GET`](#reading-it-back) with `attribute_name` repeated for each and `size=100` — reapply your changes and resend the whole request. `"version": null` for an attribute that *does* carry metadata by now is stale in the same way: the `412` tells you what it is at instead of overwriting a description you never read. A stale version is reported before anything is checked against the object type, so a `412` can hide an unknown attribute in the same request; you see that one when you resend. A request that sets or clears nothing — no items, or items naming only an attribute and its version — is refused with `422` and `entity_change_empty`: ```json { "reason": "The request names no field to change", "exception_details": { "error_code": "entity_change_empty" }, "request_id": "01JQ8H3Z9K2F7M4N6P8R0S2T4V" } ``` Each attribute appears in at most one item, since two items would carry two versions of it. A request naming one twice is refused with `request_item_repeated`. ### Keys A key is 1–64 characters. Its value is a string of at most 2048 characters or a finite number within the signed 64-bit range — `true`, objects and arrays are refused. No attribute name, raw value, key or string value may contain a NUL character (`\u0000`). Five keys are format-checked, because a storefront can rely on their shape: | Key | Must be | | --- | --- | | `label` | a non-empty string, at most 2048 characters | | `unit` | a non-empty string, at most 2048 characters | | `currency` | an uppercase ISO 4217 code, e.g. `EUR` | | `color` | a hex colour, `#RGB` or `#RRGGBB`, stored as sent | | `image_url` | an absolute `https` URL of at most 2048 characters, written in its standard form, stored as sent | A value that fails one of these is rejected with `attribute_metadata_value_invalid`. An `image_url` in standard form has a lowercase host, no `:443`, a path of at least `/`, and any character a URL cannot hold, such as a space or a quote, percent-encoded. One written otherwise is refused with the form to send instead, so what you read back is always what you sent: ```json { "loc": ["body", "items", 0, "metadata", "image_url"], "msg": "must be written as https://cdn.example.com/a.png", "type": "attribute_metadata_value_invalid" } ``` ### Limits | Limit | Value | | --- | --- | | Attributes per request | 100 | | Value entries per request | 500 | | Keys per metadata map | 32 | | Bytes per metadata map | 4096 | | Attribute name | 256 characters | | Raw value | 512 characters | | Metadata key | 64 characters | | String metadata value | 2048 characters | | Values carrying metadata, per attribute | 2 000 | | Values carrying metadata, per catalog, across object types | 20 000 | Too many attributes or value entries in one request, or a map sent with more than 32 keys or more than 4096 bytes of content, is refused before anything is stored, with `attribute_metadata_request_too_large`. An attribute name, raw value, key or other string value over its length is refused with `string_too_long`, and the value of a format-checked key over its length with `attribute_metadata_value_invalid`. A limit only the merge can break — a map pushed over 32 keys or 4096 bytes by keys already stored, or an attribute or catalog pushed over its value count — is refused whole, with `attribute_metadata_limit_reached`. Clear something first. ## The attribute has to exist You can only describe an attribute the object type actually has: one the catalog's last ingest inferred on that type, or a registered `@` slot such as `@title` or `@brand`. Anything else is refused with `catalog_field_unknown`, which is usually a typo, a name that only exists in the source feed rather than in the catalog, or an attribute of another object type. The reserved namespaces — `private:`, `signals:`, `ml:`, `lexical:` and `catalog:` — are refused with `catalog_field_forbidden`. Value metadata only goes on an attribute holding text: one whose `type` in the [attribute listing](/indexing/catalog-metadata/#attributes-and-their-types) is `string`, or an `array` of `string`. Setting it on a number, a boolean or an object is refused with `attribute_metadata_values_unsupported`; describe such an attribute itself instead, for example with a `unit`. An `@` slot has no type in that listing, so it is taken as text and takes value metadata whatever it holds. Removing value metadata works on any attribute. Both checks read the catalog's inferred attributes, so **metadata can only be set once the catalog's first ingest has run**. Before that there is nothing to check a name against, and a write is refused with `catalog_types_unavailable`: ```json { "reason": "attribute metadata validation failed: 1 problem", "exception_details": { "validation_errors": [ { "loc": ["body"], "msg": "the catalog has no attributes yet, so the ones named cannot be checked; set their metadata once the catalog's first ingest has run", "type": "catalog_types_unavailable" } ] }, "request_id": "01JQ8H3Z9K2F7M4N6P8R0S2T4V" } ``` A catalog that does not exist answers the same way, because a catalog with no ingested content and one that was never created look identical from here. An object type the catalog does not have — usually a typo in the path — is refused with `catalog_type_unknown`, naming the object types it does have: ```json { "loc": ["path", "object_type"], "msg": "'prodcut' is not an object type of the catalog; it has category, product", "type": "catalog_type_unknown" } ``` Reading an object type the catalog does not have answers an empty page rather than `catalog_type_unknown`, so metadata left behind after a type disappears from the catalog stays listable and removable. ## Reading it back List the object type's attributes that carry metadata, ordered by attribute, each with every one of its values that carries metadata: ```bash curl -G 'https://api.eu1.luigisbox.ai/catalog/v1/lbc_8w3k2p/types/product/attribute-metadata' \ -H 'Authorization: Bearer ' ``` ```json { "items": [ { "attribute_name": "material", "metadata": { "label": "Material" }, "values": { "Stainless steel": { "metadata": { "label": "Steel", "color": "#C0C0C0" } } }, "value_count": 1, "version": 41 }, { "attribute_name": "size", "metadata": {}, "values": { "L": { "metadata": { "label": "Large" } }, "M": { "metadata": { "label": "Medium" } } }, "value_count": 2, "version": 58 } ], "page": 1, "size": 20, "total": 2 } ``` `metadata` is `{}` on an attribute that only its values describe — `size` above carries nothing of its own — and `values` is `{}` on one whose values carry none. An attribute comes back whole, values and `version` read together, so the `version` it carries is the one to send with a change built on what it shows. `values` is never paged: it always holds every value of the attribute that carries metadata, at most 2 000 (see [Limits](#limits)), because the attribute's `version` covers all of them. Only some attributes, by naming each in `attribute_name`, repeated for several — up to 100, as many as one write changes. The page `size` still applies, 20 by default, so send `size=100` to get up to 100 named attributes in one response. The name is a query parameter, so send it percent-encoded and it may hold any character, `/` included: ```bash curl -G 'https://api.eu1.luigisbox.ai/catalog/v1/lbc_8w3k2p/types/product/attribute-metadata' \ --data-urlencode 'attribute_name=material' \ --data-urlencode 'attribute_name=AES/EBU' \ --data-urlencode 'size=100' \ -H 'Authorization: Bearer ' ``` An attribute carrying no metadata at either level is left out, whether or not the object type holds that attribute, so naming only such attributes answers an empty page. Only attributes that describe one raw value, by naming it in `value` exactly as the catalog holds it. It combines with `attribute_name`: ```bash curl -G 'https://api.eu1.luigisbox.ai/catalog/v1/lbc_8w3k2p/types/product/attribute-metadata' \ --data-urlencode 'value=Stainless steel' \ -H 'Authorization: Bearer ' ``` Both filters choose which attributes are listed; neither narrows an attribute's `values`, so each attribute listed still carries all of them. ## Removing an attribute's metadata Send the attribute in a `PATCH` with both `"metadata": null` and `"values": null`, and its current `version`: ```bash curl -X PATCH 'https://api.eu1.luigisbox.ai/catalog/v1/lbc_8w3k2p/types/product/attribute-metadata' \ -H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ -d '{ "items": [{ "attribute_name": "material", "version": 41, "metadata": null, "values": null }] }' ``` It removes the attribute's own metadata and every one of its values', and the response leaves the attribute out. The `version` stops a removal built on a stale view from taking values someone added since: an older one is a `412` that removes nothing. ## When a change takes effect A write is stored immediately and reads back immediately from the endpoints above.