Define Metafields via Admin-API in PHP (Admin2024_01)

Hello,

the API documentation for the PHP programming language is horrible. It’s hard to understand anything.

I need to migrate a lot of data from OXID Shop System to Shopify. :see_no_evil_monkey:

Actually, I am trying to create some metafields for collections. We want to display a text for search engines on the collection page below, under the pagination.

In the first step, I just want to create/define some meta fields and then assign the values for each collection in a for-each loop.

This is the documentation:
https://shopify.dev/docs/api/admin-rest/2024-01/resources/metafield#post-blogs-blog-id-metafields

The title is “Create meta fields”.

It’s not clear what they mean by “create”.

Create an assignment → assign / set a value to an object
or
Create a definition → create a new meta field with name and description to assign/set the values later?

Or does this call automatically check if the definition already exists and create it if not.

It is extremely wired. Why do I have the option to specify a description as a parameter that is never used, and why can’t I specify a name?

I have uploaded 2 screenshots:

Hi - It may actually be easier to use the GraphQL API rather than the REST API for this, with the metafieldDefinitionCreate mutation. There’s an example of what this could look like in our developer docs.