--- title: MetafieldDefinition - GraphQL Admin description: >- Defines the structure, validation rules, and permissions for [`Metafield`](/docs/api/admin-graphql/unstable/objects/Metafield) objects attached to a specific owner type. Each definition establishes a schema that metafields must follow, including the data type and validation constraints. The definition controls access permissions across different APIs, determines whether the metafield can be used for filtering or as a collection condition, and can be constrained to specific resource subtypes. api_version: unstable api_name: admin type: object api_type: graphql source_url: html: >- https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition md: >- https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition.md --- # Metafield​Definition object Defines the structure, validation rules, and permissions for [`Metafield`](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Metafield) objects attached to a specific owner type. Each definition establishes a schema that metafields must follow, including the data type and validation constraints. The definition controls access permissions across different APIs, determines whether the metafield can be used for filtering or as a collection condition, and can be constrained to specific resource subtypes. ## Fields * access [Metafield​Access!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/MetafieldAccess) non-null The access settings associated with the metafield definition. * capabilities [Metafield​Capabilities!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/MetafieldCapabilities) non-null The capabilities of the metafield definition. * constraints [Metafield​Definition​Constraints](https://shopify.dev/docs/api/admin-graphql/unstable/objects/MetafieldDefinitionConstraints) The [constraints](https://shopify.dev/apps/build/custom-data/metafields/conditional-metafield-definitions) that determine what subtypes of resources a metafield definition applies to. * created​At [Date​Time!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/DateTime) non-null The date and time when the metafield definition was created. * description [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The description of the metafield definition. * id [ID!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/ID) non-null A globally-unique ID. * key [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) non-null The unique identifier for the metafield definition within its namespace. * metafields [Metafield​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/MetafieldConnection) non-null The metafields that belong to the metafield definition. * validation​Status [Metafield​Validation​Status](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldValidationStatus) Default:ANY ### Arguments Returns the metafields filtered by the validation status. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * metafields​Count [Int!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) non-null The count of the metafields that belong to the metafield definition. * validation​Status [Metafield​Validation​Status](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldValidationStatus) ### Arguments The current validation status. *** * name [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) non-null The human-readable name of the metafield definition. * namespace [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) non-null The container for a group of metafields that the metafield definition is associated with. * owner​Type [Metafield​Owner​Type!](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldOwnerType) non-null The resource type that the metafield definition is attached to. * pinned​Position [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The position of the metafield definition in the pinned list. * standard​Template [Standard​Metafield​Definition​Template](https://shopify.dev/docs/api/admin-graphql/unstable/objects/StandardMetafieldDefinitionTemplate) The standard metafield definition template associated with the metafield definition. * type [Metafield​Definition​Type!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/MetafieldDefinitionType) non-null The type of data that each of the metafields that belong to the metafield definition will store. Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). * updated​At [Date​Time!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/DateTime) non-null The date and time when the metafield definition was updated. * use​As​Collection​Condition [Boolean!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) non-null Whether the metafield definition can be used as a collection condition. * validations [\[Metafield​Definition​Validation!\]!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/MetafieldDefinitionValidation) non-null A list of [validation options](https://shopify.dev/apps/metafields/definitions/validation) for the metafields that belong to the metafield definition. For example, for a metafield definition with the type `date`, you can set a minimum date validation so that each of the metafields that belong to it can only store dates after the specified minimum. * validation​Status [Metafield​Definition​Validation​Status!](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldDefinitionValidationStatus) non-null The validation status for the metafields that belong to the metafield definition. *** ## Map ### Fields and connections with this object * [CollectionRuleMetafieldCondition.metafieldDefinition](https://shopify.dev/docs/api/admin-graphql/unstable/objects/CollectionRuleMetafieldCondition#field-CollectionRuleMetafieldCondition.fields.metafieldDefinition) * [Metafield.definition](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Metafield#field-Metafield.fields.definition) * [MetafieldDefinitionConnection.nodes](https://shopify.dev/docs/api/admin-graphql/unstable/connections/MetafieldDefinitionConnection#returns-nodes) * [MetafieldDefinitionEdge.node](https://shopify.dev/docs/api/admin-graphql/unstable/objects/MetafieldDefinitionEdge#field-MetafieldDefinitionEdge.fields.node) *** ## Queries * [metafield​Definition](https://shopify.dev/docs/api/admin-graphql/unstable/queries/metafieldDefinition) query Retrieves a [`MetafieldDefinition`](https://shopify.dev/docs/api/admin-graphql/unstable/objects/MetafieldDefinition) by its identifier. You can identify a definition using either its owner type, namespace, and key, or its global ID. Use this query to inspect a definition's configuration, including its data type, validations, access settings, and the count of [metafields](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Metafield) using it. * id [ID](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/ID) Deprecated ### Arguments * identifier [Metafield​Definition​Identifier​Input](https://shopify.dev/docs/api/admin-graphql/unstable/input-objects/MetafieldDefinitionIdentifierInput) The identifier of the MetafieldDefinition to return. *** * [metafield​Definitions](https://shopify.dev/docs/api/admin-graphql/unstable/queries/metafieldDefinitions) query Returns a list of metafield definitions. * key [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) ### Arguments Filter metafield definition by key. * namespace [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) Filter metafield definition by namespace. * owner​Type [Metafield​Owner​Type!](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldOwnerType) required Filter the metafield definition by the specific owner type. * pinned​Status [Metafield​Definition​Pinned​Status](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldDefinitionPinnedStatus) Default:ANY Filter the metafield definition by the pinned status. * constraint​Subtype [Metafield​Definition​Constraint​Subtype​Identifier](https://shopify.dev/docs/api/admin-graphql/unstable/input-objects/MetafieldDefinitionConstraintSubtypeIdentifier) Filter metafield definitions based on whether they apply to a given resource subtype. * constraint​Status [Metafield​Definition​Constraint​Status](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldDefinitionConstraintStatus) Filter metafield definitions based on whether they are constrained. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Metafield​Definition​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldDefinitionSortKeys) Default:ID Sort the underlying list using a key. If your query is slow or returns an error, then [try specifying a sort key that matches the field used in the search](https://shopify.dev/api/usage/pagination-graphql#search-performance-considerations). * query [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax). * * default string * created\_at time * id id * key string * namespace string * owner\_type string * type string * updated\_at time - Filter by a case-insensitive search of multiple fields in a document. - Example: * `query=Bob Norman` * `query=title:green hoodie` Filter by the date and time when the metafield definition was created. - Example: * `created_at:>2020-10-21T23:39:20Z` * `created_at:=1234` * `id:<=1234` Filter by the metafield definition [`key`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-key) field. - Example: * `key:some-key` Filter by the metafield definition [`namespace`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-namespace) field. - Example: * `namespace:some-namespace` Filter by the metafield definition [`ownerType`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-ownertype) field. - Example: * `owner_type:PRODUCT` Filter by the metafield definition [`type`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-type) field. - Example: * `type:single_line_text_field` Filter by the date and time when the metafield definition was last updated. Example: * `updated_at:>2020-10-21T23:39:20Z` * `updated_at: