Skip to content
Cartly Developers

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: storefront or admin_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.

javascriptPOST /admin/metaobject-definitions
// 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.

javascriptPOST /admin/metaobjects/: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 entries
  • POST /admin/metaobjects/:type — create entry
  • GET /admin/metaobjects/:type/:id — get entry
  • PUT /admin/metaobjects/:type/:id — update entry
  • DELETE /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.

graphqlGraphQL queries for metaobjects
# 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.

liquidRendering metaobjects in Liquid templates
{%- 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 text
  • multi_line_text — multiline plain text
  • integer — whole number
  • decimal — decimal number
  • boolean — true / false
  • date — ISO 8601 date
  • date_time — ISO 8601 date and time
  • url — validated URL
  • color — hex color string (#ff6600)
  • json — arbitrary JSON value
  • rich_text — HTML rich text
  • money — monetary amount (integer cents + currency code)
  • file_reference — reference to an uploaded media file
  • product_reference — reference to a product by ID
  • collection_reference — reference to a collection by ID
  • metaobject_reference — reference to another metaobject entry by ID