--- title: automaticDiscountNode - GraphQL Admin description: Returns a `DiscountAutomaticNode` resource by ID. api_version: 2025-01 api_name: admin type: query api_type: graphql source_url: html: >- https://shopify.dev/docs/api/admin-graphql/2025-01/queries/automaticDiscountNode md: >- https://shopify.dev/docs/api/admin-graphql/2025-01/queries/automaticDiscountNode.md --- # automatic​Discount​Node query Returns a `DiscountAutomaticNode` resource by ID. ## Arguments * id [ID!](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/ID) required The ID of the `DiscountAutomaticNode` to return. *** ## Possible returns * Discount​Automatic​Node [Discount​Automatic​Node](https://shopify.dev/docs/api/admin-graphql/2025-01/objects/DiscountAutomaticNode) The `DiscountAutomaticNode` object enables you to manage [automatic discounts](https://help.shopify.com/manual/discounts/discount-types#automatic-discounts) that are applied when an order meets specific criteria. You can create amount off, free shipping, or buy X get Y automatic discounts. For example, you can offer customers a free shipping discount that applies when conditions are met. Or you can offer customers a buy X get Y discount that's automatically applied when customers spend a specified amount of money, or a specified quantity of products. Learn more about working with [Shopify's discount model](https://shopify.dev/docs/apps/build/discounts), including related queries, mutations, limitations, and considerations. * automatic​Discount [Discount​Automatic!](https://shopify.dev/docs/api/admin-graphql/2025-01/unions/DiscountAutomatic) non-null A discount that's applied automatically when an order meets specific criteria. Learn more about [automatic discounts](https://help.shopify.com/manual/discounts/discount-types#automatic-discounts). * events [Event​Connection!](https://shopify.dev/docs/api/admin-graphql/2025-01/connections/EventConnection) non-null The paginated list of events associated with the host subject. * first [Int](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/2025-01/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/2025-01/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/2025-01/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/2025-01/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Event​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/2025-01/enums/EventSortKeys) 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/2025-01/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). * * action string * comments boolean * created\_at time * id id * subject\_type string - The action that occured. - Example: * `action:create` Whether or not to include [comment-events](https://shopify.dev/api/admin-graphql/latest/objects/CommentEvent) in your search, passing `false` will exclude comment-events, any other value will include comment-events. - Example: * `false` * `true` Filter by the date and time when the event happened. - Example: * `created_at:>2020-10-21` * `created_at:=1234` * `id:<=1234` The resource type affected by this event. See [EventSubjectType](https://shopify.dev/api/admin-graphql/latest/enums/EventSubjectType) for possible values. Example: * `PRODUCT_VARIANT` * `PRODUCT` * `COLLECTION` *** * id [ID!](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/ID) non-null A globally-unique ID. * metafield [Metafield](https://shopify.dev/docs/api/admin-graphql/2025-01/objects/Metafield) A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information. * namespace [String](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/String) ### Arguments The container the metafield belongs to. If omitted, the app-reserved namespace will be used. * key [String!](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/String) required The key for the metafield. *** * metafields [Metafield​Connection!](https://shopify.dev/docs/api/admin-graphql/2025-01/connections/MetafieldConnection) non-null A list of [custom fields](https://shopify.dev/docs/apps/build/custom-data) that a merchant associates with a Shopify resource. * namespace [String](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/String) ### Arguments The metafield namespace to filter by. If omitted, the app-reserved namespace will be used. * keys [\[String!\]](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/String) List of keys of metafields in the format `namespace.key`, will be returned in the same format. * first [Int](https://shopify.dev/docs/api/admin-graphql/2025-01/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/2025-01/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/2025-01/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/2025-01/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/2025-01/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * metafield​Definitions [Metafield​Definition​Connection!](https://shopify.dev/docs/api/admin-graphql/2025-01/connections/MetafieldDefinitionConnection) non-nullDeprecated * namespace [String](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/String) ### Arguments Filter metafield definitions by namespace. * pinned​Status [Metafield​Definition​Pinned​Status](https://shopify.dev/docs/api/admin-graphql/2025-01/enums/MetafieldDefinitionPinnedStatus) Default:ANY Filter by the definition's pinned status. * first [Int](https://shopify.dev/docs/api/admin-graphql/2025-01/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/2025-01/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/2025-01/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/2025-01/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/2025-01/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Metafield​Definition​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/2025-01/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/2025-01/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: { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371284") { id automaticDiscount { ... on DiscountAutomaticBxgy { title status } } } }`, ); 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 { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371284") { id automaticDiscount { ... on DiscountAutomaticBxgy { title status } } } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371284") { id automaticDiscount { ... on DiscountAutomaticBxgy { title status } } } }`, }); ``` #### Response ```json { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/1057371284", "automaticDiscount": { "title": "An automatic bogo discount", "status": "SCHEDULED" } } } ``` * ### Retrieve an automatic discount by its ID #### Description Retrieve an automatic discount that's managed by an app using \[Shopify Functions]\(https://shopify.dev/docs/apps/build/functions). #### Query ```graphql query { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371285") { id automaticDiscount { ... on DiscountAutomaticApp { title status } } } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { automaticDiscountNode(id: \"gid://shopify/DiscountAutomaticNode/1057371285\") { id automaticDiscount { ... on DiscountAutomaticApp { title status } } } }" }' ``` #### 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 { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371285") { id automaticDiscount { ... on DiscountAutomaticApp { title status } } } }`, ); 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 { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371285") { id automaticDiscount { ... on DiscountAutomaticApp { title status } } } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371285") { id automaticDiscount { ... on DiscountAutomaticApp { title status } } } }`, }); ``` #### Response ```json { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/1057371285", "automaticDiscount": { "title": "An automatic app discount", "status": "ACTIVE" } } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20%7B%0A%20%20automaticDiscountNode\(id%3A%20%22gid%3A%2F%2Fshopify%2FDiscountAutomaticNode%2F1057371284%22\)%20%7B%0A%20%20%20%20id%0A%20%20%20%20automaticDiscount%20%7B%0A%20%20%20%20%20%20...%20on%20DiscountAutomaticBxgy%20%7B%0A%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20status%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) ##### GQL ```graphql query { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371284") { id automaticDiscount { ... on DiscountAutomaticBxgy { title status } } } } ``` ##### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { automaticDiscountNode(id: \"gid://shopify/DiscountAutomaticNode/1057371284\") { id automaticDiscount { ... on DiscountAutomaticBxgy { title status } } } }" }' ``` ##### 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 { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371284") { id automaticDiscount { ... on DiscountAutomaticBxgy { title status } } } }`, ); const json = await response.json(); return json.data; } ``` ##### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371284") { id automaticDiscount { ... on DiscountAutomaticBxgy { title status } } } }`, }); ``` ##### 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 { automaticDiscountNode(id: "gid://shopify/DiscountAutomaticNode/1057371284") { id automaticDiscount { ... on DiscountAutomaticBxgy { title status } } } } QUERY response = client.query(query: query) ``` ## Response JSON ```json { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/1057371284", "automaticDiscount": { "title": "An automatic bogo discount", "status": "SCHEDULED" } } } ```