Create Metafield

Create a new metafield

The Create Metafield API allows create a new custom metafield attached to a specific resource in the store. Metafields are custom data fields that can store additional information about the resources.

This API is especially useful for:

  1. Extending the functionality of data management by adding custom metadata.

Request Parameters

Public Request Parameters

📘

Path Parameters

ParameterTypeRequiredDescription
owner_resourcestringYesResource type to attach metafield
Valid values: shop, product, product_image, product_variant, order, page, customer, collection, blog, article
owner_idstringYesUnique identifier of the target resource

Body Parameters

ParameterTypeRequiredDescriptionExample Value
definition_idstringNoSystem identifier for metafield configuration"global"
namespacestringYesLogical container for grouping related metafields"color"
keystringYesUnique identifier within the namespace"string"
valuestringYesContent value matching the specified type"#FF0000" (for color)
typestringYesData format specification
Valid values: date, date_time, weight, volume, dimension, integer, number_decimal, file_reference, single_line_text_field, json, multi_line_text_field, color, rating, url, boolean
"The main color of the product"
descriptionstringNoHuman-readable explanation of purpose"df_12345"

Response Explanation

Public Response Parameters

📘

Successful Response

FieldTypeExampleDescription
codestring"Success"Response status (e.g., "Success").
messagestring"Metafield created successfully"Response message.
dataobjectContains the created metafield data.
data.metafield.idstring"mf_001"Unique ID of the created metafield.
data.metafield.store_idinteger12345ID of the store that owns the metafield.
data.metafield.owner_resourcestring"product"Resource type that owns the metafield (e.g., "product").
data.metafield.owner_idstring"prod_001"ID of the owner resource.
data.metafield.namespacestring"global"Namespace of the metafield.
data.metafield.keystring"color"Key of the metafield.
data.metafield.typestring"string"Type of the metafield ("json" or "string").
data.metafield.descriptionstring"Product primary color"Description of the metafield.
data.metafield.definition_idstring"df_12345"ID of the metafield definition (if applicable).
data.metafield.created_atstring"2023-10-25T14:30:00Z"Timestamp when the metafield was created (ISO 8601 format).
data.metafield.updated_atstring"2023-10-25T14:30:00Z"Timestamp when the metafield was last updated (ISO 8601 format).

Error Response

FieldTypeExampleDescription
codestringInvalidParameterError http message
messagestring``Error message

API Structure Overview

Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!