Skip to main content

Manage entries

Metaobjects let you store structured data with multiple related field values. This guide shows you how to create, read, update, and delete metaobject entries using the GraphQL Admin API.



Create metaobject entries to store instances of structured data based on your metaobject definitions.

Anchor to Create a basic entryCreate a basic entry

This example creates a size chart metaobject entry with basic field values. Both the field keys and type must match the existing metaobject definition.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation CreateSizeChartEntry {
metaobjectCreate(metaobject: {
type: "size_chart"
fields: [
{ key: "size", value: "Medium" }
{ key: "chest_inches", value: "38" }
{ key: "waist_inches", value: "32" }
{ key: "hip_inches", value: "36" }
]
}) {
metaobject {
id
handle
displayName
fields {
key
value
}
}
userErrors {
field
message
}
}
}

Anchor to Create an entry with capabilitiesCreate an entry with capabilities

If your metaobject definition has capabilities enabled (such as publishable), set their initial state when creating entries. This example creates an author metaobject with publishable status set to active.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation CreatePublishableEntry {
metaobjectCreate(metaobject: {
type: "$app:author"
capabilities: {
publishable: {
status: ACTIVE
}
}
fields: [
{ key: "full_name", value: "Jane Smith" }
{ key: "bio", value: "Award-winning author with 20 years of experience..." }
{ key: "email", value: "jane@example.com" }
]
}) {
metaobject {
id
handle
displayName
capabilities {
publishable {
status
}
}
}
userErrors {
field
message
}
}
}

Anchor to Create entries in batchCreate entries in batch

When you need to create many metaobject entries, use bulk operations for better performance. This is more efficient than making separate requests for each entry.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation CreateBulkEntries {
bulkOperationRunMutation(
mutation: """
mutation createMetaobject($input: MetaobjectCreateInput!) {
metaobjectCreate(metaobject: $input) {
metaobject { id }
userErrors { field message }
}
}
"""
stagedUploadPath: "bulk_ops/metaobjects_create.jsonl"
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}

Query metaobject entries to retrieve their data using various approaches.

Anchor to Query entries by typeQuery entries by type

Retrieve all metaobject entries of a specific type. This is useful when you need to list all entries, such as displaying all size charts or author profiles.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
query GetSizeCharts {
metaobjects(type: "size_chart", first: 10) {
edges {
node {
id
handle
displayName
fields {
key
value
}
}
}
}
}

Anchor to Query a specific entry by handleQuery a specific entry by handle

Retrieve a single metaobject using its handle. Handles are URL-friendly identifiers for referencing specific entries.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
query GetMetaobjectByHandle {
metaobjectByHandle(handle: {
type: "size_chart"
handle: "medium"
}) {
id
handle
displayName
fields {
key
value
}
updatedAt
}
}

Anchor to Query a specific entry by IDQuery a specific entry by ID

Retrieve a metaobject entry using its global ID. This is useful when you have the ID stored and need to fetch the entry's current state.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
query GetMetaobjectById {
metaobject(id: "gid://shopify/Metaobject/123") {
id
handle
displayName
type
fields {
key
value
type
}
capabilities {
publishable {
status
}
}
}
}

Anchor to Query specific fieldsQuery specific fields

Optimize queries by requesting only the fields you need.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
query GetSpecificFields {
metaobject(id: "gid://shopify/Metaobject/123") {
field(key: "full_name") {
value
}
emailField: field(key: "email") {
value
}
}
}

Filter metaobject entries based on field values. This is useful for finding entries that match specific criteria, such as all size charts for "Large" sizes.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
query GetFilteredMetaobjects {
metaobjects(
type: "size_chart"
first: 10
query: "size:Large"
) {
edges {
node {
id
displayName
fields {
key
value
}
}
}
}
}

Modify existing metaobject entries to change field values or capability states.

Update one or more field values in a metaobject entry. Optimize the operation by including only the fields you want to change.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation UpdateSizeChart {
metaobjectUpdate(
id: "gid://shopify/Metaobject/123"
metaobject: {
fields: [
{ key: "chest_inches", value: "40" }
{ key: "waist_inches", value: "34" }
]
}
) {
metaobject {
id
fields {
key
value
}
updatedAt
}
userErrors {
field
message
}
}
}
Note

You can't change the metaobject type after it's created. Field keys must match those defined in the metaobject definition, and field values must match their defined types.

Anchor to Update published statusUpdate published status

For metaobjects with the publishable capability enabled, change their published status to control visibility on the storefront.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation PublishMetaobject {
metaobjectUpdate(
id: "gid://shopify/Metaobject/123"
metaobject: {
capabilities: {
publishable: {
status: ACTIVE
}
}
}
) {
metaobject {
id
capabilities {
publishable {
status
}
}
}
userErrors {
field
message
}
}
}

When you need to update many metaobject entries, use bulk operations for better performance.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation BulkUpdateMetaobjects {
bulkOperationRunMutation(
mutation: """
mutation updateMetaobject($id: ID!, $metaobject: MetaobjectUpdateInput!) {
metaobjectUpdate(id: $id, metaobject: $metaobject) {
metaobject { id }
userErrors { field message }
}
}
"""
stagedUploadPath: "bulk_ops/metaobjects_update.jsonl"
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}

Remove metaobject entries that are no longer needed using the GraphQL Admin API.

Anchor to Delete a single entryDelete a single entry

Delete a metaobject entry using its global ID.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation DeleteMetaobject {
metaobjectDelete(
id: "gid://shopify/Metaobject/123"
) {
deletedId
userErrors {
field
message
}
}
}

When you need to delete many metaobject entries, use bulk operations for better performance.

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation BulkDeleteMetaobjects {
bulkOperationRunMutation(
mutation: """
mutation deleteMetaobject($id: ID!) {
metaobjectDelete(id: $id) {
deletedId
userErrors { field message }
}
}
"""
stagedUploadPath: "bulk_ops/metaobjects_delete.jsonl"
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}

Anchor to Connecting metaobjects to resourcesConnecting metaobjects to resources

One of the most powerful patterns with metaobjects is connecting them to Shopify resources using metafields. Reference type metafields store links to metaobject entries, enabling you to create reusable structured data that can be attached to products, orders, and other resources.

How it works:

  1. Create definitions (metaobject + metafield) in your TOML configuration and deploy
  2. Create metaobject entries (such as "Waterproof", "Eco-friendly", "Durable")
  3. Attach entries to products by setting the metafield value

Why use this pattern:

  • Reusability: Create a feature (such as 'Waterproof') once, reference it from 100 products
  • Maintainability: Update the feature entry, and it updates everywhere it's referenced
  • Structure: Features have consistent fields (title, description, icon) defined by the metaobject definition

Reference types available:

  • metaobject_reference - Link to a single metaobject entry
  • list.metaobject_reference - Link to multiple entries of the same metaobject type
  • mixed_reference - Link to entries from different metaobject types

Anchor to Step 1: Create definitionsStep 1: Create definitions

Define the metaobject structure and the metafield that references it:

TOML

shopify.app.toml
# Metaobject definition
[metaobjects.app.product_feature]
name = "Product Feature"

[metaobjects.app.product_feature.fields.title]
type = "single_line_text_field"
name = "Title"

[metaobjects.app.product_feature.fields.description]
type = "multi_line_text_field"
name = "Description"

[metaobjects.app.product_feature.fields.icon]
type = "file_reference"
name = "Icon"

# Metafield definition that references the metaobject
[product.metafields.product_info.features]
type = "list.metaobject_reference<$app:product_feature>"
name = "Product Features"

Deploy the definitions:

shopify app deploy

Anchor to Step 2: Create metaobject entriesStep 2: Create metaobject entries

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation CreateWaterproofFeature {
metaobjectCreate(metaobject: {
type: "product_feature"
fields: [
{ key: "title", value: "Waterproof" }
{ key: "description", value: "Protected against water damage" }
]
}) {
metaobject {
id # gid://shopify/Metaobject/789
handle
}
userErrors {
field
message
}
}
}

Anchor to Step 3: Attach metaobject entries to a productStep 3: Attach metaobject entries to a product

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation AttachFeaturesToProduct {
productUpdate(input: {
id: "gid://shopify/Product/456"
metafields: [{
namespace: "product_info"
key: "features"
type: "list.metaobject_reference"
value: "[\"gid://shopify/Metaobject/789\", \"gid://shopify/Metaobject/790\"]"
}]
}) {
product {
metafield(namespace: "product_info", key: "features") {
references(first: 10) {
nodes {
... on Metaobject {
handle
fields { key value }
}
}
}
}
}
userErrors {
field
message
}
}
}

Metaobject handles are URL-friendly identifiers used to reference entries.

Anchor to Auto-generated handlesAuto-generated handles

By default, Shopify generates handles from the display name:

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation CreateWithAutoHandle {
metaobjectCreate(metaobject: {
type: "size_chart"
fields: [
{ key: "size", value: "Extra Large" }
]
}) {
metaobject {
handle # Will be "extra-large"
displayName
}
}
}

Specify a custom handle for more control:

GraphQL

POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
mutation CreateWithCustomHandle {
metaobjectCreate(metaobject: {
type: "size_chart"
handle: "xl-size-chart"
fields: [
{ key: "size", value: "Extra Large" }
]
}) {
metaobject {
handle
displayName
}
userErrors {
field
message
}
}
}

Common errors when managing metaobject entries:

ErrorCauseSolution
UNDEFINED_OBJECT_TYPENo metaobject definition exists for this typeCreate the definition first or check the type identifier
OBJECT_FIELD_REQUIREDA required field value is not providedInclude all required fields in the mutation
UNDEFINED_OBJECT_FIELDField key doesn't exist in the definitionVerify field keys match the definition
CAPABILITY_NOT_ENABLEDTrying to use a capability not enabled on the definitionEnable the capability on the definition first

  • Use meaningful handles: Choose handles that clearly identify the entry's purpose.
  • Validate before creating: Check that all required fields are provided and values match expected types.
  • Use bulk operations for scale: When creating, updating, or deleting many entries, use bulk operations for better performance.
  • Query only needed fields: Optimize API usage by requesting only the fields you need.
  • Handle errors gracefully: Check userErrors in responses and provide clear feedback.
  • Consider capability states: Set appropriate published/unpublished states for publishable metaobjects.

Common issues and solutions when working with metaobject entries:

IssuePossible CausesSolution
Entry not appearing on storefrontMissing storefront access, unpublished entry, or incorrect queryVerify the definition has storefront: PUBLIC_READ access, check if the entry is published (for publishable metaobjects), and ensure your storefront query includes the correct type
Unable to update entryMissing permissions, incorrect ID, or invalid field keysConfirm you have write access to the metaobject type, check that the entry ID is correct and the entry still exists, and verify field keys match the definition
Bulk operation failingInvalid JSONL format, missing required fields, or file size issuesValidate your JSONL file format, check that all entries have required fields, ensure file size is within limits, and review bulk operation status for specific error details


Was this page helpful?