Update Metafield
Updates an existing metafield. Only the fields you send are changed.
HTTP Request
- URL:
/metafields/{id} - Method:
PUT - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope: None. Any valid access token can call this endpoint.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | String | Required. The ID of the metafield to update. |
Request Body
Send at least one of the following fields. They accept the same values as Create Metafield.
| Field | Type | Required | Description |
|---|---|---|---|
fieldType | String | No | Type of record the metafield belongs to. |
label | String | No | Display label. |
code | String | No | Code used to set and filter values. |
valueType | String | No | Type of value. |
description | String | No | Description of the metafield. |
allowAdminUpdate | Boolean | No | Whether admins can edit the value. |
displayStorefront | Boolean | No | Whether the value is shown on the storefront. |
displayAdmin | Boolean | No | Whether the value is shown in the admin panel. |
displayFilter | Boolean | No | Whether the metafield is offered as a storefront filter. |
hasPredefinedValues | Boolean | No | Whether values are chosen from a fixed list. |
predefinedValues | Array | No | List of allowed values. Replaces the current list. |
cURL Example
curl --location --request PUT '<BASE_URL>/metafields/6650c2c8f1d2e83a1b9c0d19' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"label": "Material",
"predefinedValues": ["Cotton", "Polyester", "Wool", "Linen"]
}'
Response
- 200 OK: The metafield was updated successfully.
- 400 Bad Request: The request body is empty, a value is not valid, or the new code is already used for this field type.
Sample JSON Response
{
"success": true,
"data": {
"_id": "6650c2c8f1d2e83a1b9c0d19",
"id": "6650c2c8f1d2e83a1b9c0d19"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request was successful. |
data | Object | The ID of the updated metafield. |
Notes
- To see the updated values, call Get Metafield.
- If no metafield matches the ID,
datais an empty object.