Get Metafield
This GET endpoint retrieves a single metafield by its unique ID.
Endpoint
- URL:
/api/metafields/:id - Method:
GET
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Request Headers
| Header | Type | Description |
|---|---|---|
accessToken | string | Access token for authentication. (required) |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the metafield. (required) |
Sample Request
curl --location '<BASE-URL>/metafields/507f1f77bcf86cd799439011' \
--header 'accessToken: <ACCESS-TOKEN>'
Response
- Status Code: 200 OK
Sample Response Body
{
"success": true,
"data": {
"_id": "507f1f77bcf86cd799439011",
"fieldType": "product",
"label": "Brand Name",
"description": "The brand of the product",
"code": "brand_name",
"allowAdminUpdate": true,
"displayStorefront": true,
"displayAdmin": true,
"hasPredefinedValues": false,
"displayFilter": true,
"predefinedValues": [],
"valueType": "text",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}
}
Success Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
data | object | The metafield object. |
Metafield Object Fields
| Field | Type | Description |
|---|---|---|
_id | string | Unique identifier for the metafield. |
fieldType | string | The entity type this metafield applies to. |
label | string | Display label for the metafield. |
description | string | Optional description of the metafield's purpose. |
code | string | Unique code identifier (combined with fieldType). |
allowAdminUpdate | boolean | Whether admin can update this field. |
displayStorefront | boolean | Whether this field is visible on storefront. |
displayAdmin | boolean | Whether this field is visible in admin panel. |
hasPredefinedValues | boolean | Whether this field has predefined values (for select types). |
displayFilter | boolean | Whether this field can be used as a filter. |
predefinedValues | array | Array of predefined values (if hasPredefinedValues is true). |
valueType | string | Data type of the metafield value. |
createdAt | string | ISO 8601 timestamp of when the metafield was created. |
updatedAt | string | ISO 8601 timestamp of when the metafield was last updated. |
Supported Field Types
customercompanyshippingAddressbillingAddresscategoryproductvariantorderinvoicesalesRepshippingMethod
Supported Value Types
text- Plain text stringnumber- Numeric valuefile- File uploadjson- JSON objectselect- Single selection from predefined valuesdateTime- Date and timeboolean- True/false valueproduct- Product referencemulti-text- Multiple text valuesrange- Numeric rangehtml-markdown- HTML or Markdown contentnumberRange- Numeric range with min/max
Error Response
- Status Code: 400 Bad Request
{
"success": false,
"message": "Error message describing what went wrong"
}
Common Error Scenarios
- Invalid metafield ID format
- Metafield not found with the given ID
- Unauthorized access (missing or invalid access token)