POST https://{handle}.myshopline.com/admin/openapi/v20250601/metafield_definition.json
handle : The store's unique identifier, which is the prefix of the store's domain name. For example, if a store's domain name is open001.myshopline.com , the store handle is open001 .
metafieldDefinitionCreate
Request Headers
  • Content-Type required
    The value of this field is fixed to application/json; charset=utf-8
  • Authorization string required
    The access token for the API. Please refer to App authorization to obtain the access token, and then put the obtained access token into the API request header in Bearer Token.
    Example:
    Bearer eyJhbGciOiJIUzUxMiJ9.eyJhcHBLZXkiOiJmMjM3OWQyMTYyOGMzM2QxMWRiMWZkYjY5N2EzZjdjMjZlNGMwYTA5Iiwic2VsbGVySWQiOiIyMDAwMjM0ODgwIiwic3RvcmVJZCI6IjE2NzIzNjk3Mjk2MDYiLCJ2ZXJzaW9uIjoiVjIiLCJkb21haW4iOiJodHRwczovL3NsLW9wZW4tc2cubXlzaG9wbGluZS5jb20iLCJ0aW1lc3RhbXAiOjE2NzUzMTk0OTI0MzksImlzcyI6Inlzb3VsIiwiZXhwIjoxNzY5OTI3NDkyfQ.UwQzomM2veGCUaOZ0paUxq5dpc7DXuhHYFvsQ_uIAKduzWcb_j2E4q_36El83sp145D4cKbpcE5KCeeIz-JNQw
Request Body
  • definitionobject required
    Metafield definition
  • accessobject
    Access settings that apply to each metafield that belongs to the metafield definition.
  • admin string
    Admin access settings for metafields under this definition, supports: PRIVATE, MERCHANT_READ, MERCHANT_READ_WRITE
    Example: MERCHANT_READ
  • description string
    A description of the metafield definition.
    Example: This is the description for the Product Care Guidelines metafield
  • key string required
    A metafield is defined as a unique identifier within its namespace. Must be 3-30 characters in length and only supports alphanumeric, hyphen, and underscore characters.
    Example: product-guide
  • name string required
    Define human-readable metafield names.
    Example: Product Care Guide
  • namespace string required
    A metafield defines a container for a set of metafields that will be related. Must be 2-50 characters long, and only alphanumeric, hyphen, and underscore characters are supported.
    1. If app permissions need to be set, the namespace format is: $app:{app-name}
    2. If you do not add $app:{app-name}, it is defined as an ordinary meta field, even if access is entered, this access will not take effect
    Example: $app:testapp
  • owner_resource string required
    The meta field defines the resource object type to attach to: products, customers, orders, pages, variants, collections articles, blogs, draft_orders, smart_collections locations, images, shop
    Example: products
  • type string required
    The type of data that each metafield that belongs to the metafield definition will store. See the list of supported types.
    Example: multi_line_text_field
Response
For more information about status codes, see Http status code.

Response Headers
  • traceId
    traceId
Response Body
  • definitionobject
    definition
  • accessobject
    Access settings that apply to each metafield that belongs to the metafield definition.
  • admin string
    Admin access settings for metafields under this definition, supports: PRIVATE, MERCHANT_READ, MERCHANT_READ_WRITE
    Example: MERCHANT_READ
  • created_at string
    The creation time of the meta field definition.
    Example: 2023-05-26T10:11:26+08:00
  • description string
    A description of the metafield definition.
    Example: This is the description for the Product Care Guidelines meta field
  • id string
    The definition ID of the metafield.
    Example: 71213507083
  • key string
    A metafield is defined as a unique identifier within its namespace. Must be 3-30 characters in length and only supports alphanumeric, hyphen, and underscore characters.
    Example: product-guide
  • name string
    Define human-readable metafield names.
    Example: Product Care Guide
  • namespace string
    A metafield defines a container for a set of metafields that will be associated. Must be 2-50 characters in length and only supports alphanumeric, hyphen, and underscore characters.
    1. If the input parameter is $app:{app-name}, the output will parse the app id in the format: {app}--{your-app-id}--{some-namespace}
    2. If the input parameter is not $app:{app-name}, the output will be the original namespace.
    Example: app--70303--riven or my_fields
  • owner_resource string
    The meta field defines the resource object type to attach to: products, customers, orders, pages, variants, collections articles, blogs, draft_orders, smart_collections locations, images, shop
    Example: products
  • type string
    The type of data that each metafield that belongs to the metafield definition will store. See the list of supported types.
    Example: multi_line_text_field
  • updated_at string
    The last update time of the meta field definition.
    Example: 2023-05-26T10:11:26+08:00
API Explorer
https://openapiceshidianpu.myshopline.com/admin/openapi/v20250601

ParamOptions

header required

Body

required
{
  "definition": {
    "access": {
      "admin": "MERCHANT_READ"
    },
    "description": "This is the description for the Product Care Guidelines metafield",
    "key": "product-guide",
    "name": "Product Care Guide",
    "namespace": "$app:testapp",
    "owner_resource": "products",
    "type": "multi_line_text_field"
  }
}

Language

curl --request POST \
--url https://openapiceshidianpu.myshopline.com/admin/openapi/v20250601/metafield_definition.json \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJhcHBLZXkiOiJmMjM3OWQyMTYyOGMzM2QxMWRiMWZkYjY5N2EzZjdjMjZlNGMwYTA5Iiwic2VsbGVySWQiOiIyMDAwMjM0ODgwIiwic3RvcmVJZCI6IjE2NzIzNjk3Mjk2MDYiLCJ2ZXJzaW9uIjoiVjIiLCJkb21haW4iOiJodHRwczovL3NsLW9wZW4tc2cubXlzaG9wbGluZS5jb20iLCJ0aW1lc3RhbXAiOjE2NzUzMTk0OTI0MzksImlzcyI6Inlzb3VsIiwiZXhwIjoxNzY5OTI3NDkyfQ.UwQzomM2veGCUaOZ0paUxq5dpc7DXuhHYFvsQ_uIAKduzWcb_j2E4q_36El83sp145D4cKbpcE5KCeeIz-JNQw' \
--header 'Content-Type: application/json; charset=utf-8' \
--header 'accept: application/json' \
--data '
{
"definition": {
"access": {
"admin": "MERCHANT_READ"
},
"description": "This is the description for the Product Care Guidelines metafield",
"key": "product-guide",
"name": "Product Care Guide",
"namespace": "$app:testapp",
"owner_resource": "products",
"type": "multi_line_text_field"
}
}
'
Examples
Failure : Metafield definition already exists
Request
{
"definition": {
"access": {
"admin": "MERCHANT_READ"
},
"description": "这是商品保养指南元字段的描述说明",
"key": "key-1",
"name": "商品保养指南",
"namespace": "$app:seotest",
"owner_resource": "products",
"type": "multi_line_text_field"
}
}
Response
{}
Was this article helpful to you?