metafield.definition.create

Define a typed custom field on products, variants, collections, or the store.

Payload

fieldtyperequirednotes
ownerType"product" | "variant" | "collection" | "store"yes
namespacestring (/^(custom|app\.[a-z0-9-]{2,32})$/)yes
keystring (/^[a-z0-9_]{1,64}$/)yes
valueType"text" | "integer" | "decimal" | "boolean" | "date" | "json"yes
labelTRstring (≤100 chars)yes
descriptionTRstring (≤500 chars)no
validationsobjectno
minnumberno
maxnumberno
maxLengthinteger (..65536)no
regexstring (≤200 chars)no
choicesarray<string (≤100 chars)> (≤50)no

JSON Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ownerType": {
      "type": "string",
      "enum": [
        "product",
        "variant",
        "collection",
        "store"
      ]
    },
    "namespace": {
      "type": "string",
      "pattern": "^(custom|app\\.[a-z0-9-]{2,32})$"
    },
    "key": {
      "type": "string",
      "pattern": "^[a-z0-9_]{1,64}$"
    },
    "valueType": {
      "type": "string",
      "enum": [
        "text",
        "integer",
        "decimal",
        "boolean",
        "date",
        "json"
      ]
    },
    "labelTR": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "descriptionTR": {
      "type": "string",
      "maxLength": 500
    },
    "validations": {
      "type": "object",
      "properties": {
        "min": {
          "type": "number"
        },
        "max": {
          "type": "number"
        },
        "maxLength": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 65536
        },
        "regex": {
          "type": "string",
          "maxLength": 200
        },
        "choices": {
          "minItems": 1,
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 100
          }
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "ownerType",
    "namespace",
    "key",
    "valueType",
    "labelTR"
  ],
  "additionalProperties": false
}
Generated from the live platform registries at build time — reference pages cannot go stale. Markdown variant: /reference/commands/metafield.definition.create.md