Cannot change app metafield type from number_integer to single_line_text_field - How to delete and recreate?

I have an existing app-owned metafield definition that I need to change:

Current app metafield:

[product.metafields.app.hsn]
type = "number_integer"
name = "HSN Code"
description = "Harmonized System Nomenclature (HSN) code for product"
capabilities.admin_filterable = true

What I need:

[product.metafields.app.hsn]
type = "single_line_text_field"
name = "HSN Code"
description = "Harmonized System Nomenclature (HSN) code for product"
capabilities.admin_filterable = true

Reason for change:
We need to store HSN codes with leading zeros (e.g., “0101”, “0203”) but number_integer strips them (becomes 101, 203). The single_line_text_field type would preserve the leading zeros which are significant for HSN classification.

Problem:
When I update the metafield type in shopify.app.toml and run shopify app deploy, I get this error:

[product.metafields.app.hsn] Cannot change type of existing metafield definition - type: number_integer

What I’ve tried:

  1. Removed the metafield from shopify.app.toml and deployed - The metafield definition still exists in Shopify’s database, so I get the same error when trying to add it back with a different type

  2. Looked for it in Settings > Custom data - App-owned metafields (namespace: app) don’t appear in the Shopify admin UI, so I can’t delete it manually

  3. Tried to find a CLI command - There doesn’t seem to be a shopify app config metafields delete command

Questions:

  1. How do I delete an app-owned metafield definition? Is there a GraphQL mutation like metafieldDefinitionDelete that works for app metafields?

  2. Is changing metafield types supported at all? Or is the only option to create a new metafield key (e.g., app.hsn_code) and migrate data?

  3. If I need to use GraphQL to delete it, what’s the proper mutation? I tried finding the metafield definition ID but need confirmation this is the right approach for app metafields.

Environment:

  • App type: Remix app with Shopify Admin UI extensions

  • Metafield namespace: app (app-owned)

  • Current type: number_integer

  • Desired type: single_line_text_field

Workaround I’m considering:
Create a new metafield app.hsn_code with single_line_text_field type, migrate existing data, then deprecate the old app.hsn metafield.

Is there a better way to handle this? Any help would be appreciated!

Hey again @Aswin_Ashok , hope all’s well! :waving_hand:

Just a quick question to confirm, did your current app originally create this product.metafields.app.hsn metafield definition, or was it created by a previous app with a different app ID? Wanted to confirm this since app-owned metafields (namespace app) are tied to the specific app’s client ID that created them, and only that app can modify or delete the definition via GraphQL.

If you inherited this Remix app or migrated from another setup, you might be trying to manage a metafield that’s still “owned” by the old app’s credentials, which would explain why it won’t budge. Another thing to check, if it was owned by your current app, are you able to run the metafield definition delete mutation here to remove it?

If that doesn’t work, and you can confirm that your app should own the metafield, just let me know and we can keep looking into this for sure.