Metaobjects
Create custom structured content types â FAQs, testimonials, size guides, team members â and render them in Liquid templates or query them via the GraphQL Storefront API.
Overview
Metaobjects let you define custom content schemas and populate them with structured entries. Unlike Metafields (which attach extra data to existing entities), Metaobjects are standalone content types you design from scratch.
- Define schemas with typed fields (16 field types supported)
- Create entries via Admin REST API or admin UI
- Access entries globally in all Liquid templates
- Query via GraphQL Storefront API for headless frontends
- Per-definition access control:
storefrontoradmin_only
Creating Definitions
A MetaobjectDefinition describes the schema for a content type: its unique type handle, display name, access level, and the list of typed fields.
// Create a metaobject definition
const response = await fetch(
"https://cartly.pro/admin/metaobject-definitions",
{
method: "POST",
headers: {
"Authorization": `Bearer ${adminToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "FAQ Item",
type: "faq_item",
access: "storefront",
fields: [
{ key: "question", name: "Question", type: "single_line_text", required: true },
{ key: "answer", name: "Answer", type: "multi_line_text", required: true },
],
}),
}
);
// { id: "...", type: "faq_item", name: "FAQ Item", access: "storefront", fields: [...] }The type field becomes the key used to access entries in Liquid and GraphQL. Use lowercase snake_case (e.g., faq_item, team_member).
Managing Entries
Create, update, and delete entries for any definition via the Admin API. Each entry has a unique handle within its type.
// Create a metaobject entry
const response = await fetch(
"https://cartly.pro/admin/metaobjects/faq_item",
{
method: "POST",
headers: {
"Authorization": `Bearer ${adminToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
handle: "faq-shipping",
fields: {
question: "How long does shipping take?",
answer: "Standard delivery takes 3â5 business days.",
},
}),
}
);
// { id: "...", type: "faq_item", handle: "faq-shipping", fields: { ... } }Available entry endpoints:
GET /admin/metaobjects/:typeâ list entriesPOST /admin/metaobjects/:typeâ create entryGET /admin/metaobjects/:type/:idâ get entryPUT /admin/metaobjects/:type/:idâ update entryDELETE /admin/metaobjects/:type/:idâ delete entry
GraphQL API
Query metaobjects via the GraphQL Storefront API. Only definitions with access: "storefront" are accessible; admin_only definitions return an empty result.
# Query entries of a type
query FAQItems {
metaobjects(type: "faq_item", first: 20) {
id
handle
fields {
key
value
type
}
}
}
# Query a single entry by handle
query FAQItem($handle: String!) {
metaobject(type: "faq_item", handle: $handle) {
id
fields {
key
value
}
}
}Access Control
Each definition has an access field with two possible values:
storefrontâ entries are publicly accessible in Liquid templates and the GraphQL API. Use this for FAQs, testimonials, size guides, and other content that should appear on the storefront.admin_onlyâ entries are only visible in the admin panel. GraphQL queries for these types return an empty list. Liquid context does not include these entries. Use this for internal reference data that should not be exposed publicly.
Using in Liquid
All storefront metaobject entries are automatically injected into the Liquid rendering context. Access them via metaobjects.<type>.entries in any template, layout, or section â no additional setup required.
{%- comment -%}
Iterate over all FAQ entries injected into the Liquid context.
Limit: 50 entries per type, 250 total across all types.
{%- endcomment -%}
{% if metaobjects.faq_item %}
<section class="faq">
<h2>Frequently Asked Questions</h2>
{% for entry in metaobjects.faq_item.entries %}
<details>
<summary>{{ entry.fields.question }}</summary>
<p>{{ entry.fields.answer }}</p>
</details>
{% endfor %}
</section>
{% endif %}
{%- comment -%}
For more than 50 entries, use the GraphQL Storefront API instead.
{%- endcomment -%}Safety Limits
To keep Liquid rendering fast, the following limits apply to the injected context:
- 50 entries per type â only the first 50 entries of each definition are injected
- 250 entries total â across all types combined, maximum 250 entries per render
For more entries, use the GraphQL Storefront API which supports pagination and has no built-in limit.
Cache Invalidation
Cartly uses a Redis version counter per metaobject type. When you create, update, or delete an entry, the counter is incremented and included in the Liquid page cache key â ensuring cached pages are automatically invalidated when content changes.
Cartly also sends async CDN purge requests to Gcore via Surrogate-Key headers on Liquid responses. Pages are tagged with their metaobject types (e.g., mo:faq_item), enabling targeted invalidation without flushing the entire cache. Requires GCORE_API_KEY and GCORE_RESOURCE_ID environment variables.
Field Types
The following field types are supported in MetaobjectDefinition fields:
single_line_textâ short plain textmulti_line_textâ multiline plain textintegerâ whole numberdecimalâ decimal numberbooleanâtrue/falsedateâ ISO 8601 datedate_timeâ ISO 8601 date and timeurlâ validated URLcolorâ hex color string (#ff6600)jsonâ arbitrary JSON valuerich_textâ HTML rich textmoneyâ monetary amount (integer cents + currency code)file_referenceâ reference to an uploaded media fileproduct_referenceâ reference to a product by IDcollection_referenceâ reference to a collection by IDmetaobject_referenceâ reference to another metaobject entry by ID