CRUD
Last updated View as Markdown
Metafield management is available through the admin API. Anyone with access to a resource can list and read its metafields. Writes are limited to apps.
Who can write
- Only a token that belongs to an app can create, update or delete a metafield. Other tokens get HTTP 403 with
only apps can write metafields. - An app writes only in the namespace equal to its app handle. For an app with the handle
reviews-app, the namespace isreviews-app. - A write in another namespace gets HTTP 403 with
apps can only write metafields in the <handle> namespace. This also applies to an update or a delete by ID of a metafield in another namespace. - An update by ID only changes a metafield of the resource in the URL. Another resource's metafield ID returns
resource not found.
List
Response
json
[
{
"id": "2YcBCnAFyyDjLv0wuhZdFnWIqjR",
"namespace": "reviews-app",
"key": "rating",
"value": "4",
"type": "number"
}
]1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Create
Parameters
Note
value_type supports these types. The input parameter is named value_type but the response field is named type.
Some scenarios to consider when creating a new metafield.
- If the namespace and key already exists, and the existing value is not a list, we override the value.
- If the namespace and key already exists, the existing value is a list, and the coming value is single, we append the value to the list.
- If the namespace and key already exists, the existing value is a list, and the coming value is a list, we override the value.
Response
json
{
"id": "2YcBCnAFyyDjLv0wuhZdFnWIqjR",
"namespace": "reviews-app",
"key": "rating",
"value": "4",
"type": "number"
}1
2
3
4
5
6
7
2
3
4
5
6
7
Update
Parameters
Note
value_type supports these types
Response
json
{
"status": 200,
"detail": "",
"meta": []
}1
2
3
4
5
2
3
4
5
Delete
By ID
Response
json
{
"message": "The resource has been successfully deleted.",
"type": "success"
}1
2
3
4
2
3
4
By namespace and key
Response
json
{
"message": "The resource has been successfully deleted.",
"type": "success"
}1
2
3
4
2
3
4
Show
By ID
Response
json
{
"id": "2YcCVBRMqjpRcqFbeN9fpUAWmQc",
"namespace": "reviews-app",
"key": "rating",
"value": "4",
"type": "number"
}1
2
3
4
5
6
7
2
3
4
5
6
7
By namespace and key
Response
json
{
"id": "2YcCVBRMqjpRcqFbeN9fpUAWmQc",
"namespace": "reviews-app",
"key": "rating",
"value": "4",
"type": "number"
}1
2
3
4
5
6
7
2
3
4
5
6
7