Skip to main content

Get All Metafields

This GET endpoint retrieves a list of all metafields with support for filtering and pagination.

Endpoint

  • URL: /api/metafields
  • Method: GET

Authentication

  • Header: accessToken
  • Type: Bearer Token
  • Value: <ACCESS-TOKEN>

Request Headers

HeaderTypeDescription
accessTokenstringAccess token for authentication. (required)

Query Parameters

ParameterTypeDescription
pagenumberThe page number to retrieve. Defaults to 1 if not specified.
limitnumberThe maximum number of items to return per page. Defaults to 10 if not specified. Max is 50.
idstringFilter for a specific metafield by its unique ID.
id:instringFilter for multiple metafields by a comma-separated list of IDs.
codestringFilter by the metafield's unique code.
code:instringFilter for multiple metafields by a comma-separated list of codes.
typestringFilter by field type (e.g., customer, company, product, order).
type:instringFilter for multiple metafields by a comma-separated list of field types.

Supported Field Types

The type and type:in parameters accept the following values:

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

Sample Request

curl --location '<BASE-URL>/metafields?page=1&limit=10&type=product' \
--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"
},
{
"id": "507f1f77bcf86cd799439012",
"fieldType": "product",
"label": "Material Type",
"description": "The material used for the product",
"code": "material_type",
"allowAdminUpdate": true,
"displayStorefront": true,
"displayAdmin": true,
"hasPredefinedValues": true,
"displayFilter": true,
"predefinedValues": ["Cotton", "Polyester", "Wool", "Silk"],
"valueType": "select",
"createdAt": "2024-01-16T14:20:00.000Z",
"updatedAt": "2024-01-16T14:20:00.000Z"
}
],
"pagination": {
"page": 1,
"total": 25,
"count": 2
}
}

Success Response Fields

FieldTypeDescription
successbooleanIndicates if the request was successful.
dataarrayArray of metafield objects.
paginationobjectContains pagination details (page, total, count).

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 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"
}

Notes

  • The code and fieldType combination must be unique for each metafield.
  • Maximum limit per page is 50. Values exceeding this will be capped.
  • Pagination starts at page 1.