Skip to main content

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​

ParameterTypeDescription
idStringRequired. 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.

FieldTypeRequiredDescription
fieldTypeStringNoType of record the metafield belongs to.
labelStringNoDisplay label.
codeStringNoCode used to set and filter values.
valueTypeStringNoType of value.
descriptionStringNoDescription of the metafield.
allowAdminUpdateBooleanNoWhether admins can edit the value.
displayStorefrontBooleanNoWhether the value is shown on the storefront.
displayAdminBooleanNoWhether the value is shown in the admin panel.
displayFilterBooleanNoWhether the metafield is offered as a storefront filter.
hasPredefinedValuesBooleanNoWhether values are chosen from a fixed list.
predefinedValuesArrayNoList 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​

FieldTypeDescription
successBooleanWhether the request was successful.
dataObjectThe ID of the updated metafield.

Notes​

  • To see the updated values, call Get Metafield.
  • If no metafield matches the ID, data is an empty object.