An app can declare its own custom content (metaobject) types, such as an author or a size chart, in declared_metaobjects of tringify.app.json or in the Developer Portal. Installing the app creates them in the store, owned by the app; merchants see them under Content > Custom content with your app's name. Your app manages their fields; by default the entries are the merchant's data, which merchants and your app both edit, and each type's access settings can keep them to your app.
{
"declared_metaobjects": [
{
"handle": "author",
"name": "Author",
"display_field": "name",
"web_pages": true,
"address": "authors",
"schema_kind": "person",
"app_access": "shared",
"merchant_access": "read_write",
"fields": [
{ "key": "name", "name": "Name", "type": "string", "required": true, "searchable": true },
{ "key": "bio", "name": "Bio", "type": "rich_text", "translatable": true },
{ "key": "photo", "name": "Photo", "type": "file_reference" },
{ "key": "favourite", "name": "Favourite book", "type": "metaobject_reference", "metaobject_type": "book" }
]
},
{
"handle": "book",
"name": "Book",
"display_field": "title",
"merchant_access": "read",
"fields": [ { "key": "title", "name": "Title", "type": "string", "required": true } ]
}
],
"declared_metafields": [
{ "owner_type": "product", "key": "author", "name": "Author", "type": "metaobject_reference", "metaobject_type": "author" }
]
}
Each type has the shape of a theme's config/metaobjects.json entry, without sample entries: handle, name, optional description, display_field (a single line text field), web_pages, address, schema_kind (person, place, faq_page or none), the access settings app_access, merchant_access and storefront_visible (see Access settings below) and fields. A field has key, name, type (any metafield type), and optional description, required, choices (select types), translatable, searchable, and metaobject_type for a reference to another of your declared types. A configuration without declared_metaobjects declares none.
Handles#
A declared handle is stored as app--{app handle}--{handle}: the type author of the app with handle reviews is app--reviews--author. The app-- prefix belongs to apps; merchants and themes cannot use it, so your types never collide with theirs or another app's. In the Store API, name your own types $app:{handle} (for example ?type=$app:author) wherever a type id or handle is accepted.
Install, update and uninstall#
Installing the app, and updating an installed app to a new release, creates the types or updates them: fields your release newly declares are added, and existing fields take the declared name, description, translatable and searchable settings. A field is never removed and never changes type. Web pages are turned on when declared (at creation, or by the first release that declares them); if the address is in use, or a redirect already starts there, the type is created without web pages, the type shows
requested_addressandaddress_conflict, and Store Admin asks the merchant to choose an address. Once a type has an address, the merchant owns it and the web page setting: later releases never change or remove them, and uninstalling or reinstalling keeps them.A type the store already has under your handle is taken back only when your app handed it over on an earlier uninstall and its fields still match. Anything else is skipped: the other types and metafields still apply, and metafields pointing at a skipped type are not added. The store's plan allowance never refuses or skips your types: app types and their entries do not count toward it (see Limits).
Uninstalling the app gives its types and entries to the merchant, who can then change or delete them; nothing is deleted. Handed-over types become
sharedandread_write;storefront_visiblestays. From then on they count toward the store's allowance; a store that goes over it keeps everything working and only creating new types or entries waits. The uninstall confirmation lists them, with how far keeping them would take the store over its allowance, and the merchant keeps each type (the default) or deletes it with its entries (the confirmation shows the entries, menu items and references that go with it; a type something still points at is left empty as the merchant's). Reinstalling takes kept types back, and never tightens their access: each setting stays at whichever is more open, the merchant's or your declared one.Every change fires
metaobject_definitions/createormetaobject_definitions/update; the payload'sownerisapp,owner_refyour app's id andowner_nameits name. A hand-over firesmetaobject_definitions/updatewithchanged_fields["owner"],ownermerchantandowner_refstill your app's id.
Access settings#
Each declared type takes the access settings of app metafields, with the same option ids. A later release may only open them (private to shared, hidden to read to read_write, not visible to visible); narrowing one is refused with METAOBJECT_APP_TYPE_SETTING_NARROWED.
Setting |
Values |
What it means |
|---|---|---|
|
|
Private types and their entries reach only your app: other apps get |
|
|
|
|
|
False keeps the entries off the storefront: theme |
A metafield may not show more than the type it points to: a shared metafield cannot point to a private type, a storefront visible one to a type that is not, and one merchants see to a hidden type. Merchants' metafields can point only to shared types they see. Files have no privacy setting: never store secrets in files, which are always visible to the merchant.
Access#
Your app's token reads your types and lists, reads, creates, updates and deletes their entries (including bulk upsert and where an entry is used) without read_metaobjects or write_metaobjects. Translations still need read_translations / write_translations. The merchant's types, other apps' types, types your app handed over, and creating, changing or deleting types through the API all need the metaobject scopes. Without the scope, listing types returns only yours, and any other type answers STORE_API_SCOPE_REQUIRED.
Limits#
Scope |
Limit |
|---|---|
Custom content types per app |
10 (not counted toward the store's plan allowance) |
Entries across your app's types, per store |
25000 (not counted toward the store's plan allowance) |
Fields per type |
40 |
Type handle |
Lowercase letters, numbers, hyphens and underscores, starting with a letter, at most 64 characters, unique in your app |
Released types and fields |
Cannot be removed or change type in a later release; add new ones instead |