Unable to create metafield definition with ownerType API_PERMISSION

I’m trying to create metafield definition (not actual metafield) using this mutation

mutation metafieldDefinitionCreate($definition: MetafieldDefinitionInput!) {
  metafieldDefinitionCreate(definition: $definition) {
    createdDefinition {
        id
        name
    }
    userErrors {
      field
      message
    }
  }
}

and this is payload

{
  "definition": {
    "key": "test_123",
    "name": "Test name",
    "namespace": "test_123",
    "ownerType": "API_PERMISSION",
    "type": "json",
    "visibleToStorefrontApi": true
  }
}

I’m getting this error

{
    "data": {
        "metafieldDefinitionCreate": {
            "createdDefinition": null,
            "userErrors": [
                {
                    "field": [
                        "definition",
                        "ownerType"
                    ],
                    "message": "Owner type is not included in the list"
                }
            ]
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 10,
            "actualQueryCost": 10,
            "throttleStatus": {
                "maximumAvailable": 1000.0,
                "currentlyAvailable": 990,
                "restoreRate": 50.0
            }
        }
    }
}

What does it mean for me `

Owner type is not included in the list` what list, why this is not included? this type of error message doesn’t help at all, i can’t find anything about this in Shopify doc as well.

Can someone please help.

To be clear - I’m not creating metafield, i’m creating metafield definition.

1 Like