# createAttribute

## Overview

Creates a new product attribute definition with a unique code. Optionally creates initial attribute values in the same operation.

## Modules Commands Used

- `product-management.CreateProductAttribute` — validates code uniqueness and persists the new attribute definition
- `product-management.CreateProductAttributeValue` — creates each specified initial value under the new attribute

## Exception Handling

| Error Code | Source | Description |
| --- | --- | --- |
| DUPLICATE_CODE | CreateProductAttribute | An attribute with the given code already exists |
| MISSING_REQUIRED_FIELD | CreateProductAttribute | A required field such as code or name was not provided |
| ATTRIBUTE_NOT_FOUND | CreateProductAttributeValue | The parent attribute was not found (internal) |
| DUPLICATE_VALUE | CreateProductAttributeValue | A value with the given label already exists under this attribute |
| INVALID_LABEL | CreateProductAttributeValue | The provided label is empty or contains invalid characters |
