Update a metaobject definition
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/metaobject-definitions/example';const options = { method: 'PATCH', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"type":"example","name":"example","description":"example","fields":[{"key":"example","name":"example","description":"example","type":"single_line_text","required":true,"validations":{"min_length":1,"max_length":1,"regex":"example","choices":["example"],"min":{"value":"example","unit":"example"},"max":{"value":"example","unit":"example"},"max_precision":1,"allowed_domains":["example"],"scale_min":"example","scale_max":"example","file_types":["image"],"metaobject_definition_id":"example","metaobject_definition_ids":["example"],"list_min":1,"list_max":1}}],"display_name_key":"example","filter_keys":["example"],"has_status":true,"storefront_access":true,"customer_access":"none"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://apibase.ecomweb.app/api/v1/stores/example/metaobject-definitions/example \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "type": "example", "name": "example", "description": "example", "fields": [ { "key": "example", "name": "example", "description": "example", "type": "single_line_text", "required": true, "validations": { "min_length": 1, "max_length": 1, "regex": "example", "choices": [ "example" ], "min": { "value": "example", "unit": "example" }, "max": { "value": "example", "unit": "example" }, "max_precision": 1, "allowed_domains": [ "example" ], "scale_min": "example", "scale_max": "example", "file_types": [ "image" ], "metaobject_definition_id": "example", "metaobject_definition_ids": [ "example" ], "list_min": 1, "list_max": 1 } } ], "display_name_key": "example", "filter_keys": [ "example" ], "has_status": true, "storefront_access": true, "customer_access": "none" }'Changes a definition’s name, description, fields, display-name field, filters, status or access settings. Send only the properties to change; the merged definition is validated as a whole, and a fields list replaces the stored one. The type handle and existing field types cannot change and answer 400. A field that is the display name or a filter cannot be removed (409).
Required scopes: write:metaobjects
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The metaobject definition ID.
The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The type handle, 2 to 64 lowercase letters, digits, underscores or hyphens. Derived from the name on create when left out; cannot change afterwards.
Human-readable name, 1 to 255 characters. Required on create.
What the metaobject represents, up to 5000 characters.
The fields entries can hold, at most 40. On update the list replaces the stored one: send every field to keep. A field in use as the display name or a filter cannot be removed.
object
The field’s key. 2 to 64 lowercase letters, digits or underscores. Derived from the name when left out.
Human-readable name, 1 to 255 characters.
What the field holds, up to 5000 characters.
The value type: a base type, or list. followed by a base type.
Whether every entry must have a value. Defaults to false.
The rules values must meet.
object
Minimum text length, in characters. Text types.
Maximum text length, in characters. Text types and rich text.
A regular expression the text must match. Single-line text only, in a restricted dialect (no back-references or lookaround, at most 200 characters).
The only values allowed. Single-line text only, at most 128 choices.
Smallest allowed value: a number for integer, a decimal string for decimal, a date or date-time string, or a value with a unit for weight, volume and dimension.
object
The amount, as a decimal string.
The unit. Weights use g, kg, oz or lb; volumes ml, cl, l, m3, fl_oz, pt, qt or gal; dimensions mm, cm, m, in, ft or yd.
Maximum number of decimal places. Decimal only.
Host names a link may point to. Url and link types, at most 20.
Lowest rating on the scale, as a decimal string. Rating only.
Highest rating on the scale, as a decimal string. Rating only.
The kinds of file allowed. File type only.
ID of the metaobject definition an entry reference must belong to. Metaobject reference only.
IDs of the metaobject definitions a mixed reference may point to, between 2 and 10.
Minimum number of items. List types only.
Maximum number of items, at most 128. List types only.
Key of the field whose text names each entry.
Keys of the fields entries can be filtered by, at most 5. Only single_line_text, boolean, integer and date fields qualify; list types never do.
Whether entries have an active or draft status. Defaults to false.
Whether the storefront API exposes the entries. Defaults to false.
None or read: whether a signed-in customer may read the entries. Defaults to none.
Responses
Section titled “Responses”object
Definition ID, as a string.
What the metaobject represents.
The fields entries can hold.
object
What the field holds.
The value type, as for a metafield definition.
The rules values must meet.
object
Minimum text length, in characters. Text types.
Maximum text length, in characters. Text types and rich text.
A regular expression the text must match. Single-line text only, in a restricted dialect (no back-references or lookaround, at most 200 characters).
The only values allowed. Single-line text only, at most 128 choices.
Smallest allowed value: a number for integer, a decimal string for decimal, a date or date-time string, or a value with a unit for weight, volume and dimension.
object
The amount, as a decimal string.
The unit. Weights use g, kg, oz or lb; volumes ml, cl, l, m3, fl_oz, pt, qt or gal; dimensions mm, cm, m, in, ft or yd.
Maximum number of decimal places. Decimal only.
Host names a link may point to. Url and link types, at most 20.
Lowest rating on the scale, as a decimal string. Rating only.
Highest rating on the scale, as a decimal string. Rating only.
The kinds of file allowed. File type only.
ID of the metaobject definition an entry reference must belong to. Metaobject reference only.
IDs of the metaobject definitions a mixed reference may point to, between 2 and 10.
Minimum number of items. List types only.
Maximum number of items, at most 128. List types only.
The field’s key within entries. Lowercase letters, digits and underscores.
Human-readable name.
Whether every entry must have a value for the field.
Key of the field whose text names each entry, or null to name entries by handle.
Keys of the fields entries can be filtered by, at most 5.
Whether a signed-in customer may read the entries: none or read.
ID of the user who created the definition, or null when it was created with an API key.
When the definition was created, as an ISO 8601 timestamp.
When the definition was last updated, as an ISO 8601 timestamp.
Name of the user who created the definition. Only present in the list; null when unknown.
The type handle. Entries are addressed by it in URLs. Lowercase letters, digits, underscores and hyphens.
Human-readable name.
Whether entries have an active or draft status. Without it every entry is active.
Whether the storefront API exposes the entries.
Number of entries of this type.
Example
{ "fields": [ { "type": "single_line_text", "validations": { "file_types": [ "image" ] } } ], "customer_access": "none"}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The resource does not exist in this store.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The request conflicts with the resource’s current state.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}