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
| Parameter | Type | Description |
|---|---|---|
page | Number | Page number to retrieve. Default is 1. |
limit | Number | Number of metafields per page. Default is 10. |
id | String | Return only the metafield with this ID. |
id:in | String | Comma-separated list of metafield IDs. |
code | String | Return only the metafield with this code. |
code:in | String | Comma-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
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request was successful. |
data | Array | List of metafields. See below. |
pagination | Object | Pagination details. See below. |
Metafield Data
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier of the metafield. |
fieldType | String | Type of record the metafield belongs to, for example product or customer. |
label | String | Display label. |
description | String | Description of the metafield. |
code | String | Code used to set and filter values. Unique for each field type. |
allowAdminUpdate | Boolean | Whether admins can edit the value. Default is false. |
displayStorefront | Boolean | Whether the value is shown on the storefront. Default is false. |
displayAdmin | Boolean | Whether the value is shown in the admin panel. Default is false. |
displayFilter | Boolean | Whether the metafield is offered as a storefront filter. Default is false. |
hasPredefinedValues | Boolean | Whether values are chosen from a fixed list. Default is false. |
predefinedValues | Array | List of allowed values. |
valueType | String | Type of value, for example text, number or select. |
createdAt | String | Date and time the metafield was created (ISO 8601). |
updatedAt | String | Date and time the metafield was last updated (ISO 8601). |
Pagination Details
| Field | Type | Description |
|---|---|---|
page | Number | Current page number. |
total | Number | Total number of metafields that match. |
count | Number | Number 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" }
]
}
| Field | Type | Required | Description |
|---|---|---|---|
code | String | Yes | Code of an existing metafield. |
value | String, Number, Boolean or Array | No | Value 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
codemust belong to a metafield that already exists. Otherwise the request fails withMeta 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:
| Parameter | Description |
|---|---|
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.