Skip to main content

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

HeaderTypeDescription
accessTokenstringAccess token for authentication. (required)

Path Parameters

ParameterTypeDescription
idstringThe 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

FieldTypeDescription
successbooleanIndicates if the request was successful.
dataobjectThe metafield object.

Metafield Object Fields

FieldTypeDescription
_idstringUnique identifier for the metafield.
fieldTypestringThe entity type this metafield applies to.
labelstringDisplay label for the metafield.
descriptionstringOptional description of the metafield's purpose.
codestringUnique code identifier (combined with fieldType).
allowAdminUpdatebooleanWhether admin can update this field.
displayStorefrontbooleanWhether this field is visible on storefront.
displayAdminbooleanWhether this field is visible in admin panel.
hasPredefinedValuesbooleanWhether this field has predefined values (for select types).
displayFilterbooleanWhether this field can be used as a filter.
predefinedValuesarrayArray of predefined values (if hasPredefinedValues is true).
valueTypestringData type of the metafield value.
createdAtstringISO 8601 timestamp of when the metafield was created.
updatedAtstringISO 8601 timestamp of when the metafield was last updated.

Supported Field Types

  • customer
  • company
  • shippingAddress
  • billingAddress
  • category
  • product
  • variant
  • order
  • invoice
  • salesRep
  • shippingMethod

Supported Value Types

  • text - Plain text string
  • number - Numeric value
  • file - File upload
  • json - JSON object
  • select - Single selection from predefined values
  • dateTime - Date and time
  • boolean - True/false value
  • product - Product reference
  • multi-text - Multiple text values
  • range - Numeric range
  • html-markdown - HTML or Markdown content
  • numberRange - 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)