---
title: "Update a metafield for a resource"
description: "Update a metafield for a resource with a specific ID。"
doc_type: openapi
doc_category: openapi
doc_version: v20260901
source_url:
  html: 'https://developer.shopline.com/docs/admin-rest-api/shopline-metafields/metafields/resource-metafields/update-a-metafield-for-a-resource'
  md: 'https://developer.shopline.com/docs/admin-rest-api/shopline-metafields/metafields/resource-metafields/update-a-metafield-for-a-resource.md'
---
# Update a metafield for a resource

Update a metafield for a resource with a specific ID。

- **Base URL:** `https://{handle}.myshopline.com/admin/openapi`
- **API Version:** v20260901
- **API Type:** Admin
- **API Protocol:** RESTful

## Endpoint

```http
PUT /:resource/:owner_id/metafields/:id.json
```

## Base URL

* `https://{handle}.myshopline.com/admin/openapi`

  * `{handle}`: `handle` : The store's unique identifier, which is the prefix of the store's domain name. For example, if a store's domain name is `open001.myshopline.com` , the store handle is `open001` .

## Request

### Path Parameters

* `id`

  string (required)

  The ID of the metafield.

* `owner_id`

  string (required)

  The ID of the resource to which the metafield belongs. For example, when adding a metafield to product A with an ID of `1605898661`, the metafield's `owner_id` is `1605898661`.  
  Maximum length: 128

* `resource`

  string (required)

  The type of the resource to which the metafield belongs. Valid values are:  
  - `products`: products 
  - `variants`: product variants  
  - `collections`: product collections
  - `customers`: customers
  - `orders`: orders
  - `pages`: pages  
  - `blogs`: blogs collections
  - `articles`: blogs
  - `shop`: store

### Request Headers

* `Content-Type`

  string (required)

  The field must be set to the fixed value `application/json; charset=utf-8`.

* `Authorization`

  string (required)

   The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. 

### Request Body

* `metafield`

  object

  Metafield information.

  * `description`

    string

    The description of the metafield.  
    Maximum length: 255

  * `id`

    long

    The ID of the metafield.

  * `type`

    string

    The data type for the metafield. Valid values are:     
    - `single_line_text_field`: A single-line text field 
    - `list.single_line_text_field`: Multiple single-line text fields  
    - `multi_line_text_field`: Multi-line text field    
    - `color`: A single color  
    - `list.color`: Multiple colors 
    - `date`: A single date 
    - `list.date`: Multiple dates  
    - `date_time`: A single date and time. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).   
    - `list.date_time`: Multiple dates and times. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). 
    - `url`: A single URL  
    - `list.url`: Multiple URLs  
    - `file_reference`: A single file. Support a PDF or image file within 10 MB. Supported image formats: JPG, JPEG, PNG, and GIF.     
    - `list.file_reference`: Multiple files. Support PDF or image files and each file must be within 10 MB. Supported image formats: JPG, JPEG, PNG, and GIF.  
    - `json`: JSON     
    - `weight`: A single weight with a unit   
    - `list.weight`: Multiple weights with units   
    - `volume`: A single volume with a unit   
    - `list.volume`: Multiple volumes with units   
    - `dimension`: A single size with a unit    
    - `list.dimension`: Multiple sizes with units   
    - `number_integer`: A single integer   
    - `list.number_integer`: Multiple integers   
    - `number_decimal`: A single decimal   
    - `list.number_decimal`: Multiple decimals  
    - `rating`: A single rating    
    - `list.rating`: Multiple ratings 
    - `page_reference`: A single page  
    - `list.page_reference`: Multiple pages   
    - `product_reference`: A single product    
    - `list.product_reference`: Multiple products  
    - `variant_reference`: A single product variant  
    - `list.variant_reference`: Multiple product variants    
    - `collection_reference`: A single product collection  
    - `list.collection_reference`: Multiple product collections      
    - `boolean`: Boolean type. Valid values are `true` and `false`.
    - `money`: Amount with a currency   
    
    For more information about metafields, refer to [Guide to Using Metafields Feature](https://help.shopline.com/hc/en-001/articles/7095355017113).

  * `value`

    object

    Data stored in the metafield.  
    Regardless of how you define the type of the metafield, SHOPLINE will store it in string format. The maximum length of the converted string is 500000.

## Response

### Status Codes

* `200`

  For the complete list of codes and messages, see [Http status code](https://developer.shopline.com/docs/apps/api-instructions-for-use/http-status-code.md?lang=en).

* `401`

  

* `429`

  

### Response Headers

* `traceId`

  A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise.

### Response Body

#### 200

* `metafield`

  object

  Metafield information.

  * `type`

    string

    The data type for the metafield. Valid values are:     
    - `single_line_text_field`: A single-line text field 
    - `list.single_line_text_field`: Multiple single-line text fields  
    - `multi_line_text_field`: Multi-line text field    
    - `color`: A single color  
    - `list.color`: Multiple colors 
    - `date`: A single date 
    - `list.date`: Multiple dates  
    - `date_time`: A single date and time. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).   
    - `list.date_time`: Multiple dates and times. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). 
    - `url`: A single URL  
    - `list.url`: Multiple URLs  
    - `file_reference`: A single file. Support a PDF or image file within 10 MB. Supported image formats: JPG, JPEG, PNG, and GIF.     
    - `list.file_reference`: Multiple files. Support PDF or image files and each file must be within 10 MB. Supported image formats: JPG, JPEG, PNG, and GIF.  
    - `json`: JSON     
    - `weight`: A single weight with a unit   
    - `list.weight`: Multiple weights with units   
    - `volume`: A single volume with a unit   
    - `list.volume`: Multiple volumes with units   
    - `dimension`: A single size with a unit    
    - `list.dimension`: Multiple sizes with units   
    - `number_integer`: A single integer   
    - `list.number_integer`: Multiple integers   
    - `number_decimal`: A single decimal   
    - `list.number_decimal`: Multiple decimals  
    - `rating`: A single rating    
    - `list.rating`: Multiple ratings 
    - `page_reference`: A single page  
    - `list.page_reference`: Multiple pages   
    - `product_reference`: A single product    
    - `list.product_reference`: Multiple products  
    - `variant_reference`: A single product variant  
    - `list.variant_reference`: Multiple product variants    
    - `collection_reference`: A single product collection  
    - `list.collection_reference`: Multiple product collections      
    - `boolean`: Boolean type. Valid values are `true` and `false`.
    - `money`: Amount with a currency   
    
    For more information about metafields, refer to [Guide to Using Metafields Feature](https://help.shopline.com/hc/en-001/articles/7095355017113).

  * `updated_at`

    string

    The date and time when the metafield was updated. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).

  * `value`

    object

    The data stored in the metafield. 

  * `id`

    long

    The ID of the metafield.

  * `key`

    string

    A unique identifier for a metafield definition within its `namespace`.

  * `namespace`

    string

    The namespace of the metafield.

  * `created_at`

    string

    The date and time when the metafield was created. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). 

  * `description`

    string

    The description of the metafield.  

  * `owner_id`

    string

    The resource ID to which the metafield belongs.

  * `owner_resource`

    string

    The type of the resource to which the metafield belongs. Valid values are:  
    - `products`: products 
    - `variants`: product variants  
    - `collections`: product collections
    - `customers`: customers
    - `orders`: orders
    - `pages`: pages  
    - `blogs`: blogs collections
    - `articles`: blogs
    - `shop`: store


#### 401

* `errors`

  string

  Error message. 


#### 429

* `errors`

  string

  Error message. 


## OpenAPI Definition

```json
{
  "tags": [
    "Update a metafield for a resource"
  ],
  "description": "Update a metafield for a resource with a specific ID。",
  "externalDocs": {
    "url": "",
    "errorTableDescription": "| Error Code | HTTP Status Code | Error Description |\n|------------|------------------|-------------------|\n| DATA_NOT_EXIST | 404 | The requested data does not exist. |\n| INTERNAL_ERROR | 500 | An internal error occured. |\n| INVALID_PARAMETER | 400 | The provided parameter is invalid. |\n| SUCCESS | 200 | request success |\n"
  },
  "operationId": "nWhOmpKg",
  "parameters": [
    {
      "name": "id",
      "in": "path",
      "description": "The ID of the metafield.",
      "required": true,
      "style": "simple",
      "schema": {
        "name": "id",
        "description": "The ID of the metafield.",
        "type": "string",
        "example": 397923258691
      },
      "example": 397923258691,
      "examples": {
        "Update a metafield for a resource": {
          "value": ""
        }
      }
    },
    {
      "name": "owner_id",
      "in": "path",
      "description": "The ID of the resource to which the metafield belongs. For example, when adding a metafield to product A with an ID of `1605898661`, the metafield's `owner_id` is `1605898661`.  \nMaximum length: 128",
      "required": true,
      "style": "simple",
      "schema": {
        "name": "owner_id",
        "description": "The ID of the resource to which the metafield belongs. For example, when adding a metafield to product A with an ID of `1605898661`, the metafield's `owner_id` is `1605898661`.  \nMaximum length: 128",
        "type": "string",
        "example": "16015223514512351000"
      },
      "example": "16015223514512351000",
      "examples": {
        "Update a metafield for a resource": {
          "value": ""
        }
      }
    },
    {
      "name": "resource",
      "in": "path",
      "description": "The type of the resource to which the metafield belongs. Valid values are:  \n- `products`: products \n- `variants`: product variants  \n- `collections`: product collections\n- `customers`: customers\n- `orders`: orders\n- `pages`: pages  \n- `blogs`: blogs collections\n- `articles`: blogs\n- `shop`: store",
      "required": true,
      "style": "simple",
      "schema": {
        "name": "resource",
        "description": "The type of the resource to which the metafield belongs. Valid values are:  \n- `products`: products \n- `variants`: product variants  \n- `collections`: product collections\n- `customers`: customers\n- `orders`: orders\n- `pages`: pages  \n- `blogs`: blogs collections\n- `articles`: blogs\n- `shop`: store",
        "type": "string",
        "example": "products"
      },
      "example": "products",
      "examples": {
        "Update a metafield for a resource": {
          "value": ""
        }
      }
    },
    {
      "name": "Content-Type",
      "in": "header",
      "description": "The field must be set to the fixed value `application/json; charset=utf-8`.",
      "required": true,
      "schema": {
        "name": "Content-Type",
        "type": "string",
        "example": "application/json; charset=utf-8"
      }
    },
    {
      "name": "Authorization",
      "in": "header",
      "description": " The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. ",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Authorization",
        "description": " The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. ",
        "type": "string",
        "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
      },
      "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "name": "body",
          "description": "body position parameter",
          "type": "object",
          "properties": {
            "metafield": {
              "name": "metafield",
              "description": "Metafield information.",
              "type": "object",
              "properties": {
                "description": {
                  "name": "description",
                  "description": "The description of the metafield.  \nMaximum length: 255",
                  "type": "string",
                  "example": "My fields"
                },
                "id": {
                  "name": "id",
                  "description": "The ID of the metafield.",
                  "type": "long",
                  "example": 397923258691
                },
                "type": {
                  "name": "type",
                  "description": "The data type for the metafield. Valid values are:     \n- `single_line_text_field`: A single-line text field \n- `list.single_line_text_field`: Multiple single-line text fields  \n- `multi_line_text_field`: Multi-line text field    \n- `color`: A single color  \n- `list.color`: Multiple colors \n- `date`: A single date \n- `list.date`: Multiple dates  \n- `date_time`: A single date and time. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).   \n- `list.date_time`: Multiple dates and times. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). \n- `url`: A single URL  \n- `list.url`: Multiple URLs  \n- `file_reference`: A single file. Support a PDF or image file within 10 MB. Supported image formats: JPG, JPEG, PNG, and GIF.     \n- `list.file_reference`: Multiple files. Support PDF or image files and each file must be within 10 MB. Supported image formats: JPG, JPEG, PNG, and GIF.  \n- `json`: JSON     \n- `weight`: A single weight with a unit   \n- `list.weight`: Multiple weights with units   \n- `volume`: A single volume with a unit   \n- `list.volume`: Multiple volumes with units   \n- `dimension`: A single size with a unit    \n- `list.dimension`: Multiple sizes with units   \n- `number_integer`: A single integer   \n- `list.number_integer`: Multiple integers   \n- `number_decimal`: A single decimal   \n- `list.number_decimal`: Multiple decimals  \n- `rating`: A single rating    \n- `list.rating`: Multiple ratings \n- `page_reference`: A single page  \n- `list.page_reference`: Multiple pages   \n- `product_reference`: A single product    \n- `list.product_reference`: Multiple products  \n- `variant_reference`: A single product variant  \n- `list.variant_reference`: Multiple product variants    \n- `collection_reference`: A single product collection  \n- `list.collection_reference`: Multiple product collections      \n- `boolean`: Boolean type. Valid values are `true` and `false`.\n- `money`: Amount with a currency   \n\nFor more information about metafields, refer to [Guide to Using Metafields Feature](https://help.shopline.com/hc/en-001/articles/7095355017113).",
                  "type": "string",
                  "example": "single_line_text_field"
                },
                "value": {
                  "name": "value",
                  "description": "Data stored in the metafield.  \nRegardless of how you define the type of the metafield, SHOPLINE will store it in string format. The maximum length of the converted string is 500000.",
                  "type": "object",
                  "example": {}
                }
              },
              "required": [
                "id",
                "value",
                "type"
              ],
              "example": {
                "type": "single_line_text_field",
                "value": {},
                "description": "My fields",
                "id": 397923258691
              }
            }
          },
          "required": [
            "metafield"
          ],
          "example": {
            "metafield": {
              "type": "single_line_text_field",
              "value": {},
              "description": "My fields",
              "id": 397923258691
            }
          }
        },
        "examples": {
          "Update a metafield for a resource": {
            "description": "Update the metafield",
            "value": {
              "metafield": {
                "description": "update",
                "id": 1782269169606,
                "type": "single_line_text_field",
                "value": "A product title"
              }
            }
          }
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "description": "For the complete list of codes and messages, see [Http status code](https://developer.shopline.com/docs/apps/api-instructions-for-use/http-status-code.md?lang=en).",
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "name": "body",
            "type": "object",
            "properties": {
              "metafield": {
                "name": "metafield",
                "description": "Metafield information.",
                "type": "object",
                "properties": {
                  "type": {
                    "name": "type",
                    "description": "The data type for the metafield. Valid values are:     \n- `single_line_text_field`: A single-line text field \n- `list.single_line_text_field`: Multiple single-line text fields  \n- `multi_line_text_field`: Multi-line text field    \n- `color`: A single color  \n- `list.color`: Multiple colors \n- `date`: A single date \n- `list.date`: Multiple dates  \n- `date_time`: A single date and time. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).   \n- `list.date_time`: Multiple dates and times. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). \n- `url`: A single URL  \n- `list.url`: Multiple URLs  \n- `file_reference`: A single file. Support a PDF or image file within 10 MB. Supported image formats: JPG, JPEG, PNG, and GIF.     \n- `list.file_reference`: Multiple files. Support PDF or image files and each file must be within 10 MB. Supported image formats: JPG, JPEG, PNG, and GIF.  \n- `json`: JSON     \n- `weight`: A single weight with a unit   \n- `list.weight`: Multiple weights with units   \n- `volume`: A single volume with a unit   \n- `list.volume`: Multiple volumes with units   \n- `dimension`: A single size with a unit    \n- `list.dimension`: Multiple sizes with units   \n- `number_integer`: A single integer   \n- `list.number_integer`: Multiple integers   \n- `number_decimal`: A single decimal   \n- `list.number_decimal`: Multiple decimals  \n- `rating`: A single rating    \n- `list.rating`: Multiple ratings \n- `page_reference`: A single page  \n- `list.page_reference`: Multiple pages   \n- `product_reference`: A single product    \n- `list.product_reference`: Multiple products  \n- `variant_reference`: A single product variant  \n- `list.variant_reference`: Multiple product variants    \n- `collection_reference`: A single product collection  \n- `list.collection_reference`: Multiple product collections      \n- `boolean`: Boolean type. Valid values are `true` and `false`.\n- `money`: Amount with a currency   \n\nFor more information about metafields, refer to [Guide to Using Metafields Feature](https://help.shopline.com/hc/en-001/articles/7095355017113).",
                    "type": "string"
                  },
                  "updated_at": {
                    "name": "updated_at",
                    "description": "The date and time when the metafield was updated. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).",
                    "type": "string"
                  },
                  "value": {
                    "name": "value",
                    "description": "The data stored in the metafield. ",
                    "type": "object"
                  },
                  "id": {
                    "name": "id",
                    "description": "The ID of the metafield.",
                    "type": "long"
                  },
                  "key": {
                    "name": "key",
                    "description": "A unique identifier for a metafield definition within its `namespace`.",
                    "type": "string"
                  },
                  "namespace": {
                    "name": "namespace",
                    "description": "The namespace of the metafield.",
                    "type": "string"
                  },
                  "created_at": {
                    "name": "created_at",
                    "description": "The date and time when the metafield was created. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). ",
                    "type": "string"
                  },
                  "description": {
                    "name": "description",
                    "description": "The description of the metafield.  ",
                    "type": "string"
                  },
                  "owner_id": {
                    "name": "owner_id",
                    "description": "The resource ID to which the metafield belongs.",
                    "type": "string"
                  },
                  "owner_resource": {
                    "name": "owner_resource",
                    "description": "The type of the resource to which the metafield belongs. Valid values are:  \n- `products`: products \n- `variants`: product variants  \n- `collections`: product collections\n- `customers`: customers\n- `orders`: orders\n- `pages`: pages  \n- `blogs`: blogs collections\n- `articles`: blogs\n- `shop`: store",
                    "type": "string"
                  }
                },
                "example": {
                  "value": null,
                  "description": null,
                  "key": null,
                  "type": null,
                  "created_at": null,
                  "id": null,
                  "namespace": null,
                  "owner_id": null,
                  "owner_resource": null,
                  "updated_at": null
                }
              }
            },
            "example": {
              "metafield": {
                "created_at": null,
                "description": null,
                "key": null,
                "type": null,
                "value": null,
                "id": null,
                "namespace": null,
                "owner_id": null,
                "owner_resource": null,
                "updated_at": null
              }
            }
          },
          "examples": {
            "Update a metafield for a resource": {
              "description": "Update the metafield",
              "value": {
                "metafield": {
                  "namespace": "seo",
                  "owner_id": "16068033970754864233492340",
                  "value": "A product title",
                  "created_at": "2025-01-03T02:22:55+08:00",
                  "description": "update",
                  "id": 1782269169606,
                  "owner_resource": "products",
                  "type": "single_line_text_field",
                  "updated_at": "2025-07-15T19:11:11+08:00",
                  "key": "seoTitle"
                }
              }
            }
          }
        }
      }
    },
    "401": {
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "Error message. ",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    },
    "429": {
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "Error message. ",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": []
    }
  ],
  "method": "put",
  "path": "/:resource/:owner_id/metafields/:id.json",
  "servers": [
    {
      "url": "https://{handle}.myshopline.com/admin/openapi",
      "variables": {
        "handle": {
          "default": "openapiceshidianpu",
          "description": "`handle` : The store's unique identifier, which is the prefix of the store's domain name. For example, if a store's domain name is `open001.myshopline.com` , the store handle is `open001` ."
        }
      }
    }
  ],
  "info": {
    "title": "Update a metafield for a resource",
    "version": "v20260901"
  }
}
```