Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Save app-owned meta fields

Save app-owned meta fields

Potices
Shopify Partner
2 0 0

I am trying to build a simple app, that allows merchants to call an API. In order to do so, I need the merchants API key. I have a text field and a button, and when the button is pressed I want the api key to be saved.

 

As far as I can tell, the best way to do this, is to use app-owned meta fields.

But in order to save this data, I need my OwnerID. But I cannot find any documentation for how to get this? Hope someone can help me out.

 

Thanks.

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 524

Hey @Potices - the OwnerID is the same number as your app's installation object's ID. To get the installation ID, you can run a simple query like this:

 

 {
  app (id:"gid://shopify/App/[insert app ID here]") {
    title
    installation {
      id
    }
  }
}

 

This should output the app's installation ID which you can then define as a value in the app-owned metafields call like this:

{
"namespace": "secret_keys",
"key": "api_key",
"type": "single_line_text_field",
"value": "example_value",
"ownerId": "gid://shopify/AppInstallation/[your-app's-installation-id]"
}
]
}


Hope this helps!


Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog