Skip to main content

Get All Metafields

Retrieves a paginated list of metafields. A metafield is a custom field you define once (for example "Country of Origin" for products) and then fill in on individual records.

HTTP Request​

  • URL: /metafields
  • Method: GET
  • Headers:
    • accessToken: Required. Your API access token.
  • Required scope: None. Any valid access token can call this endpoint.

Query Parameters​

ParameterTypeDescription
pageNumberPage number to retrieve. Default is 1.
limitNumberNumber of metafields per page. Default is 10.
idStringReturn only the metafield with this ID.
id:inStringComma-separated list of metafield IDs.
codeStringReturn only the metafield with this code.
code:inStringComma-separated list of metafield codes.

cURL Example​

curl --location '<BASE_URL>/metafields?page=1&limit=20&code:in=country_of_origin,material_type' \
--header 'accessToken: <ACCESS_TOKEN>'

Response​

  • 200 OK: The list of metafields was returned successfully.
  • 400 Bad Request: A query parameter is not valid.

Sample JSON Response​

{
"success": true,
"data": [
{
"id": "6650c2a1f1d2e83a1b9c0d11",
"fieldType": "product",
"label": "Country of Origin",
"description": "Country where the product is manufactured.",
"code": "country_of_origin",
"allowAdminUpdate": true,
"displayStorefront": true,
"displayAdmin": true,
"displayFilter": true,
"hasPredefinedValues": false,
"predefinedValues": [],
"valueType": "text",
"createdAt": "2024-05-24T08:12:17.402Z",
"updatedAt": "2024-05-24T08:12:17.402Z"
},
{
"id": "6650c2c8f1d2e83a1b9c0d19",
"fieldType": "product",
"label": "Material Type",
"code": "material_type",
"allowAdminUpdate": true,
"displayStorefront": true,
"displayAdmin": true,
"displayFilter": true,
"hasPredefinedValues": true,
"predefinedValues": ["Cotton", "Polyester", "Wool"],
"valueType": "select",
"createdAt": "2024-05-24T08:12:56.118Z",
"updatedAt": "2024-06-02T10:41:03.590Z"
}
],
"pagination": {
"page": 1,
"total": 2,
"count": 2
}
}

Response Details​

FieldTypeDescription
successBooleanWhether the request was successful.
dataArrayList of metafields. See below.
paginationObjectPagination details. See below.

Metafield Data​

FieldTypeDescription
idStringUnique identifier of the metafield.
fieldTypeStringType of record the metafield belongs to, for example product or customer.
labelStringDisplay label.
descriptionStringDescription of the metafield.
codeStringCode used to set and filter values. Unique for each field type.
allowAdminUpdateBooleanWhether admins can edit the value. Default is false.
displayStorefrontBooleanWhether the value is shown on the storefront. Default is false.
displayAdminBooleanWhether the value is shown in the admin panel. Default is false.
displayFilterBooleanWhether the metafield is offered as a storefront filter. Default is false.
hasPredefinedValuesBooleanWhether values are chosen from a fixed list. Default is false.
predefinedValuesArrayList of allowed values.
valueTypeStringType of value, for example text, number or select.
createdAtStringDate and time the metafield was created (ISO 8601).
updatedAtStringDate and time the metafield was last updated (ISO 8601).

Pagination Details​

FieldTypeDescription
pageNumberCurrent page number.
totalNumberTotal number of metafields that match.
countNumberNumber of metafields returned on this page.

Using Metafields on Other Resources​

Products, categories, brands, customers, companies, addresses, orders, invoices, quotes and sales reps accept a metaFields array when you create or update them:

{
"metaFields": [
{ "code": "country_of_origin", "value": "Germany" },
{ "code": "material_type", "value": "Cotton" }
]
}
FieldTypeRequiredDescription
codeStringYesCode of an existing metafield.
valueString, Number, Boolean or ArrayNoValue to store for this record.

The record then returns each value together with the metafield's details:

{
"metaFieldId": "6650c2a1f1d2e83a1b9c0d11",
"label": "Country of Origin",
"code": "country_of_origin",
"displayStorefront": true,
"valueType": "text",
"value": "Germany"
}
  • The code must belong to a metafield that already exists. Otherwise the request fails with Meta Fields not found.
  • When you update a record, values for the codes you send are replaced and new codes are added. See the update page of each resource for details.

Filtering by Metafields​

The list endpoints for products, categories, brands, customers, companies, orders, invoices and sales reps can be filtered by metafield value:

ParameterDescription
metafields:<code>=<value>Records whose metafield <code> equals the value, e.g. metafields:country_of_origin=Germany.
metafields-in:<code>=<a>,<b>Records whose metafield <code> equals any of the values, e.g. metafields-in:material_type=Cotton,Wool.
curl --location '<BASE_URL>/brands?metafields:country_of_origin=Germany' \
--header 'accessToken: <ACCESS_TOKEN>'

Notes​

  • Metafield values are matched exactly and are case-sensitive.
  • When you use more than one metafield filter, a record is returned if it matches any of them.