I’m POSTing a metafield to order thru the rest API. How do create a definition for the metafield?
Metafields enable you to customize the functionality and appearance of
your Shopify store by letting you save specialized information that isn’t
usually captured in the Shopify admin. You can use metafields for internal
tracking, or to display specialized information on your online store in a
variety of ways.
I know.
My question was how to define definition via the rest API.
Unfortunately, that isn’t possible in REST API for now as far as i know.
I encountered the same problem and it is possible using the GraphQL API . For my project i use PHPShopify SDK and as you can see in the documentation, it is possible to use GraphQL using that.
I know this post is kind of old, but this might help future people.
Here is an example of what i used.
$input = [
"definition" => [
"namespace" => 'my_namespace',
"key" => 'my_key',
"type" => 'my_type,
"name" => 'my_name',
"ownerType" => "PRODUCT",
"visibleToStorefrontApi" => true,
"description" => 'this is a description'
]
];
$graphQL = <<