### App Installation Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation This is an example of the JSON response structure when querying for an app installation. ```json { "appInstallation": { "app": { "id": "gid://shopify/App/1002334195" } } } ``` -------------------------------- ### App Installation Launch URL Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Example JSON response structure for the app installation launch URL. ```json { "appInstallation": { "launchUrl": "https://snowdevil.myshopify.com/admin/api_permissions/1002334195/redirect" } } ``` -------------------------------- ### App Installation Metafields Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Example JSON response structure for app installation metafields. ```json { "appInstallation": { "metafields": { "edges": [ { "node": { "namespace": "secret_keys", "key": "api_key", "value": "aSBhbSBhIHNlY3JldCBrZXk=" } } ] } } } ``` -------------------------------- ### App Installation Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Example of a JSON response when querying for app installation details, showing the uninstallUrl field. ```json { "appInstallation": { "uninstallUrl": null } } ``` -------------------------------- ### App Installation Credits Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation This is an example of the JSON response structure when querying for app installation credits. It shows an empty credits array. ```json { "appInstallation": { "credits": { "edges": [] } } } ``` -------------------------------- ### Example Response for App Installation Metafield Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation This is a sample JSON response structure when successfully retrieving a metafield for an app installation. ```JSON { "appInstallation": { "apiKey": { "value": "aSBhbSBhIHNlY3JldCBrZXk=" } } } ``` -------------------------------- ### Get Gift Card Transactions with React Router Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/giftCard Example loader function using `authenticate.admin` to fetch gift card transactions in a React Router setup. ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query GiftCardTransactionList($id: ID!, $firstTransactions: Int) { giftCard(id: $id) { id balance { amount currencyCode } transactions(first: $firstTransactions) { nodes { amount { amount currencyCode } } } } }`, { variables: { "id": "gid://shopify/GiftCard/411106674", "firstTransactions": 5 }, }, ); const json = await response.json(); return json.data; } ``` -------------------------------- ### Get App Installation Metafield via Direct API Access (Node.js) Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation This Node.js example shows how to fetch a specific metafield from an app installation by making a direct POST request to the Shopify Admin API. It includes the query and variables within the request body. ```JavaScript const response = await fetch('shopify:admin/api/2025-07/graphql.json', { method: 'POST', body: JSON.stringify({ query: ` query AppInstallationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { appInstallation(id: $ownerId) { apiKey: metafield(namespace: $namespace, key: $key) { value } } } `, variables: { "namespace": "secret_keys", "key": "api_key", "ownerId": "gid://shopify/AppInstallation/1002334195" }, }), }); const { data } = await response.json(); console.log(data); ``` -------------------------------- ### Create a new Blog Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/blogCreate This example demonstrates how to create a new blog with all required fields and proper permissions. It returns the details of the newly created blog and any user errors. ```graphql mutation CreateBlog($blog: BlogCreateInput!) { blogCreate(blog: $blog) { blog { id title handle templateSuffix commentPolicy } userErrors { code field message } } } ``` ```json { "blog": { "title": "New Blog Title", "handle": "new-blog-title", "templateSuffix": "standard", "commentPolicy": "MODERATED" } } ``` ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation CreateBlog($blog: BlogCreateInput!) { blogCreate(blog: $blog) { blog { id title handle templateSuffix commentPolicy } userErrors { code field message } } }", "variables": { "blog": { "title": "New Blog Title", "handle": "new-blog-title", "templateSuffix": "standard", "commentPolicy": "MODERATED" } } }' ``` ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation CreateBlog($blog: BlogCreateInput!) { blogCreate(blog: $blog) { blog { id title handle templateSuffix commentPolicy } userErrors { code field message } } }`, { variables: { "blog": { "title": "New Blog Title", "handle": "new-blog-title", "templateSuffix": "standard", "commentPolicy": "MODERATED" } }, }, ); const json = await response.json(); return json.data; } ``` ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation CreateBlog($blog: BlogCreateInput!) { blogCreate(blog: $blog) { blog { id title handle templateSuffix commentPolicy } userErrors { code field message } } } QUERY variables = { "blog": { "title": "New Blog Title", "handle": "new-blog-title", "templateSuffix": "standard", "commentPolicy": "MODERATED" } } response = client.query(query: query, variables: variables) ``` -------------------------------- ### Response Example for Product Options Create Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/productOptionsCreate This is an example response from the `productOptionsCreate` mutation when using the `LEAVE_AS_IS` strategy, showing the updated product and its variants. ```json { "productOptionsCreate": { "userErrors": [], "product": { "id": "gid://shopify/Product/20995642", "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/30322695", "title": "151cm / Blue", "selectedOptions": [ { "name": "Title", "value": "151cm" }, { "name": "Color", "value": "Blue" } ] }, { "id": "gid://shopify/ProductVariant/113711323", "title": "155cm / Blue", "selectedOptions": [ { "name": "Title", "value": "155cm" }, { "name": "Color", "value": "Blue" } ] }, { "id": "gid://shopify/ProductVariant/236948360", "title": "158cm / Blue", "selectedOptions": [ { "name": "Title", "value": "158cm" }, { "name": "Color", "value": "Blue" } ] }, { "id": "gid://shopify/ProductVariant/1070325308", "title": "151cm / Green", "selectedOptions": [ { "name": "Title", "value": "151cm" }, { "name": "Color", "value": "Green" } ] }, { "id": "gid://shopify/ProductVariant/1070325309", "title": "155cm / Green", "selectedOptions": [ { "name": "Title", "value": "155cm" }, { "name": "Color", "value": "Green" } ] }, { "id": "gid://shopify/ProductVariant/1070325310", "title": "158cm / Green", "selectedOptions": [ { "name": "Title", "value": "158cm" }, { "name": "Color", "value": "Green" } ] } ] }, "options": [ { "id": "gid://shopify/ProductOption/328272167", "name": "Title", "values": [ "151cm", "155cm", "158cm" ], "position": 1, "optionValues": [ { "name": "151cm", "hasVariants": true }, { "name": "155cm", "hasVariants": true }, { "name": "158cm", "hasVariants": true } ] }, { "id": "gid://shopify/ProductOption/1064576670", "name": "Color", "values": [ "Blue", "Green" ], "position": 2, "optionValues": [ { "name": "Blue", "hasVariants": true }, { "name": "Green", "hasVariants": true } ] } ] } } } ``` -------------------------------- ### Create Blog using Shopify CLI Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/blogCreate This example shows how to create a blog using the Shopify CLI. It requires the `app execute` command with the mutation and variables provided as arguments. ```bash shopify app execute \ --query \ 'mutation CreateBlog($blog: BlogCreateInput!) {\n blogCreate(blog: $blog) {\n blog {\n id\n title\n handle\n templateSuffix\n commentPolicy\n }\n userErrors {\n code\n field\n message\n }\n }\n}' \ --variables \ '{\n "blog": {\n "title": "New Blog Title",\n "handle": "new-blog-title",\n "templateSuffix": "standard",\n "commentPolicy": "MODERATED"\n }\n}' ``` -------------------------------- ### Update an Automatic BXGY Discount Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/discountAutomaticBxgyUpdate Use this mutation to update an existing automatic BXGY discount. This example modifies the discount's title, start and end dates, and specifies the 'buy' and 'get' product conditions and limits. ```graphql mutation UpdateBxgyDiscount($id: ID!, $automaticBxgyDiscount: DiscountAutomaticBxgyInput!) { discountAutomaticBxgyUpdate(id: $id, automaticBxgyDiscount: $automaticBxgyDiscount) { automaticDiscountNode { id automaticDiscount { ... on DiscountAutomaticBxgy { title startsAt endsAt } } } userErrors { field message } } } ``` ```json { "id": "gid://shopify/DiscountAutomaticBxgy/198286294", "automaticBxgyDiscount": { "title": "Buy first product, get second product free", "startsAt": "2025-01-01T00:00:00Z", "endsAt": "2025-12-31T23:59:59Z", "customerBuys": { "items": { "products": { "productsToAdd": [ "gid://shopify/Product/108828309" ] } }, "value": { "quantity": "1" } }, "customerGets": { "items": { "products": { "productsToAdd": [ "gid://shopify/Product/20995642" ] } }, "value": { "discountOnQuantity": { "quantity": "1", "effect": { "percentage": 1 } } } }, "usesPerOrderLimit": "1" } } ``` -------------------------------- ### Get metafields attached to an app installation Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Get a page of metafields attached to a specific app installation. This allows you to retrieve multiple metafields at once. ```APIDOC ## Get metafields attached to an app installation ### Description Get a page of metafields attached to a specific app installation. ### Method POST ### Endpoint /admin/api/2025-07/graphql.json ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **query** (String!) - The GraphQL query to retrieve metafields. - **variables** (Object!) - The variables for the GraphQL query. - **ownerId** (ID!) - The ID of the app installation. ### Request Example ```json { "query": "query AppInstallationMetafields($ownerId: ID!) {\n appInstallation(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n}", "variables": { "ownerId": "gid://shopify/AppInstallation/1002334195" } } ``` ### Response #### Success Response (200) - **appInstallation** (Object) - Information about the app installation. - **metafields** (Object) - A list of metafields attached to the app installation. - **edges** (Array) - A list of metafield edge objects. - **node** (Object) - The metafield node. - **namespace** (String) - The namespace of the metafield. - **key** (String) - The key of the metafield. - **value** (String) - The value of the metafield. #### Response Example ```json { "appInstallation": { "metafields": { "edges": [ { "node": { "namespace": "secret_keys", "key": "api_key", "value": "aSBhbSBhIHNlY3JldCBrZXk=" } } ] } } } ``` ``` -------------------------------- ### Create Product with Options using Shopify CLI Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/productCreate This example demonstrates how to create a product with options using the Shopify CLI's `app execute` command. ```bash shopify app execute \ --query \ 'mutation { productCreate(product: {title: "New product", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Green"}]}, {name: "Size", values: [{name: "Small"}, {name: "Medium"}]}]}) { userErrors { field message } product { id options { id name position values optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } }' ``` -------------------------------- ### Example Response for Product Options Create Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/productOptionsCreate This is an example of the response structure received after successfully creating new product options and values. It details the product, its variants, and the newly added options with their respective values. ```json { "productOptionsCreate": { "userErrors": [], "product": { "id": "gid://shopify/Product/20995642", "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/30322695", "title": "Blue / 151cm", "selectedOptions": [ { "name": "Color", "value": "Blue" }, { "name": "Title", "value": "151cm" } ] }, { "id": "gid://shopify/ProductVariant/113711323", "title": "Blue / 155cm", "selectedOptions": [ { "name": "Color", "value": "Blue" }, { "name": "Title", "value": "155cm" } ] }, { "id": "gid://shopify/ProductVariant/236948360", "title": "Blue / 158cm", "selectedOptions": [ { "name": "Color", "value": "Blue" }, { "name": "Title", "value": "158cm" } ] } ] }, "options": [ { "id": "gid://shopify/ProductOption/1064576661", "name": "Color", "values": [ "Blue" ], "position": 1, "optionValues": [ { "name": "Blue", "hasVariants": true } ] }, { "id": "gid://shopify/ProductOption/328272167", "name": "Title", "values": [ "151cm", "155cm", "158cm" ], "position": 2, "optionValues": [ { "name": "151cm", "hasVariants": true }, { "name": "155cm", "hasVariants": true }, { "name": "158cm", "hasVariants": true } ] } ] } } } ``` -------------------------------- ### Get Product Resource Feedback by ID (React Router Loader) Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/productResourceFeedback Example of fetching product resource feedback within a React Router loader function using the Shopify Admin API. This snippet requires prior authentication setup. ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { productResourceFeedback(id: "gid://shopify/Product/-1") { feedbackGeneratedAt messages productId productUpdatedAt state } }`, ); const json = await response.json(); return json.data; } ``` -------------------------------- ### Shopify CLI Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/fulfillmentOrderLineItemsPreparedForPickup Execute the fulfillmentOrderLineItemsPreparedForPickup mutation using the Shopify CLI. Ensure you have the Shopify CLI installed and authenticated. ```bash shopify app execute \ --query \ 'mutation fulfillmentOrderLineItemsPreparedForPickup($input: FulfillmentOrderLineItemsPreparedForPickupInput!) { fulfillmentOrderLineItemsPreparedForPickup(input: $input) { userErrors { field message } } }' \ --variables \ '{ "input": { "lineItemsByFulfillmentOrder": [ { "fulfillmentOrderId": "gid://shopify/FulfillmentOrder/1046000776" } ] } }' ``` -------------------------------- ### Ruby Example for File Creation Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/fileCreate This Ruby code snippet shows how to initialize a GraphQL client and execute the fileCreate mutation. It defines the query and variables separately for clarity. ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation fileCreate($files: [FileCreateInput!]!) { fileCreate(files: $files) { files { id fileStatus alt createdAt ... on MediaImage { image { width height } } } userErrors { field message } } } QUERY variables = { "files": [ { "alt": "Product showcase image from staged upload", "contentType": "IMAGE", "originalSource": "https://snowdevil.myshopify.com/admin/tmp/files/staged-image-upload-123.jpg" } ] } response = client.query(query: query, variables: variables) ``` -------------------------------- ### Get App Installation Uninstall URL via cURL Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Execute a GraphQL query to get the app installation uninstall URL using cURL. Requires the store URL and an access token. ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { appInstallation(id: \"gid://shopify/AppInstallation/688276949\") { uninstallUrl } }" }' ``` -------------------------------- ### Get App Installation Launch URL via cURL Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Execute a GraphQL query to get the app installation launch URL using cURL. Requires the store URL and an access token. ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { appInstallation(id: \"gid://shopify/AppInstallation/1002334195\") { launchUrl } }" }' ``` -------------------------------- ### Ruby Client for Product Creation Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/productCreate Example using the ShopifyAPI Ruby client to create a product. It shows session setup, client initialization, and executing the GraphQL query. ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation { productCreate(product: {title: "Wireless Headphones", productType: "Electronics", vendor: "AudioTech", status: ACTIVE}) { product { id title productType vendor status variants(first: 1) { nodes { id price inventoryItem { id tracked } } } } userErrors { field message } } } QUERY response = client.query(query: query) ``` -------------------------------- ### Example Response for Discount Code BXGY Create Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/discountCodeBxgyCreate This JSON structure represents the successful response when creating a BXGY discount code. It includes details of the created discount, such as its title, codes, start and end dates, customer buying and getting conditions, and customer selection criteria. ```json { "discountCodeBxgyCreate": { "codeDiscountNode": { "codeDiscount": { "title": "20% off up to two snowboards that are on sale for every three featured snowboards you buy.", "codes": { "nodes": [ { "code": "SUMMERSALE" } ] }, "startsAt": "2025-07-24T20:17:12Z", "endsAt": "2025-07-29T20:17:12Z", "customerBuys": { "items": { "collections": { "nodes": [ { "id": "gid://shopify/Collection/1007901140", "title": "Featured items" } ] } }, "value": { "quantity": "3" } }, "customerGets": { "appliesOnOneTimePurchase": true, "appliesOnSubscription": false, "value": { "effect": { "percentage": 0.2 }, "quantity": { "quantity": "2" } }, "items": { "collections": { "nodes": [ { "id": "gid://shopify/Collection/711838235", "title": "On Sale!" } ] } } }, "customerSelection": { "allCustomers": true }, "appliesOncePerCustomer": false, "usesPerOrderLimit": 3 } }, "userErrors": [] } } ``` -------------------------------- ### Product Create Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/productCreate Example JSON response after a successful product creation. It includes the created product's ID, title, and configured options with their values. ```json { "productCreate": { "product": { "id": "gid://shopify/Product/1072482054", "title": "Cool socks", "options": [ { "id": "gid://shopify/ProductOption/1064577875", "name": "Color", "position": 1, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054674807", "name": "Red", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/1054674808", "name": "Blue", "hasVariants": false } ] }, { "id": "gid://shopify/ProductOption/1064577876", "name": "Size", "position": 2, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054674809", "name": "Small", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/1054674810", "name": "Large", "hasVariants": false } ] } ] } } } ``` -------------------------------- ### Get App Associated with Installation Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Retrieve the application ID associated with a specific app installation. This query is useful for linking installations back to their parent applications. ```graphql query { appInstallation(id: "gid://shopify/AppInstallation/1002334195") { app { id } } } ``` -------------------------------- ### Product Creation Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/productCreate This is an example of a successful response when creating a product with options. ```json { "productCreate": { "product": { "id": "gid://shopify/Product/1072482045", "title": "Wireless Headphones", "productType": "Electronics", "vendor": "AudioTech", "status": "ACTIVE", "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070326022", "price": "0.00", "inventoryItem": { "id": "gid://shopify/InventoryItem/1070326022", "tracked": false } } ] } }, "userErrors": [] } } ``` -------------------------------- ### Shopify CLI Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/discountAutomaticBasicUpdate Example of updating an automatic basic discount using the Shopify CLI. ```APIDOC ## shopify app execute ### Description Executes a GraphQL mutation using the Shopify CLI to update an automatic basic discount. ### Command `shopify app execute` ### Arguments - `--query` (string) - Required - The GraphQL mutation to execute. - `--variables` (string) - Required - The variables for the GraphQL mutation in JSON format. ### Example ```bash shopify app execute \ --query \ 'mutation discountAutomaticBasicUpdate($id: ID!, $automaticBasicDiscount: DiscountAutomaticBasicInput!) { discountAutomaticBasicUpdate(id: $id, automaticBasicDiscount: $automaticBasicDiscount) { automaticDiscountNode { id } userErrors { field code message } } }' \ --variables \ '{ "id": "gid://shopify/DiscountAutomaticNode/299501151", "automaticBasicDiscount": { "minimumRequirement": { "quantity": { "greaterThanOrEqualToQuantity": null }, "subtotal": { "greaterThanOrEqualToSubtotal": null } } } }' ``` ``` -------------------------------- ### Get App Installation Metafield Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Retrieve a specific metafield attached to an app installation using its namespace and key. Requires the owner ID of the app installation. ```graphql query AppInstallationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { appInstallation(id: $ownerId) { apiKey: metafield(namespace: $namespace, key: $key) { value } } } ``` ```json { "namespace": "secret_keys", "key": "api_key", "ownerId": "gid://shopify/AppInstallation/1002334195" } ``` -------------------------------- ### Get App Installation Metafield Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Retrieves a specific metafield attached to an app installation, identified by its namespace and key. ```APIDOC ## Get App Installation Metafield ### Description Retrieves a specific metafield attached to an app installation, identified by its namespace and key. ### Method POST ### Endpoint /admin/api/2025-07/graphql.json ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **query** (string) - Required - The GraphQL query to execute. - **variables** (object) - Required - Variables for the GraphQL query. - **namespace** (String!) - Required - The namespace of the metafield. - **key** (String!) - Required - The key of the metafield. - **ownerId** (ID!) - Required - The ID of the app installation. ### Request Example ```json { "query": "query AppInstallationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n appInstallation(id: $ownerId) {\n apiKey: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}", "variables": { "namespace": "secret_keys", "key": "api_key", "ownerId": "gid://shopify/AppInstallation/1002334195" } } ``` ### Response #### Success Response (200) - **appInstallation** (object) - **apiKey** (object, aliased from metafield) - **value** (string) #### Response Example ```json { "data": { "appInstallation": { "apiKey": null } } } ``` ``` -------------------------------- ### File Creation Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/fileCreate This is an example of the response received after attempting to create files. It shows successful file creation and user errors encountered. ```json { "fileCreate": { "files": [], "userErrors": [ { "field": [ "files", "0", "originalSource" ], "message": "Image URL is invalid", "code": "INVALID" }, { "field": [ "files", "1", "originalSource" ], "message": "The file type is not supported.", "code": "UNACCEPTABLE_ASSET" }, { "field": [ "files", "2", "alt" ], "message": "The alt value exceeds the maximum limit of 512 characters.", "code": "ALT_VALUE_LIMIT_EXCEEDED" } ] } } ``` -------------------------------- ### Get App Installation Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Retrieves details about a specific app installation using its ID. This is useful for fetching basic information about an app's installation within a store. ```APIDOC ## POST /admin/api/2025-07/graphql.json ### Description Retrieves details about a specific app installation. ### Method POST ### Endpoint /admin/api/2025-07/graphql.json ### Parameters #### Request Body - **query** (string) - Required - The GraphQL query to execute. - **variables** (object) - Optional - Variables for the GraphQL query. ### Request Example ```json { "query": "query { appInstallation(id: \"gid://shopify/AppInstallation/1002334195\") { app { id } } }" } ``` ### Response #### Success Response (200) - **appInstallation** (object) - Contains details about the app installation. - **app** (object) - Contains details about the app. - **id** (ID) - The unique identifier for the app. #### Response Example ```json { "appInstallation": { "app": { "id": "gid://shopify/App/1002334195" } } } ``` ``` -------------------------------- ### Ruby Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/discountAutomaticBasicUpdate Example of updating an automatic basic discount using the ShopifyAPI Ruby client. ```APIDOC ## POST /admin/api/2025-07/graphql.json ### Description Updates an existing automatic basic discount. ### Method POST ### Endpoint /admin/api/2025-07/graphql.json ### Parameters #### Request Body - **query** (string) - Required - The GraphQL mutation to perform. - **variables** (object) - Required - The variables for the GraphQL mutation. - **id** (ID!) - Required - The ID of the discount to update. - **automaticBasicDiscount** (DiscountAutomaticBasicInput!) - Required - The input object for the discount update. - **minimumRequirement** (DiscountMinimumRequirementInput) - Optional - Specifies the minimum requirements for the discount. - **quantity** (DiscountQuantityInput) - Optional - Requirements based on quantity. - **greaterThanOrEqualToQuantity** (Int) - Optional - The minimum quantity required. - **subtotal** (DiscountSubtotalInput) - Optional - Requirements based on subtotal. - **greaterThanOrEqualToSubtotal** (MoneyInput) - Optional - The minimum subtotal required. ### Request Example ```json { "query": "mutation discountAutomaticBasicUpdate($id: ID!, $automaticBasicDiscount: DiscountAutomaticBasicInput!) { discountAutomaticBasicUpdate(id: $id, automaticBasicDiscount: $automaticBasicDiscount) { automaticDiscountNode { id } userErrors { field code message } } }", "variables": { "id": "gid://shopify/DiscountAutomaticNode/299501151", "automaticBasicDiscount": { "minimumRequirement": { "quantity": { "greaterThanOrEqualToQuantity": null }, "subtotal": { "greaterThanOrEqualToSubtotal": null } } } } } ``` ### Response #### Success Response (200) - **discountAutomaticBasicUpdate** (object) - The result of the mutation. - **automaticDiscountNode** (object) - The updated discount node. - **id** (ID) - The ID of the updated discount. - **userErrors** (array) - A list of user errors, if any occurred. - **field** (array) - The field that has an error. - **code** (string) - The error code. - **message** (string) - The error message. #### Response Example ```json { "discountAutomaticBasicUpdate": { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/299501151" }, "userErrors": [] } } ``` ``` -------------------------------- ### Get App Installation Access Scopes (Direct API Access) Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Query the Shopify Admin API directly using fetch to get the access scopes for an app installation. Ensure the correct endpoint and POST request body are used. ```javascript const response = await fetch('shopify:admin/api/2025-07/graphql.json', { method: 'POST', body: JSON.stringify({ query: ` query { appInstallation(id: "gid://shopify/AppInstallation/1002334195") { accessScopes { handle description } } } `, }), }); const { data } = await response.json(); console.log(data); ``` -------------------------------- ### Shopify CLI Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/marketingActivityCreateExternal Example of creating an external marketing activity using the Shopify CLI. ```APIDOC ## Shopify CLI ```bash shopify app execute \ --query \ 'mutation marketingActivityCreateExternal($createInput: MarketingActivityCreateExternalInput!) {\n marketingActivityCreateExternal(input: $createInput) {\n marketingActivity {\n id\n }\n }\n}' \ --variables \ '{\n "createInput": {\n "remoteId": "fake_id",\n "title": "New Title",\n "remoteUrl": "https://example.com",\n "remotePreviewImageUrl": "https://example.com",\n "status": "ACTIVE",\n "utm": {\n "source": "email",\n "medium": "newsletter",\n "campaign": "external-campaign"\n },\n "tactic": "NEWSLETTER",\n "marketingChannelType": "EMAIL"\n }\n}' ``` ``` -------------------------------- ### Get a specific metafield attached to an app installation Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Retrieve the value of a specific metafield for an app installation by providing its namespace, key, and the app installation's owner ID. ```APIDOC ## Get a specific metafield attached to an app installation ### Description Retrieve the value of a specific metafield for an app installation by providing its namespace, key, and the app installation's owner ID. ### Method POST ### Endpoint /admin/api/2025-07/graphql.json ### Parameters #### Query Parameters None #### Request Body - **query** (String!) - The GraphQL query to execute. - **variables** (Object!) - The variables for the GraphQL query. - **namespace** (String!) - The namespace of the metafield. - **key** (String!) - The key of the metafield. - **ownerId** (ID!) - The ID of the app installation. ### Request Example ```json { "query": "query AppInstallationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n appInstallation(id: $ownerId) {\n apiKey: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}", "variables": { "namespace": "secret_keys", "key": "api_key", "ownerId": "gid://shopify/AppInstallation/1002334195" } } ``` ### Response #### Success Response (200) - **appInstallation** (Object) - Information about the app installation. - **apiKey** (Object) - The metafield associated with the app installation. - **value** (String) - The value of the metafield. #### Response Example ```json { "appInstallation": { "apiKey": { "value": "aSBhbSBhIHNlY3JldCBrZXk=" } } } ``` ``` -------------------------------- ### Shopify CLI Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/productVariantsBulkCreate Use the Shopify CLI to execute a GraphQL mutation for creating product variants in bulk. This example demonstrates creating variants with existing media. ```APIDOC ## Shopify CLI ### Description Use the Shopify CLI to execute a GraphQL mutation for creating product variants in bulk. This example demonstrates creating variants with existing media. ### Command ```bash shopify app execute \ --query \ 'mutation CreateProductVariantsInBulkWithExistingMedia($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkCreate(productId: $productId, variants: $variants) { product { id } productVariants { id title media(first: 10) { nodes { id alt mediaContentType preview { status } } } } userErrors { field message } } }' \ --variables \ '{ "productId": "gid://shopify/Product/20995642", "variants": [ { "optionValues": [ { "name": "one", "optionName": "Title" } ], "mediaId": "gid://shopify/MediaImage/730211239" }, { "optionValues": [ { "name": "two", "optionName": "Title" } ] } ] }' ``` ``` -------------------------------- ### Example Response for Get Theme by ID Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/theme This is an example JSON response structure when querying for a theme's ID, name, and role. ```json { "theme": { "id": "gid://shopify/OnlineStoreTheme/529529152", "name": "Comfort", "role": "MAIN" } } ``` -------------------------------- ### Get App Installation Access Scopes (Description) Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Retrieve all access scopes granted to an application during installation, including their handles and descriptions. ```graphql query { appInstallation(id: "gid://shopify/AppInstallation/1002334195") { accessScopes { handle description } } } ``` -------------------------------- ### File Creation Response Example Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/fileCreate This is an example of a successful response from the `fileCreate` mutation, showing the created files with their IDs, status, and metadata. ```json { "fileCreate": { "files": [ { "id": "gid://shopify/MediaImage/1072273434", "fileStatus": "READY", "alt": "Laptop computer on modern desk setup", "createdAt": "2025-06-21T03:46:57Z", "image": { "width": 372, "height": 110 } }, { "id": "gid://shopify/MediaImage/1072273435", "fileStatus": "READY", "alt": "Close-up view of laptop keyboard and screen", "createdAt": "2025-06-21T03:46:57Z", "image": { "width": 372, "height": 110 } } ], "userErrors": [] } } ``` -------------------------------- ### Apply Discount to Line Item (Shopify CLI) Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/orderEditAddLineItemDiscount This example shows how to apply a percentage discount to a line item using the Shopify CLI. It requires the GraphQL query and variables to be passed as arguments. ```bash shopify app execute \ --query \ 'mutation orderEditAddLineItemDiscount($id: ID!, $lineItemId: ID!, $discount: OrderEditAppliedDiscountInput!) { orderEditAddLineItemDiscount(id: $id, lineItemId: $lineItemId, discount: $discount) { calculatedOrder { id } calculatedLineItem { id calculatedDiscountAllocations { discountApplication { id } } } addedDiscountStagedChange { id description value { __typename ... on PricingPercentageValue { percentage } } } userErrors { field message } } }' \ --variables \ '{ "id": "gid://shopify/CalculatedOrder/607673109", "lineItemId": "gid://shopify/CalculatedLineItem/510711879", "discount": { "description": "50% off promotion", "percentValue": 50 } }' ``` -------------------------------- ### cURL Request for App Installation Metafield Source: https://shopify.dev/docs/api/admin-graphql/2025-07/queries/appInstallation Example cURL command to fetch an app installation metafield via the Shopify Admin API. ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query AppInstallationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { appInstallation(id: $ownerId) { apiKey: metafield(namespace: $namespace, key: $key) { value } } }", "variables": { "namespace": "secret_keys", "key": "api_key", "ownerId": "gid://shopify/AppInstallation/1002334195" } }' ``` -------------------------------- ### Enable Local Pickup with Shopify CLI Source: https://shopify.dev/docs/api/admin-graphql/2025-07/mutations/locationLocalPickupEnable This example shows how to enable local pickup using the Shopify CLI. It directly executes the mutation with the specified query and variables. ```bash shopify app execute \ --query \ 'mutation enableLocalPickup($localPickupSettings: DeliveryLocationLocalPickupEnableInput!) {\n locationLocalPickupEnable(localPickupSettings: $localPickupSettings) {\n localPickupSettings {\n pickupTime\n instructions\n }\n userErrors {\n message\n field\n }\n }\n}' \ --variables \ '{\n "localPickupSettings": {\n "locationId": "gid://shopify/Location/530388139",\n "pickupTime": "TWENTY_FOUR_HOURS",\n "instructions": "Use side door." }\n}' ```