POST https://{handle}.myshopline.com/admin/openapi/v20250601/metafields_set.json
handle :店铺的唯一标识符,值为店铺域名的前缀。例如,域名为 open001.myshopline.com 的店铺,其 handleopen001
批量操作元字段。若元字段不存在,则直接新增;若存在,则根据输入值进行更新。
请求头
  • Content-Type required
    字段值固定为application/json; charset=utf-8
  • Authorization string required
    资源的访问令牌。请参考 应用授权 获取访问令牌,然后将获取到的访问令牌以 Bearer 格式传入
    Example:
    Bearer eyJhbGciOiJIUzUxMiJ9.eyJhcHBLZXkiOiJmMjM3OWQyMTYyOGMzM2QxMWRiMWZkYjY5N2EzZjdjMjZlNGMwYTA5Iiwic2VsbGVySWQiOiIyMDAwMjM0ODgwIiwic3RvcmVJZCI6IjE2NzIzNjk3Mjk2MDYiLCJ2ZXJzaW9uIjoiVjIiLCJkb21haW4iOiJodHRwczovL3NsLW9wZW4tc2cubXlzaG9wbGluZS5jb20iLCJ0aW1lc3RhbXAiOjE2NzUzMTk0OTI0MzksImlzcyI6Inlzb3VsIiwiZXhwIjoxNzY5OTI3NDkyfQ.UwQzomM2veGCUaOZ0paUxq5dpc7DXuhHYFvsQ_uIAKduzWcb_j2E4q_36El83sp145D4cKbpcE5KCeeIz-JNQw
请求体
  • metafieldsobject[]
    元字段列表。
    最大个数限制:25
  • description string
    元字段的描述信息。
    最大长度限制:255
    Example: This is the description for the Product Care Guidelines metafield
  • key string
    元字段定义在其 namespace 下的唯一标识符。仅支持字母、数字、连字符和下划线字符。
    最小长度限制:3
    最大长度限制:30
    Example: product-guide
  • namespace string
    元字段的命名空间。通过命名空间可对元字段进行分组,避免具有相同健名的元字段发生冲突。通过 keynamespace 可以唯一确定元字段。
    仅支持字母、数字、连字符和下划线字符。
    最小长度限制:2
    最大长度限制:50
    Example: my_fields
  • owner_id string
    元字段所归属的资源 ID。例如,商品 A 的 ID 是 1605898661,当对商品 A 新增元字段时,此时 owner_id1605898661
    最大长度限制:128
    Example: 16058986610866520712462605
  • owner_resource string
    元字段所归属的资源类型。有效枚举值包含:
    • products:商品
    • variants:商品变体
    • collections:商品分类
    • customers:会员
    • orders:订单
    • pages:页面
    • blogs:博客集合
    • articles:博客
    Example: products
  • type string
    元字段支持的数据类型,有效枚举值包含:
    • single_line_text_field:单个单行文本
    • list.single_line_text_field:多个单行文本
    • multi_line_text_field:多行文本
    • color:单个颜色
    • list.color:多个颜色
    • date:单个日期
    • list.date:多个日期
    • date_time:单个日期和时间。格式:ISO 8601
    • list.date_time:多个日期和时间。格式:ISO 8601
    • 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:布尔类型,有效值包括 truefalse
    • money:资金,带币种单位
    关于更多元字段信息,参考 元字段功能使用指南
    Example: multi_line_text_field
  • value object
    存储在元字段中的数据。
    无论你如何定义元字段的类型,SHOPLINE 均将其转换为字符串格式进行存储,转换后的字符串最大长度限制是 500000。
    Example: [object Object]
响应
更多状态码信息请参考 HTTP 状态码

响应头
  • traceId
    traceId
响应体
  • fail_metafieldsobject[]
    更新或新增失败的元字段数据。
  • errors string
    更新或新增失败的错误描述。
  • key string
    元字段定义在其 namespace 下的唯一标识符。仅支持字母、数字、连字符和下划线字符。
    Example: product-guide
  • namespace string
    元字段的命名空间。
    Example: my_fields
  • owner_id string
    元字段所归属的资源 ID。
    Example: 16058986610866520712462605
  • owner_resource string
    元字段所归属的资源类型。有效枚举值包含:
    • products:商品
    • variants:商品变体
    • collections:商品分类
    • customers:会员
    • orders:订单
    • pages:页面
    • blogs:博客集合
    • articles:博客
    Example: products
  • metafieldsobject[]
    更新成功的元字段数据。
  • created_at string
    元字段创建时间。格式:ISO 8601
    Example: 2023-05-31T17:03:43+08:00
  • description string
    元字段的描述信息。
    Example: This is the description for the Product Care Guidelines metafield
  • id long
    元字段 ID。
    Example: 3152668027083
  • key string
    元字段定义在其 namespace 下的唯一标识符。仅支持字母、数字、连字符和下划线字符。
    Example: product-guide
  • namespace string
    元字段的命名空间。
    Example: my_fields
  • owner_id string
    元字段所归属的资源 ID。
    Example: 16058986610866520712462605
  • owner_resource string
    元字段所归属的资源类型。有效枚举值包含:
    • products:商品
    • variants:商品变体
    • collections:商品分类
    • customers:会员
    • orders:订单
    • pages:页面
    • blogs:博客集合
    • articles:博客
    Example: products
  • type string
    元字段支持的数据类型,有效枚举值包含:
    • single_line_text_field:单个单行文本
    • list.single_line_text_field:多个单行文本
    • multi_line_text_field:多行文本
    • color:单个颜色
    • list.color:多个颜色
    • date:单个日期
    • list.date:多个日期
    • date_time:单个日期和时间。格式:ISO 8601
    • list.date_time:多个日期和时间。格式:ISO 8601
    • 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:布尔类型,有效值包括 truefalse
    • money:资金,带币种单位
    关于更多元字段信息,参考 元字段功能使用指南
    Example: multi_line_text_field
  • updated_at string
    元字段更新的时间。格式:ISO 8601
    Example: 2023-05-31T17:03:43+08:00
  • value string
    存储在元字段中的数据。
    Example: This is the metafields assignment content
API Explorer
https://openapiceshidianpu.myshopline.com/admin/openapi/v20250601

ParamOptions

header required

Body

required
{
  "metafields": [
    {
      "description": "This is the description for the Product Care Guidelines metafield",
      "key": "product-guide",
      "namespace": "my_fields",
      "owner_id": "16058986610866520712462605",
      "owner_resource": "products",
      "type": "multi_line_text_field",
      "value": {}
    }
  ]
}

Language

curl --request POST \
--url https://openapiceshidianpu.myshopline.com/admin/openapi/v20250601/metafields_set.json \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJhcHBLZXkiOiJmMjM3OWQyMTYyOGMzM2QxMWRiMWZkYjY5N2EzZjdjMjZlNGMwYTA5Iiwic2VsbGVySWQiOiIyMDAwMjM0ODgwIiwic3RvcmVJZCI6IjE2NzIzNjk3Mjk2MDYiLCJ2ZXJzaW9uIjoiVjIiLCJkb21haW4iOiJodHRwczovL3NsLW9wZW4tc2cubXlzaG9wbGluZS5jb20iLCJ0aW1lc3RhbXAiOjE2NzUzMTk0OTI0MzksImlzcyI6Inlzb3VsIiwiZXhwIjoxNzY5OTI3NDkyfQ.UwQzomM2veGCUaOZ0paUxq5dpc7DXuhHYFvsQ_uIAKduzWcb_j2E4q_36El83sp145D4cKbpcE5KCeeIz-JNQw' \
--header 'Content-Type: application/json; charset=utf-8' \
--header 'accept: application/json' \
--data '
{
"metafields": [
{
"description": "This is the description for the Product Care Guidelines metafield",
"key": "product-guide",
"namespace": "my_fields",
"owner_id": "16058986610866520712462605",
"owner_resource": "products",
"type": "multi_line_text_field",
"value": {}
}
]
}
'
Examples
批量更新元数据
Request
{
"metafields": [
{
"description": "Here is the description for the metafield1.",
"key": "mfkey-1",
"namespace": "mftest",
"owner_id": "16058986610866520712462605",
"owner_resource": "products",
"type": "list.number_decimal",
"value": "[\"0.123\",\"22.33\"]"
},
{
"description": "Here is the description for the metafield2.",
"key": "mfkey-2",
"namespace": "mftest",
"owner_id": "2241475414",
"owner_resource": "customers",
"type": "multi_line_text_field",
"value": "This is the assignment contents for metafields."
}
]
}
Response
{
"fail_metafields": [],
"metafields": [
{
"created_at": "2025-01-23T10:45:19+08:00",
"description": "Here is the description for the metafield2.",
"id": 1813234029606,
"key": "mfkey-2",
"namespace": "mftest",
"owner_id": "2241475414",
"owner_resource": "customers",
"type": "multi_line_text_field",
"updated_at": "2025-02-13T17:10:36+08:00",
"value": "This is the assignment contents for metafields."
},
{
"created_at": "2025-01-23T10:45:19+08:00",
"description": "Here is the description for the metafield1.",
"id": 1813234019606,
"key": "mfkey-1",
"namespace": "mftest",
"owner_id": "16058986610866520712462605",
"owner_resource": "products",
"type": "list.number_decimal",
"updated_at": "2025-02-13T17:10:36+08:00",
"value": "[\"0.123\",\"22.33\"]"
}
]
}
这篇文章对你有帮助吗?

Error loading component.

Error loading component.