FacetFlux

pim.attributeDefinitions.create

Create an attribute definition in a schema, or return the existing one if `code` already exists. DataType is required and immutable once values exist. Optional fields: traitId (binds the def to a trait), unit, scope (product|variantDefining|perVariant), role (None|Name|Description|Brand|...), isRequired, isTranslatable, isSearchable, isFilterable. To populate enum allowed values use pim.attributeDefinitions.allowedValues.set after creation. Response: { attributeDefinition: {...}, created: bool }. Errors: { error: { code: 'not_found' | 'bad_input', ... } }.

Remote revuo:facetflux

Other tools also called pim.attributeDefinitions.create? See providers with this name

Input Schema


            {
  "type": "object",
  "properties": {
    "schemaId": {
      "description": "Schema id.",
      "type": "string"
    },
    "code": {
      "description": "Code. Unique within schema.",
      "type": "string"
    },
    "dataType": {
      "description": "DataType: text, richText, number, decimal, boolean, date, dateTime, enum, multiEnum, reference.",
      "type": "string",
      "enum": [
        "Text",
        "RichText",
        "Number",
        "Decimal",
        "Boolean",
        "Date",
        "DateTime",
        "Enum",
        "MultiEnum",
        "Reference"
      ]
    },
    "traitId": {
      "description": "Optional trait id to bind this definition to.",
      "type": [
        "string",
        "null"
      ],
      "default": null
    },
    "labels": {
      "description": "Localized labels.",
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": [
          "string",
          "null"
        ]
      },
      "default": null
    },
    "unit": {
      "description": "Unit code (e.g. 'kg', 'mm'). Optional.",
      "type": [
        "string",
        "null"
      ],
      "default": null
    },
    "scope": {
      "description": "Where the value lives. Defaults to 'product'.",
      "type": "string",
      "enum": [
        "Product",
        "VariantDefining",
        "PerVariant"
      ],
      "default": "Product"
    },
    "role": {
      "description": "Semantic role. Defaults to 'none'. At most one definition per schema can carry each non-None role.",
      "type": "string",
      "enum": [
        "None",
        "Name",
        "Description",
        "Brand",
        "CustomerProductId",
        "PrimaryImage",
        "ExternalId",
        "Weight"
      ],
      "default": "None"
    },
    "isRequired": {
      "description": "Whether values are required for product completeness.",
      "type": "boolean",
      "default": false
    },
    "isTranslatable": {
      "description": "Whether the value is per-language (LocalizedTextValue).",
      "type": "boolean",
      "default": false
    },
    "isSearchable": {
      "description": "Indexed for search projections.",
      "type": "boolean",
      "default": false
    },
    "isFilterable": {
      "description": "Surfaced as a filter in the UI.",
      "type": "boolean",
      "default": false
    },
    "sortOrder": {
      "description": "Sort order within trait/schema.",
      "type": "integer",
      "default": 0
    }
  },
  "required": [
    "schemaId",
    "code",
    "dataType"
  ]
}