Fetching all product transfers from Shopify to Google Sheet

Hello,

We are trying to access inventory transfers via API (/admin/api/2023-10/inventory_transfers.json and inventoryTransfers GraphQL field), but both return either ‘Not Found’ or ‘Field doesn’t exist’.

We changed the API Version, we have the right read permissions and no plan restrictions (using professional plan). Still the log replies as:

|12:14:03 AM|Info|Response Code: 404|
|12:14:03 AM|Info|Response Text: {errors:Not Found}|
|12:14:03 AM|Info|Error fetching data from Shopify API|

function fetchInventoryTransfers() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Transfer Summary”);
sheet.clear(); // Optional: clear old data
sheet.appendRow([“ID”, “Origin”, “Destination”, “Status”, “Received Date”, “Estimated Arrival”]);

const accessToken = “xxxxxxxxxxxxxxxxxxx”; // Updated with the new access token
const storeUrl = “xxxxxxxxxxxxxxxxx”; // Replace with your Shopify store URL
const apiVersion = “2025-04”; // The API version you want to use
const endpoint = https://${storeUrl}/admin/api/${apiVersion}/inventory_transfers.json?limit=250; // Increased limit for larger sets of transfers

const options = {
method: “get”,
headers: {
“X-Shopify-Access-Token”: accessToken,
“Content-Type”: “application/json”
},
muteHttpExceptions: true
};

try {
// Fetch the first page of transfers
let response = UrlFetchApp.fetch(endpoint, options);
let data = JSON.parse(response.getContentText());

// Check if the response contains inventory transfers
let transfers = data.inventory_transfers;
if (!transfers || transfers.length === 0) {
  sheet.appendRow(["No transfers found"]);
  return;
}

// Write the transfer data to the sheet
transfers.forEach(transfer => {
  const id = transfer.id;
  const origin = transfer.origin_location ? transfer.origin_location.name : "—";
  const destination = transfer.destination_location ? transfer.destination_location.name : "—";
  const status = transfer.status;
  const receivedDate = transfer.processed_at || "—";
  const estimatedArrival = transfer.estimated_arrival_at || "—";

  sheet.appendRow([id, origin, destination, status, receivedDate, estimatedArrival]);
});

// Check if there are more pages of results and fetch them
let nextPageUrl = data.next_page_url;
while (nextPageUrl) {
  response = UrlFetchApp.fetch(nextPageUrl, options);
  data = JSON.parse(response.getContentText());
  transfers = data.inventory_transfers;

  transfers.forEach(transfer => {
    const id = transfer.id;
    const origin = transfer.origin_location ? transfer.origin_location.name : "—";
    const destination = transfer.destination_location ? transfer.destination_location.name : "—";
    const status = transfer.status;
    const receivedDate = transfer.processed_at || "—";
    const estimatedArrival = transfer.estimated_arrival_at || "—";

    sheet.appendRow([id, origin, destination, status, receivedDate, estimatedArrival]);
  });

  nextPageUrl = data.next_page_url; // Get the next page URL if it exists
}

} catch (error) {
Logger.log("Error fetching inventory transfers: " + error.message);
sheet.appendRow([“Error fetching data. Please check the logs.”]);
}
}