post https://{shopdomain}.myshoplaza.com/openapi/2022-01/metafield_definition/
Create a new metafield definition for a specific resource (e.g., product, product_variant, collection).
This API is especially useful for:
- Adding custom fields to extend store data.
- Defining custom attributes for products, variants, or collections.
- Managing resource metadata efficiently.
Note: The operation is scoped to a specific shop, identified by its unique domain prefix (shopdomain), ensuring all updates are applied to the correct store.
Request Parameters
Public Request Parameters
Path Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
owner_resource | string | Yes | The type of resource that the metafield is attached to. Available resources: shop, product, product_image, product_variant, order, page, customer, collection, blog, article. | product_variant |
Body Parameters
| Field | Type | Required | Example | Description |
|---|---|---|---|---|
namespace | string | Yes | custom | Namespace to group metafield definitions. |
key | string | Yes | color_code | Unique key to identify the metafield. |
name | string | Yes | Product Color | Name or title for the metafield definition. |
description | string | No | Custom field for color | Brief description of the metafield definition. |
type | string | Yes | single_line_text_field | Field type for the metafield. Valid Values for type:- date- date_time- weight- volume- dimension- integer- number_decimal- file_reference- single_line_text_field- multi_line_text_field- json- color- rating- url- boolean |
Response Explanation
Public Response Parameters
Successful Response
| Field | Type | Example | Description |
|---|---|---|---|
id | string | 374034306256875562 | Unique identifier for the metafield definition. |
key | string | key2 | Unique key for the metafield. |
name | string | Big | Name or title of the metafield definition. |
namespace | string | test | Namespace of the metafield definition. |
owner_resource | string | product | Resource type the metafield is associated with. |
type | string | boolean | Field type for the metafield. |
description | string | boolean | Description of the metafield definition. |
create_at | string | 2024-04-28T03:18:59Z | Timestamp of when the metafield was created. |
updated_at | string | 2024-04-28T03:18:59Z | Timestamp of the last update for the metafield. |
Error Response
Error responses in the API can be represented using two different fields: errors and error. Both fields provide details about issues encountered during request processing. Below is an explanation of the fields with their respective examples and descriptions.
| Field | Type | Example | Description |
|---|---|---|---|
errors | array | ["Type is invalid"] | A list of errors encountered during the request processing. |
| Field | Type | Example | Description |
|---|---|---|---|
error | String | "store is not active" | Indicates an error encountered during the process |
Error Detail
| Status Code | Message | Possible Reason | Example Response |
|---|---|---|---|
| 400 | Bad Request | Invalid input format or request structure (e.g., missing required fields or incorrect data types). | Bad Request |
| Unauthorized | The request is missing valid authentication credentials or the credentials provided are invalid. | Unauthorized | |
| 422 | "Key is required" | empty key | Key is required |
| Type is required | empty type | Type is required | |
| Name is required | empty name | Name is required | |
| Type is invalid | type is not acceptable | Type is invalid | |
| Owner resource is invalid" | Owner resource is not acceptable | "Owner resource is invalid" | |
| Metafield definition namespace and key exist | Metafield definition namespace and key exist | "Metafield definition namespace and key exist" |
