Catalog Attribute — Update
Updates an existing attribute. Mirrors Catalog → Attributes → Edit in the Bagisto admin panel.
Endpoint
| Endpoint | Method |
|---|---|
/api/admin/catalog/attributes/{id} | PUT |
{id} must be a positive integer (requirements: ['id' => '\\d+']).
Request body
Same fields as Create, with these rules:
codeis immutable. Sending a different code returns422.typecannot be changed if any product attribute value references this attribute. Returns422.optionsis a full-set replacement. Entries with anidare updated, entries withoutidare inserted, and any existing option ids omitted from the payload are deleted.- System attributes (
is_user_defined = 0) silently ignore immutable fields by convention — only mutable fields (e.g.admin_name, translations) are applied. translationsmerges per-locale — only the supplied locales are updated; others are untouched.- Setting
validationtoregexrequires aregexpattern, checked the same way as on create.
Validation and the regex pattern
validation names the rule a value must satisfy — numeric, email, decimal, url or regex. Choosing regex makes regex required, and the pattern is checked before it is stored.
A pattern must be delimited with /, may carry only the i, m, s and u modifiers, and must compile. That is narrower than PHP alone accepts because the same pattern is also written into the storefront's own form rules, where a # delimiter or a PCRE-only modifier would break the form for every product using the attribute. A pattern that does not qualify is refused rather than stored.
Response
200 OK returning the full attribute detail — identical shape to GET /api/admin/catalog/attributes/{id}.
Errors
| HTTP | Cause |
|---|---|
401 Unauthorized | Missing or invalid Bearer token |
404 Not Found | The attribute does not exist |
422 Unprocessable Entity | Code change attempted, type change refused, or other validation failure |

