---
title: "Metafield"
description: "元字段信息。"
doc_type: graphql
doc_category: storefront
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common-objects/objects/metafield'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common-objects/objects/metafield.md'
---
# Metafield

元字段信息。

- **API Version:** v20270301
- **API Type:** Storefront
- **API Protocol:** GraphQL
- **Operation Type:** Object

## Fields

* `createdAt`

  [Date](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common/scalars/date.md)

  元字段创建时间。格式：[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)。

* `namespace`

  [String](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common/scalars/string.md)

  元字段的命名空间。通过命名空间可对元字段进行分组，避免具有相同健名的元字段发生冲突。通过 `key` 和 `namespace` 可以唯一确定元字段。   
  仅支持字母、数字、连字符和下划线字符。  
  最小长度限制：2  
  最大长度限制：50 

* `id`

  [ID](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common/scalars/id.md)

  元字段 ID。

* `type`

  [String](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common/scalars/string.md)

  元字段支持的数据类型，有效枚举值包含：  
  - `single_line_text_field`：单个单行文本  
  - `list.single_line_text_field`：多个单行文本    
  - `multi_line_text_field`：多行文本   
  - `color`：单个颜色   
  - `list.color`：多个颜色  
  - `date`：单个日期    
  - `list.date`：多个日期    
  - `date_time`：单个日期和时间。格式：[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)。   
  - `list.date_time`：多个日期和时间。格式：[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)。   
  - `url`：单个 URL  
  - `list.url`：多个 URL  
  - `file_reference`：单个文件，支持 10M 以内的 PDF 和图片文件，图片支持 JPG、JEPG、PNG 和 GIF 格式。    
  - `list.file_reference`：多个文件，支持 10M 以内的 PDF 和图片文件，图片支持 JPG、JEPG、PNG 和 GIF 格式。  
  - `json`：JSON 类型   
  - `weight`：单个重量，带单位 
  - `list.weight`：多个重量，带单位   
  - `volume`：单个体积，带单位     
  - `list.volume`：多个体积，带单位     
  - `dimension`：单个尺寸，带单位     
  - `list.dimension`：多个尺寸，带单位     
  - `number_integer`：单个整数    
  - `list.number_integer`：多个整数    
  - `number_decimal`：单个小数   
  - `list.number_decimal`：多个小数    
  - `rating`：单个等级   
  - `list.rating`：多个等级   
  - `page_reference`：单个页面   
  - `list.page_reference`：多个页面    
  - `product_reference`：单个商品    
  - `list.product_reference`：多个商品   
  - `variant_reference`：单个商品变体    
  - `list.variant_reference`：多个商品变体    
  - `collection_reference`：单个商品分类    
  - `list.collection_reference`：多个商品分类    
  - `customer_reference`：单个客户     
  - `list.customer_reference`：多个客户    
  - `order_reference`：单个订单    
  - `list.order_reference`：多个订单    
  - `boolean`：布尔类型，有效值包括 `true` 和 `false`。   
  - `money`：资金，带币种单位  
  
  关于更多元字段信息，参考 [元字段功能使用指南](https://help.shopline.com/hc/zh-cn/articles/7095355017113)。

* `value`

  [String](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common/scalars/string.md)

  存储在元字段中的数据。  
  无论你如何定义元字段的类型，SHOPLINE 均将其转换为字符串格式进行存储，转换后的字符串最大长度限制是 500000。
  

* `key`

  [String](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common/scalars/string.md)

  元字段定义在其 `namespace` 下的唯一标识符。仅支持字母、数字、连字符和下划线字符。  
  最小长度限制：3  
  最大长度限制：30  

* `updatedAt`

  [Date](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common/scalars/date.md)

  元字段更新的时间。格式：[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)。

* `description`

  [String](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common/scalars/string.md)

  元字段的描述信息。  

* `reference`

  [MetafieldReference](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common-objects/objects/metafield-reference.md)

  元字段引用的资源对象。

* `references`

  [[MetafieldReference]](https://developer.shopline.com/zh-hans-cn/docs/storefront-api/common-objects/objects/metafield-reference.md)

  元字段引用的资源对象列表。

