# PrivateMetafield - admin-graphql - OBJECT Version: 2024-10 ## Description Private metafields represent custom metadata that is attached to a resource. Private metafields are accessible only by the application that created them and only from the GraphQL Admin API. An application can create a maximum of 10 private metafields per shop resource. Private metafields are deprecated. Metafields created using a reserved namespace are private by default. See our guide for [migrating private metafields](https://shopify.dev/docs/apps/custom-data/metafields/migrate-private-metafields). ### Access Scopes ## Fields * [createdAt](/docs/api/admin-graphql/2024-10/scalars/DateTime): DateTime! - The date and time when the private metafield was created. * [id](/docs/api/admin-graphql/2024-10/scalars/ID): ID! - The ID of the private metafield. * [key](/docs/api/admin-graphql/2024-10/scalars/String): String! - The key name of the private metafield. * [namespace](/docs/api/admin-graphql/2024-10/scalars/String): String! - The namespace of the private metafield. * [updatedAt](/docs/api/admin-graphql/2024-10/scalars/DateTime): DateTime! - The date and time when the private metafield was updated. * [value](/docs/api/admin-graphql/2024-10/scalars/String): String! - The value of a private metafield. * [valueType](/docs/api/admin-graphql/2024-10/enums/PrivateMetafieldValueType): PrivateMetafieldValueType! - Represents the private metafield value type. ## Connections ## Related queries * [privateMetafield](/docs/api/admin-graphql/2024-10/queries/privateMetafield) Returns a private metafield by ID. Private metafields are accessible only by the application that created them. * [privateMetafields](/docs/api/admin-graphql/2024-10/queries/privateMetafields) Returns a list of private metafields associated to a resource. ## Related mutations * [privateMetafieldUpsert](/docs/api/admin-graphql/2024-10/mutations/privateMetafieldUpsert) Creates or updates a private metafield. Use private metafields when you don't want the metafield data to be accessible by merchants or other apps. Private metafields are accessible only by the application that created them and only from the GraphQL Admin API. An application can create a maximum of 10 private metafields per shop resource. ## Related Unions ## Examples ### Retrieve a private metafield by its ID Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { privateMetafield(id: \\\"gid://shopify/PrivateMetafield/1060470840\\\") { id key namespace value } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n privateMetafield(id: \"gid://shopify/PrivateMetafield/1060470840\") {\n id\n key\n namespace\n value\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n privateMetafield(id: \"gid://shopify/PrivateMetafield/1060470840\") {\n id\n key\n namespace\n value\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n privateMetafield(id: \"gid://shopify/PrivateMetafield/1060470840\") {\n id\n key\n namespace\n value\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n privateMetafield(id: \"gid://shopify/PrivateMetafield/1060470840\") {\n id\n key\n namespace\n value\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "privateMetafield": { "id": "gid://shopify/PrivateMetafield/1060470840", "key": "buyer", "namespace": "notes", "value": "Notes about this buyer" } } }