Skip to main content

List of data types

Each metafield has a data type that determines what information it can store. All types have built-in validation and Liquid support. Use this page to explore available types and their expected value formats.

Note

Metaobjects use the same data types.


When you create a metafield definition, the type applies to every instance of that resource. For example, if you create a definition called "Ingredients" with type multi_line_text_field for products, then every product enforces that type for its "Ingredients" metafield.

shopify.app.toml

[product.metafields.app.ingredients]
name = "Ingredients"
type = "multi_line_text_field"
{
"data": {
"product": {
"metafield": {
"namespace": "$app",
"key": "ingredients",
"value": "oat milk,\nsugar,\nchia seeds",
"type": "multi_line_text_field",
"definition": {
"name": "Ingredients",
"ownerType": "PRODUCT"
}
}
}
}
}

When using the GraphQL Admin API to read and write metafields, the value is always entered and stored as a string, regardless of type.

For information about limits for each metafield type, refer to metafield limits.


Anchor to Metafield type migrationMetafield type migration

You can change the type of a metafield, with some important considerations:

  • Metafields cannot be migrated to type id.
  • When migrating a metafield between incompatible types (for example, from date_time to money), the existing values become invalid. To fix this, use the Shopify admin to clear the invalid value, or use the API to clear the value or change the invalid definition to a compatible one.

Basic types store values like text, numbers, dates, and measurements paired with a unit. See code samples.

TypeDescriptionValue typeTranslatableMarket localizable
antenna_gainA value and a unit of antenna gain. Valid unit values: decibels_isotropic, decibels_dipoleJSON objectnono
areaA value and a unit of area. Valid unit values: square_centimeters, square_feet, square_inches, square_meters, square_yardsJSON objectnono
battery_charge_capacityA value and a unit of battery charge capacity. Valid unit values: milliamp_hoursJSON objectnono
battery_energy_capacityA value and a unit of battery energy capacity. Valid unit values: watt_hoursJSON objectnono
booleanA true or false value.booleannono
capacitanceA value and a unit of capacitance. Valid unit values: picofarads, nanofarads, microfarads, faradsJSON objectnono
colorThe hexadecimal code for a color.stringnono
concentrationA value and a unit of concentration. Valid unit values: milligrams_per_gram, milligrams_per_milliliterJSON objectnono
data_storage_capacityA value and a unit of data storage capacity. Valid unit values: bytes, kilobytes, megabytes, gigabytes, terabytesJSON objectnono
data_transfer_rateA value and a unit of data transfer rate. Valid unit values: bits_per_second, kilobits_per_second, megabits_per_second, gigabits_per_secondJSON objectnono
dateA date in ISO 8601 format without a presumed timezone.stringnono
date_timeA date and time in ISO 8601 format without a presumed timezone. Defaults to Greenwich Mean Time (GMT).stringnono
dimensionA value and a unit of length. Valid unit values: inches, feet, yards, millimeters, centimeters, metersJSON objectnono
display_densityA value and a unit of display density. Valid unit values: pixels_per_inch, dots_per_inchJSON objectnono
distanceA value and a unit of distance. Valid unit values: kilometers, milesJSON objectnono
durationA value and a unit of time duration. Valid unit values: nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days, months, yearsJSON objectnono
electric_currentA value and a unit of electric current. Valid unit values: milliamperes, amperes, kiloamperesJSON objectnono
electrical_resistanceA value and a unit of electrical resistance. Valid unit values: ohms, kiloohmsJSON objectnono
energyA value and a unit of energy. Valid unit values: joules, calories, kilojoules, kilocaloriesJSON objectnono
frequencyA value and a unit of frequency. Valid unit values: hertz, kilohertz, megahertz, gigahertzJSON objectnono
idA unique single-line text field. You can add validations for min, max, and regex.stringnono
illuminanceA value and a unit of illuminance. Valid unit values: lux, foot_candlesJSON objectnono
inductanceA value and a unit of inductance. Valid unit values: microhenries, millihenries, henriesJSON objectnono
jsonA JSON-serializable value. This can be an object, an array, a string, a number, a boolean, or a null value.JSON datayesno
linkA text and URL pairing that can be used to store link content.JSON datayesno
luminous_fluxA value and a unit of luminous flux. Valid unit values: lumensJSON objectnono
mass_flow_rateA value and a unit of mass flow rate. Valid unit values: grams_per_day, grams_per_hour, grams_per_minute, grams_per_second, ounces_per_day, ounces_per_hour, ounces_per_minute, ounces_per_second, pounds_per_day, pounds_per_hour, pounds_per_minute, pounds_per_second, kilograms_per_day, kilograms_per_hour, kilograms_per_minute, kilograms_per_second, tons_per_day, tons_per_hour, tons_per_minute, tons_per_second, tonnes_per_day, tonnes_per_hour, tonnes_per_minute, tonnes_per_secondJSON objectnono
moneyA numeric amount, with a currency code that matches the store's currency. You can localize money metafields to a market, but you can't translate them to a different language or locale.JSON objectnoyes
multi_line_text_fieldA multi-line text field.stringyesno
number_decimalA number with decimal places in the range of +/-9999999999999.999999999.stringnono
number_integerA whole number in the range of +/-9,007,199,254,740,991.integernono
powerA value and a unit of power. Valid unit values: milliwatts, watts, horsepower, kilowattsJSON objectnono
pressureA value and a unit of pressure. Valid unit values: pounds_per_square_inch, barsJSON objectnono
ratingA rating measured on a specified scale. Validations are required for ratings and support min and max.JSON objectnono
resolutionA value and a unit of resolution. Valid unit values: pixels, megapixelsJSON objectnono
rich_text_fieldA rich text field supporting headings, lists, links, bold, and italics. Learn more about rich text formatting.JSON objectyesno
rotational_speedA value and a unit of rotational speed. Valid unit values: revolutions_per_minuteJSON objectnono
single_line_text_fieldA single-line text field.stringyesno
sound_levelA value and a unit of sound level. Valid unit values: decibelsJSON objectnono
speedA value and a unit of speed. Valid unit values: kilometers_per_hour, feet_per_second, miles_per_hour, meters_per_secondJSON objectnono
temperatureA value and a unit of temperature. Valid unit values: celsius, fahrenheit, kelvinJSON objectnono
thermal_powerA value and a unit of thermal power. Valid unit values: british_thermal_units_per_hour, kilowatts, tons_of_refrigerationJSON objectnono
urlA URL with one of the allowed schemes: https, http, mailto, sms, tel.stringyesno
voltageA value and a unit of voltage. Valid unit values: voltsJSON objectnono
volumeA value and a unit of volume. Valid unit values: milliliters, centiliters, liters, cubic_meters, us_fluid_ounces, us_pints, us_quarts, us_gallons, imperial_fluid_ounces, imperial_pints, imperial_quarts, imperial_gallons.JSON objectnono
volumetric_flow_rateA value and a unit of volumetric flow rate. Valid unit values: liters_per_hour, liters_per_minute, liters_per_second, gallons_per_hour, gallons_per_minute, gallons_per_second, cubic_feet_per_hour, cubic_feet_per_minute, cubic_feet_per_second, cubic_meters_per_hour, cubic_meters_per_minute, cubic_meters_per_secondJSON objectnono
weightA value and a unit of weight. Valid unit values: ounces, pounds, grams, kilogramsJSON objectnono

Anchor to Basic type code samplesBasic type code samples

The following examples demonstrate the expected value format for each basic type:

TypeSample
antenna_gain
{
"value": 5.0,
"unit": "decibels_isotropic"
}
area
{
"value": 100.0,
"unit": "square_meters"
}
battery_charge_capacity
{
"value": 3000.0,
"unit": "milliamp_hours"
}
battery_energy_capacity
{
"value": 50.0,
"unit": "watt_hours"
}
boolean
true
capacitance
{
"value": 100.0,
"unit": "microfarads"
}
color
#fff123
concentration
{
"value": 5.0,
"unit": "milligrams_per_milliliter"
}
data_storage_capacity
{
"value": 256.0,
"unit": "gigabytes"
}
data_transfer_rate
{
"value": 100.0,
"unit": "megabits_per_second"
}
date
2022-02-02
date_time
2024-01-01T12:30:00
dimension
{
"value": 25.0,
"unit": "centimeters"
}
display_density
{
"value": 326.0,
"unit": "pixels_per_inch"
}
distance
{
"value": 42.0,
"unit": "kilometers"
}
duration
{
"value": 30.0,
"unit": "seconds"
}
electric_current
{
"value": 2.5,
"unit": "amperes"
}
electrical_resistance
{
"value": 100.0,
"unit": "ohms"
}
energy
{
"value": 250.0,
"unit": "kilocalories"
}
frequency
{
"value": 2.4,
"unit": "gigahertz"
}
id
1234
illuminance
{
"value": 500.0,
"unit": "lux"
}
inductance
{
"value": 10.0,
"unit": "millihenries"
}
json
{
"ingredient": "flour",
"amount": 0.3
}
link
{
"text": "Learn more",
"url": "https://shopify.com"
}
luminous_flux
{
"value": 800.0,
"unit": "lumens"
}
mass_flow_rate
{
"value": 5.0,
"unit": "kilograms_per_hour"
}
money
{
"amount": "5.99",
"currency_code": "CAD"
}
multi_line_text_field
Ingredients
Flour
Water
Milk
Eggs
number_decimal
10.4
number_integer
10
power
{
"value": 100.0,
"unit": "watts"
}
pressure
{
"value": 14.7,
"unit": "pounds_per_square_inch"
}
rating
{
"value": "3.5",
"scale_min": "1.0",
"scale_max": "5.0"
}
resolution
{
"value": 12.0,
"unit": "megapixels"
}
rich_text_field
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "Bold text.",
"bold": true
}
]
}
]
}
rotational_speed
{
"value": 3000.0,
"unit": "revolutions_per_minute"
}
single_line_text_field
VIP shipping method
sound_level
{
"value": 85.0,
"unit": "decibels"
}
speed
{
"value": 60.0,
"unit": "kilometers_per_hour"
}
temperature
{
"value": 22.5,
"unit": "celsius"
}
thermal_power
{
"value": 12000.0,
"unit": "british_thermal_units_per_hour"
}
url
https://www.shopify.com
voltage
{
"value": 120.0,
"unit": "volts"
}
volume
{
"value": 20.0,
"unit": "milliliters"
}
volumetric_flow_rate
{
"value": 5.0,
"unit": "liters_per_minute"
}
weight
{
"value": 2.5,
"unit": "kilograms"
}

Reference metafields store references to Shopify resources. See code samples.

TypeDescriptionValue typeTranslatableMarket localizable
article_referenceA reference to a blog post.stringnoyes
collection_referenceA reference to a collection.stringnoyes
company_referenceA reference to a company.stringnono
customer_referenceA reference to a customer.stringnono
file_referenceA reference to a file. The default value is GenericFile. You can use validations to add other file types (for example, Image).stringyesno
metaobject_referenceA reference to a metaobject entry. You can use validations to set which metaobject definition the metaobject must be. In TOML, use the type shorthand: type = "metaobject_reference<$app:author>".stringnoyes
mixed_referenceA reference that can point to metaobjects from different definitions, unlike metaobject_reference which only allows metaobjects from one definition. In TOML, use the type shorthand: type = "mixed_reference<$app:author, $app:publisher>".stringnono
page_referenceA reference to a page.stringnoyes
product_referenceA reference to a product.stringnoyes
product_taxonomy_value_referenceA reference to a product taxonomy value. You can add validations to limit which taxonomy values can be selected. Refer to Shopify Standard Product Taxonomy for available values.stringnono
variant_referenceA reference to a product variant.stringnoyes

Anchor to Reference type code samplesReference type code samples

The following examples demonstrate the expected value format for each reference type:

TypeSample
article_reference
gid://shopify/Article/1
collection_reference
gid://shopify/Collection/1
company_reference
gid://shopify/Company/1
customer_reference
gid://shopify/Customer/1
file_reference
gid://shopify/MediaImage/123
metaobject_reference
gid://shopify/Metaobject/123
mixed_reference
gid://shopify/Metaobject/123
page_reference
gid://shopify/Page/1
product_reference
gid://shopify/Product/1
product_taxonomy_value_reference
gid://shopify/TaxonomyValue/1
variant_reference
gid://shopify/ProductVariant/1

List metafields store multiple values in a single metafield as a JSON array. See code samples.

You can implement list metafields on the online store using sections and blocks. The type of list determines the implementation. For example, you could add a list of product references as a dynamic source to a custom block, or you could add a list of single line text fields to a text or rich text section.

Info

If you delete a product or variant from a store, then the product or variant is automatically removed from all list metafields that reference it.

TypeDescriptionTranslatableMarket localizable
list.antenna_gainA list of values and a unit of antenna gain. Valid unit values: decibels_isotropic, decibels_dipolenono
list.areaA list of values and a unit of area. Valid unit values: square_centimeters, square_feet, square_inches, square_meters, square_yardsnono
list.article_referenceA list of references to blog posts.nono
list.battery_charge_capacityA list of values and a unit of battery charge capacity. Valid unit values: milliamp_hoursnono
list.battery_energy_capacityA list of values and a unit of battery energy capacity. Valid unit values: watt_hoursnono
list.capacitanceA list of values and a unit of capacitance. Valid unit values: picofarads, nanofarads, microfarads, faradsnono
list.collection_referenceA list of collection references.nono
list.colorA list of hexadecimal color codes.nono
list.concentrationA list of values and a unit of concentration. Valid unit values: milligrams_per_gram, milligrams_per_milliliternono
list.customer_referenceA list of references to customers.nono
list.data_storage_capacityA list of values and a unit of data storage capacity. Valid unit values: bytes, kilobytes, megabytes, gigabytes, terabytesnono
list.data_transfer_rateA list of values and a unit of data transfer rate. Valid unit values: bits_per_second, kilobits_per_second, megabits_per_second, gigabits_per_secondnono
list.dateA list of dates in ISO 8601 format without presumed timezones.nono
list.date_timeA list of dates and times in ISO 8601 format without presumed timezones. Defaults to Greenwich Mean Time (GMT).nono
list.dimensionA list of values and a unit of length. Valid unit values: inches, feet, yards, millimeters, centimeters, meters.nono
list.display_densityA list of values and a unit of display density. Valid unit values: pixels_per_inch, dots_per_inchnono
list.distanceA list of values and a unit of distance. Valid unit values: kilometers, milesnono
list.durationA list of values and a unit of time duration. Valid unit values: nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days, months, yearsnono
list.electric_currentA list of values and a unit of electric current. Valid unit values: milliamperes, amperes, kiloamperesnono
list.electrical_resistanceA list of values and a unit of electrical resistance. Valid unit values: ohms, kiloohmsnono
list.energyA list of values and a unit of energy. Valid unit values: joules, calories, kilojoules, kilocaloriesnono
list.file_referenceA list of references to files. The default value is GenericFile. You can use validations to add other file types (for example, Image).yesno
list.frequencyA list of values and a unit of frequency. Valid unit values: hertz, kilohertz, megahertz, gigahertznono
list.idA list of unique single-line text fields. You can add validations for min, max, and regex.nono
list.illuminanceA list of values and a unit of illuminance. Valid unit values: lux, foot_candlesnono
list.inductanceA list of values and a unit of inductance. Valid unit values: microhenries, millihenries, henriesnono
list.linkA list of text and URL pairings that can be used to store a collection of links.yesno
list.luminous_fluxA list of values and a unit of luminous flux. Valid unit values: lumensnono
list.mass_flow_rateA list of values and a unit of mass flow rate. Valid unit values: grams_per_day, grams_per_hour, grams_per_minute, grams_per_second, ounces_per_day, ounces_per_hour, ounces_per_minute, ounces_per_second, pounds_per_day, pounds_per_hour, pounds_per_minute, pounds_per_second, kilograms_per_day, kilograms_per_hour, kilograms_per_minute, kilograms_per_second, tons_per_day, tons_per_hour, tons_per_minute, tons_per_second, tonnes_per_day, tonnes_per_hour, tonnes_per_minute, tonnes_per_secondnono
list.metaobject_referenceA list reference to one or more metaobject entries that belong to a single metaobject definition. Unlike list.mixed_reference, all metaobject entries referenced must be of the same definition. In TOML, use the type shorthand: type = "list.metaobject_reference<$app:author>".nono
list.mixed_referenceA list reference to one or more metaobject entries that may belong to different metaobject definitions. In TOML, use the type shorthand: type = "list.mixed_reference<$app:author, $app:publisher>".nono
list.number_decimalA list of numbers with decimal places in the range of +/-9999999999999.999999999.nono
list.number_integerA list of whole numbers in the range of +/-9,007,199,254,740,991.nono
list.page_referenceA list of references to pages.nono
list.powerA list of values and a unit of power. Valid unit values: milliwatts, watts, horsepower, kilowattsnono
list.pressureA list of values and a unit of pressure. Valid unit values: pounds_per_square_inch, barsnono
list.product_referenceA list of product references.nono
list.product_taxonomy_value_referenceA list of references to product taxonomy values. You can add validations to limit which taxonomy values can be selected. Refer to Shopify Standard Product Taxonomy for available values.nono
list.ratingA list of ratings measured on a specified scale. Validations are required for ratings and support min and max.nono
list.resolutionA list of values and a unit of resolution. Valid unit values: pixels, megapixelsnono
list.rotational_speedA list of values and a unit of rotational speed. Valid unit values: revolutions_per_minutenono
list.single_line_text_fieldA list of single-line text fields.yesno
list.sound_levelA list of values and a unit of sound level. Valid unit values: decibelsnono
list.speedA list of values and a unit of speed. Valid unit values: kilometers_per_hour, feet_per_second, miles_per_hour, meters_per_secondnono
list.temperatureA list of values and a unit of temperature. Valid unit values: celsius, fahrenheit, kelvinnono
list.thermal_powerA list of values and a unit of thermal power. Valid unit values: british_thermal_units_per_hour, kilowatts, tons_of_refrigerationnono
list.urlA list of URLs with one of the allowed schemes: https, http, mailto, sms, tel.yesno
list.variant_referenceA list of references to product variants.nono
list.voltageA list of values and a unit of voltage. Valid unit values: voltsnono
list.volumeA list of values and a unit of volume. Valid unit values: milliliters, centiliters, liters, cubic_meters, us_fluid_ounces, us_pints, us_quarts, us_gallons, imperial_fluid_ounces, imperial_pints, imperial_quarts, imperial_gallons.nono
list.volumetric_flow_rateA list of values and a unit of volumetric flow rate. Valid unit values: liters_per_hour, liters_per_minute, liters_per_second, gallons_per_hour, gallons_per_minute, gallons_per_second, cubic_feet_per_hour, cubic_feet_per_minute, cubic_feet_per_second, cubic_meters_per_hour, cubic_meters_per_minute, cubic_meters_per_secondnono
list.weightA list of values and a unit of weight. Valid unit values: ounces, pounds, grams, kilogramsnono

Anchor to List type code samplesList type code samples

The following examples demonstrate the expected value format for each list type:

TypeSample
list.antenna_gain
[
{"value": 5.0, "unit": "decibels_isotropic"},
{"value": 3.0, "unit": "decibels_isotropic"}
]
list.area
[
{"value": 100.0, "unit": "square_meters"},
{"value": 200.0, "unit": "square_meters"}
]
list.article_reference
[
"gid://shopify/Article/1",
"gid://shopify/Article/2"
]
list.battery_charge_capacity
[
{"value": 3000.0, "unit": "milliamp_hours"},
{"value": 5000.0, "unit": "milliamp_hours"}
]
list.battery_energy_capacity
[
{"value": 50.0, "unit": "watt_hours"},
{"value": 100.0, "unit": "watt_hours"}
]
list.capacitance
[
{"value": 100.0, "unit": "microfarads"},
{"value": 220.0, "unit": "microfarads"}
]
list.collection_reference
[
"gid://shopify/Collection/1",
"gid://shopify/Collection/2"
]
list.color
[
"#FFF123",
"#E6E6FA",
"#00FF00"
]
list.concentration
[
{"value": 5.0, "unit": "milligrams_per_milliliter"},
{"value": 10.0, "unit": "milligrams_per_milliliter"}
]
list.customer_reference
[
"gid://shopify/Customer/1",
"gid://shopify/Customer/2"
]
list.data_storage_capacity
[
{"value": 256.0, "unit": "gigabytes"},
{"value": 512.0, "unit": "gigabytes"}
]
list.data_transfer_rate
[
{"value": 100.0, "unit": "megabits_per_second"},
{"value": 1000.0, "unit": "megabits_per_second"}
]
list.date
[
"2022-01-01",
"2022-05-05"
]
list.date_time
[
"2024-01-01T12:30:00",
"2024-05-01T12:30:00"
]
list.dimension
[
{"value": 25.0, "unit": "centimeters"},
{"value": 35.0, "unit": "centimeters"}
]
list.display_density
[
{"value": 326.0, "unit": "pixels_per_inch"},
{"value": 458.0, "unit": "pixels_per_inch"}
]
list.distance
[
{"value": 42.0, "unit": "kilometers"},
{"value": 100.0, "unit": "kilometers"}
]
list.duration
[
{"value": 30.0, "unit": "seconds"},
{"value": 60.0, "unit": "seconds"}
]
list.electric_current
[
{"value": 2.5, "unit": "amperes"},
{"value": 5.0, "unit": "amperes"}
]
list.electrical_resistance
[
{"value": 100.0, "unit": "ohms"},
{"value": 470.0, "unit": "ohms"}
]
list.energy
[
{"value": 250.0, "unit": "kilocalories"},
{"value": 500.0, "unit": "kilocalories"}
]
list.file_reference
[
"gid://shopify/MediaImage/123",
"gid://shopify/MediaImage/456"
]
list.frequency
[
{"value": 2.4, "unit": "gigahertz"},
{"value": 5.0, "unit": "gigahertz"}
]
list.id
[
"1234",
"5678"
]
list.illuminance
[
{"value": 500.0, "unit": "lux"},
{"value": 1000.0, "unit": "lux"}
]
list.inductance
[
{"value": 10.0, "unit": "millihenries"},
{"value": 47.0, "unit": "millihenries"}
]
list.link
[
{"text": "Start a business", "url": "https://shopify.com"},
{"text": "Read the docs", "url": "https://shopify.dev/docs"}
]
list.luminous_flux
[
{"value": 800.0, "unit": "lumens"},
{"value": 1600.0, "unit": "lumens"}
]
list.mass_flow_rate
[
{"value": 5.0, "unit": "kilograms_per_hour"},
{"value": 10.0, "unit": "kilograms_per_hour"}
]
list.metaobject_reference
[
"gid://shopify/Metaobject/123",
"gid://shopify/Metaobject/456"
]
list.mixed_reference
[
"gid://shopify/Metaobject/123",
"gid://shopify/Metaobject/456"
]
list.number_decimal
[
"10.4",
"20.5",
"30.6"
]
list.number_integer
[
"10",
"20",
"30"
]
list.page_reference
[
"gid://shopify/Page/1",
"gid://shopify/Page/2"
]
list.power
[
{"value": 100.0, "unit": "watts"},
{"value": 200.0, "unit": "watts"}
]
list.pressure
[
{"value": 14.7, "unit": "pounds_per_square_inch"},
{"value": 30.0, "unit": "pounds_per_square_inch"}
]
list.product_reference
[
"gid://shopify/Product/1",
"gid://shopify/Product/2"
]
list.product_taxonomy_value_reference
[
"gid://shopify/TaxonomyValue/1",
"gid://shopify/TaxonomyValue/2"
]
list.rating
[
{"value": "3.5", "scale_min": "1.0", "scale_max": "5.0"},
{"value": "4.5", "scale_min": "1.0", "scale_max": "5.0"}
]
list.resolution
[
{"value": 12.0, "unit": "megapixels"},
{"value": 48.0, "unit": "megapixels"}
]
list.rotational_speed
[
{"value": 3000.0, "unit": "revolutions_per_minute"},
{"value": 6000.0, "unit": "revolutions_per_minute"}
]
list.single_line_text_field
[
"VIP shipping method",
"Standard shipping method"
]
list.sound_level
[
{"value": 85.0, "unit": "decibels"},
{"value": 100.0, "unit": "decibels"}
]
list.speed
[
{"value": 60.0, "unit": "kilometers_per_hour"},
{"value": 120.0, "unit": "kilometers_per_hour"}
]
list.temperature
[
{"value": 22.5, "unit": "celsius"},
{"value": 37.0, "unit": "celsius"}
]
list.thermal_power
[
{"value": 12000.0, "unit": "british_thermal_units_per_hour"},
{"value": 24000.0, "unit": "british_thermal_units_per_hour"}
]
list.url
[
"https://www.shopify.com",
"https://www.shopify.dev"
]
list.variant_reference
[
"gid://shopify/ProductVariant/1",
"gid://shopify/ProductVariant/2"
]
list.voltage
[
{"value": 120.0, "unit": "volts"},
{"value": 240.0, "unit": "volts"}
]
list.volume
[
{"value": 20.0, "unit": "milliliters"},
{"value": 40.0, "unit": "milliliters"}
]
list.volumetric_flow_rate
[
{"value": 5.0, "unit": "liters_per_minute"},
{"value": 10.0, "unit": "liters_per_minute"}
]
list.weight
[
{"value": 2.5, "unit": "kilograms"},
{"value": 4.5, "unit": "kilograms"}
]

Anchor to Declarative (TOML) type syntaxDeclarative (TOML) type syntax

When defining metafields or metaobject fields in shopify.app.toml, most types use the type name directly:

[product.metafields.app.ingredients]
type = "multi_line_text_field"

However, reference types that point to metaobjects require a special shorthand syntax that embeds the target definition in the type. This replaces the metaobject_definition_id and metaobject_definition_ids validations used in the GraphQL Admin API.

  • metaobject_reference and list.metaobject_reference: Use angle brackets to specify which metaobject definition the reference must point to:

Use angle brackets to specify which metaobject definition the reference must point to:

[product.metafields.app.author]
type = "metaobject_reference<$app:author>"

[product.metafields.app.related_authors]
type = "list.metaobject_reference<$app:author>"
  • mixed_reference and list.mixed_reference: Use a comma-separated list inside the angle brackets to specify which metaobject definitions are allowed:

Use a comma-separated list inside the angle brackets to specify which metaobject definitions are allowed:

[product.metafields.app.content_block]
type = "mixed_reference<$app:author, $app:publisher>"

[product.metafields.app.content_blocks]
type = "list.mixed_reference<$app:author, $app:publisher>"

Anchor to Metaobject field exampleMetaobject field example

The same syntax applies when defining fields on metaobject definitions:

[metaobjects.app.book.fields.author]
type = "metaobject_reference<$app:author>"

[metaobjects.app.book.fields.related_content]
type = "list.mixed_reference<$app:author, $app:publisher>"
Info

You don't need to add metaobject_definition_id or metaobject_definition_ids validations in TOML. The type shorthand syntax above handles this automatically.


Anchor to Rich text formatting detailsRich text formatting details

The rich_text_field metafield type accepts a JSON object that uses the following general structure:

{
"type": "root",
// The root holds an array of paragraphs and lists. Each paragraph represents a section of text that's separated by a line break.
"children": [
{
"type": "paragraph",
// A paragraph holds an array of formatted text objects and URL objects, where the objects are concatenated to form the text within the paragraph.
"children": [
// Formatted text object
{
"type": "text",
"value": "This is italicized text and ",
"italic": true
},
// URL object
{
"url": "https://example.com",
"title": "Link to example.com",
"type": "link",
"children": [
// Formatted text object that's embedded in the URL object.
{
"type": "text",
"value": "a bolded hyperlink",
"bold": true
}
]
}
]
}
]
}
The rich text editor, showing the words

Refer to the following code samples for examples of the objects that can be used to represent fragments of rich text:

{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "This text is bolded and italicized.",
// To bold or italicize the text, set the "bold" or "italic" values to true. The default value is false.
"bold": true,
"italic": true
}
]
}
]
}
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "heading",
"children": [{
"type": "text",
"value": "This is an H1 heading"
}],
// The heading level
"level": 1
}
]
}
]
}
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"url": "https://example.com",
// The URL title is used for accessibility and SEO purposes.
"title": "Link to example.com",
"type": "link",
// The following array of formatted text represents the text that's visible to the user.
"children": [{
"type": "text",
"value": "This is a hyperlink"
}]
}
]
}
]
}
{
"type": "root",
"children": [
{
// The listType accepts "ordered" or "unordered".
"listType": "ordered",
"type": "list",
"children": [
{
"type": "list-item",
// Each list item holds an array of formatted text.
"children": [{
"type": "text",
"value": "This is the first list item."
}]
},
{
"type": "list-item",
"children": [{
"type": "text",
"value": "This is the second list item."
}]
}
]

}
]
}


Was this page helpful?