### Get current app installation details Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/currentAppInstallation?example=get-a-list-of-access-scopes This example demonstrates how to fetch details about the current app installation, including its active subscriptions and their line items. It provides code snippets for Ruby, Node.js, and Shopify CLI. ```APIDOC ## Get current app installation details ### Description Fetches details about the current app installation, including active subscriptions and their associated line items. ### Method POST ### Endpoint `/admin/api/2026-04/graphql.json` ### Request Body ```json { "query": "query GetRecurringApplicationCharges {\n currentAppInstallation {\n activeSubscriptions {\n id\n name\n status\n lineItems {\n id\n plan {\n pricingDetails {\n __typename\n }\n }\n }\n }\n }\n}" } ``` ### Response #### Success Response (200) - **currentAppInstallation** (object) - Information about the current app installation. - **activeSubscriptions** (array) - A list of active subscriptions. - **id** (string) - The ID of the subscription. - **name** (string) - The name of the subscription. - **status** (string) - The status of the subscription. - **lineItems** (array) - A list of line items for the subscription. - **id** (string) - The ID of the line item. - **plan** (object) - Details about the plan for the line item. - **pricingDetails** (object) - The pricing details for the plan. - **__typename** (string) - The type name of the pricing details. ### Response Example ```json { "currentAppInstallation": { "activeSubscriptions": [] } } ``` ``` -------------------------------- ### App Installation Response Example Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation This is an example of the JSON response when querying for app installation details. ```json { "appInstallation": { "app": { "id": "gid://shopify/App/1002334195" } } } ``` -------------------------------- ### App Installation Response Example Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation Example JSON response structure when querying for app installation details. ```json { "appInstallation": { "uninstallUrl": null } } ``` -------------------------------- ### Example Response for App Installation Metafields Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation This is an example JSON response when querying for app installation metafields. ```json { "appInstallation": { "metafields": { "edges": [ { "node": { "namespace": "secret_keys", "key": "api_key", "value": "aSBhbSBhIHNlY3JldCBrZXk=" } } ] } } } ``` -------------------------------- ### Example Response for App Installation Launch URL Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation This is an example JSON response when querying for an app installation's launch URL. ```json { "appInstallation": { "launchUrl": "https://snowdevil.myshopify.com/admin/api_permissions/1002334195/redirect" } } ``` -------------------------------- ### Get Access Scopes using Ruby Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation Ruby example demonstrating how to query for app installation access scopes using the ShopifyAPI client. ```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 query { appInstallation(id: "gid://shopify/AppInstallation/1002334195") { accessScopes { handle description } } } QUERY response = client.query(query: query) ``` -------------------------------- ### App Installation Metafield Response Example Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation Example JSON response when querying for an app installation's metafield. ```JSON { "appInstallation": { "apiKey": { "value": "aSBhbSBhIHNlY3JldCBrZXk=" } } } ``` -------------------------------- ### Example Response for App Installation Credits Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation This is a sample JSON response structure for a query requesting app installation credits. ```json { "appInstallation": { "credits": { "edges": [] } } } ``` -------------------------------- ### Full Customer Payload Example Source: https://shopify.dev/docs/api/webhooks/latest Example of a full payload for a customer update webhook. This includes all fields associated with a customer. ```json { "id": 706405506930370000, "email": "bob@biller.com", "created_at": "2021-12-31T19:00:00-05:00", "updated_at": "2021-12-31T19:00:00-05:00", "first_name": "Bob", "last_name": "Biller", "orders_count": 0, "state": "disabled", "total_spent": "0.00", "last_order_id": null, "note": "This customer loves ice cream", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "tags": "", "last_order_name": null, "currency": "USD", "phone": null, "addresses": [], "tax_exemptions": [], "email_marketing_consent": null, "sms_marketing_consent": null, "admin_graphql_api_id": "gid://shopify/Customer/706405506930370084" } ``` -------------------------------- ### Get metafields attached to an app installation Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation?example=Get+the+access+scopes+associated+with+the+app+installation This example demonstrates how to retrieve a page of metafields attached to a specific app installation. ```APIDOC ## Get metafields attached to an app installation ### Description Get a page of metafields attached to a specific app installation. This is useful for retrieving all custom data associated with an app installation. ### Method POST ### Endpoint `/admin/api/2026-04/graphql.json` ### Parameters #### Query Parameters - **ownerId** (ID!) - The ID of the app installation. #### Request Body - **query** (String!) - The GraphQL query string. - **variables** (Object) - Variables to be used with 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) - Contains 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) - Represents a single metafield. - **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": "custom", "key": "example_key", "value": "example_value" } } ] } } } ``` ``` -------------------------------- ### Draft Order Payload Example Source: https://shopify.dev/docs/api/webhooks?reference=toml This is a sample payload representing a Shopify Draft Order, illustrating its structure and key fields. ```APIDOC ## Draft Order Payload Example ### Description This is a sample payload representing a Shopify Draft Order, illustrating its structure and key fields. ### Response #### Success Response (200) - **outstanding_balance** (string) - The outstanding balance for the draft order. - **outstanding_balance_currency** (string) - The currency of the outstanding balance. - **can_pay_early** (boolean) - Indicates if the draft order can be paid early. - **admin_graphql_api_id** (string) - The GraphQL API ID for the draft order. - **customer** (object) - Information about the customer associated with the draft order. - **id** (integer) - The unique identifier for the customer. - **created_at** (null) - The creation timestamp for the customer. - **updated_at** (null) - The last update timestamp for the customer. - **first_name** (string) - The first name of the customer. - **last_name** (string) - The last name of the customer. - **state** (string) - The state of the customer account (e.g., 'disabled'). - **note** (null) - Any notes associated with the customer. - **verified_email** (boolean) - Indicates if the customer's email is verified. - **multipass_identifier** (null) - Multipass identifier for the customer. - **tax_exempt** (boolean) - Indicates if the customer is tax-exempt. - **email** (string) - The email address of the customer. - **phone** (null) - The phone number of the customer. - **currency** (string) - The default currency for the customer. - **tax_exemptions** (array) - A list of tax exemptions for the customer. - **admin_graphql_api_id** (string) - The GraphQL API ID for the customer. - **default_address** (object) - The default address of the customer. - **id** (null) - The unique identifier for the address. - **customer_id** (integer) - The ID of the customer this address belongs to. - **first_name** (string) - The first name associated with the address. - **last_name** (string) - The last name associated with the address. - **company** (null) - The company name associated with the address. - **address1** (string) - The first line of the street address. - **address2** (null) - The second line of the street address. - **city** (string) - The city of the address. - **province** (string) - The province or state of the address. - **country** (string) - The country of the address. - **zip** (string) - The postal or ZIP code of the address. - **phone** (string) - The phone number associated with the address. - **name** (string) - The full name associated with the address. - **province_code** (string) - The code for the province or state. - **country_code** (string) - The code for the country. - **country_name** (string) - The full name of the country. - **default** (boolean) - Indicates if this is the default address for the customer. ### Response Example ```json { "outstanding_balance": "428.00", "outstanding_balance_currency": "USD", "can_pay_early": true, "admin_graphql_api_id": "gid://shopify/DraftOrder/890612572568261625", "customer": { "id": 706405506930370084, "created_at": null, "updated_at": null, "first_name": "John", "last_name": "Smith", "state": "disabled", "note": null, "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "email": "john@doe.ca", "phone": null, "currency": "USD", "tax_exemptions": [], "admin_graphql_api_id": "gid://shopify/Customer/706405506930370084", "default_address": { "id": null, "customer_id": 706405506930370084, "first_name": "John", "last_name": "Smith", "company": null, "address1": "123 Elm St.", "address2": null, "city": "Ottawa", "province": "Ontario", "country": "Canada", "zip": "K2H7A8", "phone": "123-123-1234", "name": "John Smith", "province_code": "ON", "country_code": "CA", "country_name": "Canada", "default": true } } } ``` ``` -------------------------------- ### Get a metafield attached to an app installation Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation?example=retrieves-all-application-credits This example shows how to fetch the value of a metafield using its namespace and key for a given app installation. It includes the GraphQL query, variables, and examples for cURL and React Router. ```APIDOC ## Get a metafield attached to an app installation ### Description Get the metafield value identified by `secret_keys.api_key` on a specific app installation. ### Query ```graphql query AppInstallationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { appInstallation(id: $ownerId) { apiKey: metafield(namespace: $namespace, key: $key) { value } } } ``` ### Variables ```json { "namespace": "secret_keys", "key": "api_key", "ownerId": "gid://shopify/AppInstallation/1002334195" } ``` ### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-04/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" } }' ``` ### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql 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 json = await response.json(); return json.data; } ``` ``` -------------------------------- ### Get the access scopes associated with the app installation Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation?example=Get+the+access+scopes+associated+with+the+app+installation This example demonstrates how to retrieve the access scopes for an app installation using a GraphQL query. ```APIDOC ## Get the access scopes associated with the app installation ### Description Retrieves the access scopes associated with a specific app installation. This is useful for understanding the permissions granted to the app. ### Method POST ### Endpoint `/admin/api//graphql.json` ### Parameters #### Request Body - **query** (String!) - The GraphQL query string. - **variables** (Object) - Variables to be used with 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) - Contains information about the app installation. - **apiKey** (Object) - Contains the metafield value. - **value** (String) - The value of the metafield. #### Response Example ```json { "appInstallation": { "apiKey": { "value": "aSBhbSBhIHNlY3JldCBrZXk=" } } } ``` ``` -------------------------------- ### Get Metafields for App Installation (Node.js) Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation?example=Get+the+access+scopes+associated+with+the+app+installation Node.js example for querying app installation metafields. It utilizes the Shopify GraphQL client to send the query and variables. ```JavaScript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "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" }, }, }); ``` -------------------------------- ### Retrieve Metafields Attached to an App Installation Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation?example=retrieves-all-application-credits Get a page of metafields attached to a specific app installation. This example demonstrates the GraphQL query, variables, and provides examples for direct API access, cURL, React Router, Ruby, and Node.js. ```APIDOC ## Get metafields attached to an app installation ### Description Get a page of metafields attached to a specific app installation. ### Query ```graphql query AppInstallationMetafields($ownerId: ID!) { appInstallation(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } } ``` ### Variables ```json { "ownerId": "gid://shopify/AppInstallation/1002334195" } ``` ### Direct API Access ```javascript const response = await fetch('shopify:admin/api/2026-04/graphql.json', { method: 'POST', body: JSON.stringify({ query: ` query AppInstallationMetafields($ownerId: ID!) { appInstallation(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } } `, variables: { "ownerId": "gid://shopify/AppInstallation/1002334195" }, }), }); const { data } = await response.json(); console.log(data); ``` ### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-04/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query AppInstallationMetafields($ownerId: ID!) { appInstallation(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }", "variables": { "ownerId": "gid://shopify/AppInstallation/1002334195" } }' ``` ### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query AppInstallationMetafields($ownerId: ID!) { appInstallation(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }`, { variables: { "ownerId": "gid://shopify/AppInstallation/1002334195" }, }, ); const json = await response.json(); return json.data; } ``` ### Ruby ```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 query AppInstallationMetafields($ownerId: ID!) { appInstallation(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } } QUERY variables = { "ownerId": "gid://shopify/AppInstallation/1002334195" } response = client.query(query: query, variables: variables) ``` ### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query AppInstallationMetafields($ownerId: ID!) { appInstallation(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }`, "variables": { "ownerId": "gid://shopify/AppInstallation/1002334195" }, }, }); ``` ``` -------------------------------- ### Query App Installation by ID (Direct API Access) Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation This example shows how to query app installation details directly using the Fetch API. ```javascript const response = await fetch('shopify:admin/api/2026-04/graphql.json', { method: 'POST', body: JSON.stringify({ query: ` query { appInstallation(id: "gid://shopify/AppInstallation/1002334195") { app { id } } } `, }), }); const { data } = await response.json(); console.log(data); ``` -------------------------------- ### Get App Installation Metafield with cURL Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation Example of how to fetch an app installation metafield using a cURL command. Replace placeholders with your store details and access token. ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-04/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" } }' ``` -------------------------------- ### Ruby Example Source: https://shopify.dev/docs/api/admin-graphql/latest/mutations/bulkProductResourceFeedbackCreate This Ruby snippet demonstrates how to set up a GraphQL client and execute the bulkProductResourceFeedbackCreate mutation. ```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($feedbackInput: [ProductResourceFeedbackInput!]!) { bulkProductResourceFeedbackCreate(feedbackInput: $feedbackInput) { userErrors { field message } feedback { productId state messages } } } QUERY variables = { "feedbackInput": { "productId": "gid://shopify/Product/172561227", "state": "REQUIRES_ACTION", "feedbackGeneratedAt": "2021-05-01T23:00:00Z", "productUpdatedAt": "2021-04-28T16:00:00Z", "messages": [ "Needs a description." ] } } response = client.query(query: query, variables: variables) ``` -------------------------------- ### Initialize a Hydrogen Storefront Source: https://shopify.dev/docs Set up a new headless Hydrogen storefront project. ```bash shopify hydrogen init ``` -------------------------------- ### Get App Installation Metafield Example Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation?example=Get+the+access+scopes+associated+with+the+app+installation This example demonstrates how to fetch a metafield value associated with an app installation using the Shopify Admin GraphQL API. It shows the query structure, variables, and how to execute it using the Ruby client or direct HTTP requests. ```APIDOC ## Get App Installation Metafield ### Description Retrieves a specific metafield value associated with an app installation. This is useful for accessing configuration or secret values stored as metafields for your app. ### Method POST ### Endpoint `/admin/api//graphql.json` ### Parameters #### Query Parameters None #### Request Body - **query** (String!) - The GraphQL query string. - **variables** (Object) - A JSON object containing variables for the GraphQL query. - **namespace** (String!) - The namespace of the metafield. - **key** (String!) - The key of the metafield. - **ownerId** (ID!) - The GraphQL ID of the app installation. ### Request Example (Ruby Client) ```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 query AppInstallationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { appInstallation(id: $ownerId) { apiKey: metafield(namespace: $namespace, key: $key) { value } } } QUERY variables = { "namespace": "secret_keys", "key": "api_key", "ownerId": "gid://shopify/AppInstallation/1002334195" } response = client.query(query: query, variables: variables) ``` ### Request Example (Shopify CLI) ```bash shopify app execute \ --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 \ '{\n "namespace": "secret_keys",\n "key": "api_key",\n "ownerId": "gid://shopify/AppInstallation/1002334195"\n}' ``` ### Request Example (Direct API Access) ```javascript const response = await fetch('shopify:admin/api/2026-04/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); ``` ### Response #### Success Response (200) - **appInstallation** (Object) - Contains 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=" } } } ``` ``` -------------------------------- ### Get Access Scopes for App Installation (Node.js) Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation?example=Get+the+access+scopes+associated+with+the+app+installation This Node.js example demonstrates how to query for app installation access scopes using the Shopify GraphQL client. Ensure you have an active session. ```JavaScript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "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" }, }, }); ``` -------------------------------- ### Get App Installation Credits Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation?example=Get+the+access+scopes+associated+with+the+app+installation This snippet demonstrates how to query for app installation credits using the Shopify GraphQL API. It shows examples for Node.js, Shopify CLI, and direct API access. ```APIDOC ## Get App Installation Credits ### Description Retrieves the credits associated with a specific app installation. This query allows you to fetch details about the credits, such as their amount, currency, creation date, and description. ### Method POST ### Endpoint `/admin/api/2026-04/graphql.json` ### Parameters #### Request Body - **query** (string) - Required - The GraphQL query string. - **variables** (object) - Required - The variables to be used with the GraphQL query. - **appInstallationId** (ID!) - Required - The ID of the app installation. ### Request Example ```json { "query": "query GetAppInstallationCredits($appInstallationId: ID!) {\n appInstallation(id: $appInstallationId) {\n credits(first: 10) {\n edges {\n node {\n amount {\n amount\n currencyCode\n }\n createdAt\n description\n id\n }\n }\n }\n }\n}", "variables": { "appInstallationId": "gid://shopify/AppInstallation/236444539" } } ``` ### Response #### Success Response (200) - **appInstallation** (object) - Contains the credits information for the app installation. - **credits** (object) - Contains a list of credit edges. - **edges** (array) - An array of credit edge objects. - **node** (object) - Represents a single credit. - **amount** (object) - The amount of the credit. - **amount** (string) - The numerical amount. - **currencyCode** (string) - The currency code (e.g., USD). - **createdAt** (string) - The date and time the credit was created. - **description** (string) - A description of the credit. - **id** (ID) - The unique identifier for the credit. #### Response Example ```json { "appInstallation": { "credits": { "edges": [] } } } ``` ``` -------------------------------- ### Start Shopify Theme Console Source: https://shopify.dev/docs/api/shopify-cli/theme/theme-console These examples demonstrate how to start the Shopify Liquid REPL. The first command starts the console without specific context, while the second command starts it with a URL to provide context for Liquid objects. ```bash shopify theme console shopify theme console --url /products/classic-leather-jacket ``` -------------------------------- ### Initialize a Shopify Theme Source: https://shopify.dev/docs Clone a Shopify starter theme to begin local development. ```bash shopify theme init ``` -------------------------------- ### Example response for discountCodeBxgyCreate Source: https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyCreate This is an example of a successful response when creating a BXGY discount. It includes details about the discount, such as its title, generated codes, start and end times, 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": [] } } ``` -------------------------------- ### Shopify CLI Example Source: https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingCreate Example of creating a free shipping discount using the Shopify CLI. ```APIDOC ## Shopify CLI ```bash shopify app execute \ --query \ 'mutation CreateFreeShippingDiscount($input: DiscountAutomaticFreeShippingInput!) { discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $input) { automaticDiscountNode { id automaticDiscount { ... on DiscountAutomaticFreeShipping { title startsAt endsAt minimumRequirement { ... on DiscountMinimumQuantity { greaterThanOrEqualToQuantity } } destinationSelection { ... on DiscountCountryAll { allCountries } } } } } userErrors { field message } } }' \ --variables \ '{ "input": { "title": "FREESHIP5PLUS", "startsAt": "2025-01-01T00:00:00Z", "endsAt": "2025-12-31T23:59:59Z", "minimumRequirement": { "quantity": { "greaterThanOrEqualToQuantity": "5" } }, "destination": { "all": true } } }' ``` ``` -------------------------------- ### Get a list of access scopes Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/currentAppInstallation?example=get-a-list-of-access-scopes This example demonstrates how to query the Shopify Admin API to fetch the handles of all access scopes granted to the current app installation. ```APIDOC ## Get a list of access scopes ### Description This query retrieves a list of access scopes associated with the current app installation. It specifically fetches the `handle` for each scope. ### Method POST ### Endpoint /admin/api/2026-04/graphql.json ### Request Body ```json { "query": "query AccessScopeList {\n currentAppInstallation {\n accessScopes {\n handle\n }\n }\n}" } ``` ### Response #### Success Response (200) - **accessScopes** (Array) - A list of access scopes. - **handle** (String) - The unique identifier for the access scope. ### Request Example (GraphQL Query) ```graphql query AccessScopeList { currentAppInstallation { accessScopes { handle } } } ``` ``` -------------------------------- ### Shopify CLI for Product Media Creation Source: https://shopify.dev/docs/api/admin-graphql/latest/mutations/productCreateMedia This example shows how to use the Shopify CLI to execute the productCreateMedia mutation. It demonstrates passing the GraphQL query and variables directly as arguments. ```bash shopify app execute \ --query \ 'mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) { productCreateMedia(media: $media, productId: $productId) { media { alt mediaContentType status } mediaUserErrors { field message } product { id title } } }' \ --variables \ '{ \ "media": [ { "alt": "Image", "mediaContentType": "EXTERNAL_VIDEO", "originalSource": "https://youtu.be/32mGBDk3LSo" }, { "alt": "Image", "mediaContentType": "IMAGE", "originalSource": "invalid_img" } ], "productId": "gid://shopify/Product/121709582" }' ``` -------------------------------- ### Get Product Metafields using Ruby Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/product Example of fetching product metafields using the ShopifyAPI Ruby client. Requires session and access token setup. ```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 query ProductMetafields($ownerId: ID!) { product(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } } QUERY variables = { "ownerId": "gid://shopify/Product/108828309" } response = client.query(query: query, variables: variables) ``` -------------------------------- ### Get Gift Card Transactions with React Router Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/giftCard Example loader function using `authenticate.admin` to fetch gift card transactions within 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; } ``` -------------------------------- ### Shopify CLI Example Source: https://shopify.dev/docs/api/admin-graphql/latest/mutations/customerCreate Create a customer using the Shopify CLI. ```APIDOC ## Shopify CLI ```bash shopify app execute \ --query \ 'mutation customerCreate($input: CustomerInput!) { customerCreate(input: $input) { userErrors { field message } customer { id email phone taxExempt emailMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt } firstName lastName amountSpent { amount currencyCode } smsMarketingConsent { marketingState marketingOptInLevel } addresses { address1 city countryCode phone zip } } } }' \ --variables \ '{ "input": { "email": null, "phone": null, "firstName": null, "lastName": null } }' ``` ``` -------------------------------- ### Initialize a Shopify App Source: https://shopify.dev/docs Create a new Shopify app project in a local subdirectory. ```bash shopify app init ``` -------------------------------- ### Get a list of access scopes Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/currentAppInstallation?example=get-a-list-of-access-scopes This example shows how to retrieve a list of access scopes granted to the current app installation using the GraphQL API. It includes examples for GQL, cURL, React Router, Node.js, Ruby, Shopify CLI, and Direct API Access. ```APIDOC ## Get a list of access scopes ### Description Retrieves a list of access scopes associated with the current application installation. ### Method POST ### Endpoint `/admin/api/2026-04/graphql.json` ### Request Body ```json { "query": "query AccessScopeList {\n currentAppInstallation {\n accessScopes {\n handle\n }\n }\n}" } ``` ### Response #### Success Response (200) - **accessScopes** (object) - A list of access scopes. - **handle** (string) - The handle of the access scope. ### Response Example ```json { "currentAppInstallation": { "accessScopes": [ { "handle": "read_products" } ] } } ``` ``` -------------------------------- ### Create Buy X Get Y Discount Code Source: https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyCreate Use this mutation to create a 'Buy X Get Y' discount code. It requires specifying the code, title, customer buying conditions, customer getting conditions, applicable customer segments, start and end dates, and usage limits. The example uses a React loader function. ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation discountCodeBxgyCreate($bxgyCodeDiscount: DiscountCodeBxgyInput!) { discountCodeBxgyCreate(bxgyCodeDiscount: $bxgyCodeDiscount) { codeDiscountNode { codeDiscount { ... on DiscountCodeBxgy { title codes(first: 10) { nodes { code } } startsAt endsAt customerBuys { items { ...collectionsFragment } value { ... on DiscountQuantity { quantity } } } customerGets { value { ... on DiscountOnQuantity { effect { ... on DiscountPercentage { percentage } } quantity { quantity } } } items { ...collectionsFragment } } context { ... on DiscountCustomerSegments { segments { id } } } appliesOncePerCustomer } } } userErrors { field code message } } } fragment collectionsFragment on DiscountCollections { collections(first: 10) { nodes { id title } } }`, { variables: { "bxgyCodeDiscount": { "code": "SUMMERSALE", "title": "SUMMERSALE", "customerBuys": { "items": { "collections": { "add": [ "gid://shopify/Collection/1007901140" ] } }, "value": { "quantity": "3" } }, "customerGets": { "items": { "collections": { "add": [ "gid://shopify/Collection/1007901140" ] } }, "value": { "discountOnQuantity": { "effect": { "percentage": 0.2 }, "quantity": "2" } } }, "context": { "customerSegments": { "add": [ "gid://shopify/Segment/210588551" ] } }, "endsAt": "2026-05-04T02:46:03-04:00", "startsAt": "2026-04-29T02:46:03-04:00", "usesPerOrderLimit": 3 } }, }, ); const json = await response.json(); return json.data; } ``` -------------------------------- ### Node.js: Fetch App Installation Launch URL Source: https://shopify.dev/docs/api/admin-graphql/latest/queries/appInstallation Utilize the Shopify Node.js client to query for the app installation's launch URL. This example demonstrates using the client.query method. ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { appInstallation(id: "gid://shopify/AppInstallation/1002334195") { launchUrl } }`, }); ```