Blog

Call the Shopify Admin API From Make With a Code Step (GraphQL)

Updated November 2026

To call Shopify's GraphQL Admin API from Make, send a POST with fetch to https://<shop>.myshopify.com/admin/api/2026-10/graphql.json, put the Admin API access token in the X-Shopify-Access-Token header, and return a flattened array that the next module can iterate. The code step earns its place by doing what a raw API call leaves to you: checking userErrors, unwrapping edges/node, and building a batched mutation from an array.

Shopify marked the REST Admin API as legacy on October 1, 2024, and since April 1, 2025 new public apps must use GraphQL only (checked on shopify.dev, October 2026). Make's Shopify app has followed: its REST module is labeled "(legacy)" and a "Make a GraphQL API call" module exists (checked on apps.make.com, October 2026). That module returns the raw JSON. The rest of this page is about making that JSON usable in one operation.

TL;DR

  • Endpoint: POST /admin/api/<version>/graphql.json, header X-Shopify-Access-Token, body { query, variables }. Latest stable version: 2026-10.
  • GraphQL returns HTTP 200 even when a mutation fails. Check errors and data.*.userErrors and throw, so the Make run stops.
  • Flatten edges[].node into a plain array the next module can iterate.
  • 50 orders with line items and customer: one Make credit, one CustomJS request. A single query may cost at most 1,000 points; the real cost is in extensions.cost.
  • Keep the token out of the code field. Map it from a Make variable into the Input field.

How do I fetch the last 50 orders with line items from Shopify in one Make operation?

Add the CustomJS module Execute Inline JavaScript, Return Type Object. In the Input field, map a JSON string with the shop subdomain and the token. The token comes from a Make variable (Set variable, scenario inputs, or a data store), never from a literal in the code.

{
  "shop": "acme-outdoor",
  "token": "{{shopifyToken}}",
  "version": "2026-10"
}

The code posts the query, throws on any GraphQL error, and maps the nested connection into flat objects:

const data = typeof input === "string" ? JSON.parse(input) : input;
const { shop, token, version = "2026-10" } = data;
const query = `{
  orders(first: 50, sortKey: CREATED_AT, reverse: true) {
    edges { node {
      id name createdAt displayFinancialStatus customer { email displayName }
      totalPriceSet { shopMoney { amount currencyCode } }
      lineItems(first: 10) { edges { node { title sku quantity } } }
    } }
  }
}`;
const url = `https://${shop}.myshopify.com/admin/api/${version}/graphql.json`;
const res = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json", "X-Shopify-Access-Token": token },
  body: JSON.stringify({ query })
});
const json = await res.json();
if (!res.ok || json.errors) throw new Error(JSON.stringify(json.errors ?? res.status));

const orders = json.data.orders.edges.map(({ node: o }) => ({
  id: o.id.split("/").pop(), name: o.name, createdAt: o.createdAt,
  status: o.displayFinancialStatus,
  total: Number(o.totalPriceSet.shopMoney.amount),
  currency: o.totalPriceSet.shopMoney.currencyCode,
  customerEmail: o.customer?.email ?? null,
  customerName: o.customer?.displayName ?? null,
  items: o.lineItems.edges.map(e => e.node)
}));
return { orders, count: orders.length, cost: json.extensions?.cost };

Output (two of the fifty orders shown):

{
  "orders": [
    {
      "id": "6210473263394",
      "name": "#1842",
      "createdAt": "2026-11-24T09:12:41Z",
      "status": "PAID",
      "total": 148.9,
      "currency": "USD",
      "customerEmail": "[email protected]",
      "customerName": "Lena Fischer",
      "items": [
        { "title": "Trail Jacket - M", "sku": "TJ-M-OLV", "quantity": 1 },
        { "title": "Wool Socks", "sku": "WS-42", "quantity": 2 }
      ]
    },
    {
      "id": "6210470871202",
      "name": "#1841",
      "createdAt": "2026-11-24T08:55:03Z",
      "status": "PENDING",
      "total": 59,
      "currency": "USD",
      "customerEmail": null,
      "customerName": null,
      "items": [{ "title": "Headlamp 400", "sku": "HL-400", "quantity": 1 }]
    }
  ],
  "count": 50,
  "cost": {
    "requestedQueryCost": 702,
    "actualQueryCost": 318,
    "throttleStatus": {
      "maximumAvailable": 2000,
      "currentlyAvailable": 1682,
      "restoreRate": 100
    }
  }
}

The median CustomJS inline script finishes in 121 ms; this one adds Shopify's response time, so plan for a few hundred milliseconds. It is 1 Make credit either way, since CustomJS bills per request, not per second. The cost object is Shopify's own accounting: requestedQueryCost is the estimate, actualQueryCost what you were charged, and throttleStatus.currentlyAvailable what is left in the bucket. Standard plans restore 100 points per second (checked October 2026 on shopify.dev). If Shopify answers MAX_COST_EXCEEDED, lower first on lineItems, because connections are priced by requested page size. Note the ?. on customer: it is null for guest and POS orders.

How do I run a Shopify mutation for a whole array in one call?

The common case is "write one value onto each of these records". metafieldsSet takes an array, so one code step replaces an Iterator plus one Shopify module per item. Shopify caps it at 25 metafields per call and the operation is atomic: if one entry fails, none are written. The example takes { orderId, key, value } objects from an Array Aggregator and stamps a warehouse reference onto each order.

{
  "shop": "acme-outdoor",
  "token": "{{shopifyToken}}",
  "updates": [
    { "orderId": "6210473263394", "key": "warehouse_ref", "value": "WH-DE-00921" },
    { "orderId": "6210470871202", "key": "warehouse_ref", "value": "WH-DE-00922" }
  ]
}
const data = typeof input === "string" ? JSON.parse(input) : input;
const { shop, token, updates } = data;
if (updates.length > 25) throw new Error("metafieldsSet takes at most 25 per call");

const mutation = `mutation SetRefs($metafields: [MetafieldsSetInput!]!) {
  metafieldsSet(metafields: $metafields) {
    metafields { ownerType key value }
    userErrors { field message code }
  }
}`;

const metafields = updates.map(u => ({
  ownerId: `gid://shopify/Order/${u.orderId}`,
  namespace: "fulfillment",
  key: u.key,
  type: "single_line_text_field",
  value: String(u.value)
}));

const url = `https://${shop}.myshopify.com/admin/api/2026-10/graphql.json`;
const res = await fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json", "X-Shopify-Access-Token": token },
  body: JSON.stringify({ query: mutation, variables: { metafields } })
});
const json = await res.json();
if (json.errors) throw new Error(JSON.stringify(json.errors));

const { metafields: written, userErrors } = json.data.metafieldsSet;
if (userErrors.length) {
  throw new Error(userErrors.map(e => `${e.code}: ${e.message}`).join("; "));
}
return { written: written.length, keys: written.map(m => m.key) };
{
  "written": 2,
  "keys": ["warehouse_ref", "warehouse_ref"]
}

The userErrors check is the part people skip. A failed mutation comes back as HTTP 200 with an empty metafields array, so nothing watching the status fires. Throwing turns it into a module error Make's error routes can catch. The same shape works for inventoryAdjustQuantities, with one caveat: from API version 2026-04 it requires an @idempotent directive, so read its reference page first.

Use our Make App to execute JavaScript directly in Make.

Should I use Make's Shopify module or a code step?

TaskNative Shopify moduleCode step
AuthenticationStored Make connection, OAuth handled for youToken from a Make variable in the Input field
Get one order, create one productDedicated module, fields in the mapping panelWorks, but no advantage
50 orders with nested line items and customer"Make a GraphQL API call" returns raw edges/node JSONFlat array, one operation
Write a value onto 25 recordsIterator + 25 module calls, 26 creditsOne metafieldsSet call, 1 credit
Failed mutation (userErrors)HTTP 200, run continues unless you add a filterthrow stops the run
Query cost and throttle statusIn the raw response, if you dig for itReturned as a field, can gate a retry

If several scenarios need the same query, save it as a stored function with shop and token as parameters, so the API version changes in one place (setup guide).

When Make's built-in is enough

  • Watching for new orders. The Shopify "Watch orders" trigger is the right tool. A code step cannot be a trigger.
  • Single-record reads and writes. Get an Order, Create a Product, Update a Customer: one module, one credit, fields in the mapping panel. Code adds nothing.
  • A query with no nesting. If the top-level fields from "Make a GraphQL API call" are enough and map() can read them, stay native.

Reach for the code step when the response is nested, when a mutation takes an array, or when a silent userErrors response has already cost you a bad run. The general pattern is in building an API request body in Make.

Try the snippet on the free tier, 600 requests a month

Frequently Asked Questions

Related Articles

Continue reading on similar topics

Call Google Apps Script From Make With a Code Step
·Recipe

Call Google Apps Script From Make With a Code Step

Deploy an Apps Script doPost web app and call it from one Make code step: POST the JSON payload with fetch, follow Google's 302 redirect, parse the result. Covers the access settings and the Execution API.

makemake-comgoogle-apps-script