Skip to content

Catalog Attribute — Create

Creates a new product attribute. Mirrors Catalog → Attributes → Create in the Bagisto admin panel. The same event hooks fire (catalog.attribute.create.before / catalog.attribute.create.after), so any core listener (search reindex, cache flush, etc.) is triggered.

Endpoint

EndpointMethod
/api/admin/catalog/attributesPOST

Request body

FieldTypeRequiredNotes
codestringyesSnake_case identifier. Must be unique and not a reserved word.
admin_namestringyesInternal admin label.
typestringyesOne of text, textarea, price, boolean, select, multiselect, checkbox, date, datetime, image, file.
swatch_typestring|nullnocolor, image, or text. Only relevant for select/multiselect.
is_required / is_unique / is_filterable / is_configurable / is_visible_on_front / is_comparable / value_per_locale / value_per_channel / enable_wysiwygbooleannoStandard attribute flags.
validationstring|nullnoValidation rule (numeric, email, decimal, url).
default_valuestring|nullnoDefault value for the attribute.
positionintegernoDisplay order.
translationsobjectnoMap of locale → { name }.
optionsarraynoInitial options (select/multiselect/checkbox only). Each entry: { admin_name, sort_order?, swatch_value?, translations? }.

Response

201 Created returning the full attribute detail — identical shape to GET /api/admin/catalog/attributes/{id}.

Errors

HTTPCause
401 UnauthorizedMissing or invalid Bearer token
422 Unprocessable EntityValidation failure (missing/duplicate code, invalid type, malformed body)

Notes

  • The code field is immutable after creation — see the Update endpoint.
  • The repository returns a contract interface — the response is re-fetched as a full Eloquent model so the payload always carries translations and options.
  • For attribute types that do not support options (text, textarea, boolean, etc.), the options array in the response is null.

Released under the MIT License.