MESA Docs
MESA Homepage
  • Welcome to MESA
    • Installing MESA
    • Dashboard
    • Core Concepts
    • Getting Help
  • Templates
    • Template Library
    • Installing & Editing
  • Workflow Builder
    • Triggers
    • Actions
    • Fields
      • Variables
      • Formatting Variables
      • Liquid Templating
    • Testing
  • Workflow Activity
    • Tasks
      • Troubleshooting
      • Replay
    • Logs
    • Time Travel
  • Best Practices
    • Set Titles & Descriptions
    • Track Time Saved
    • Enable Failure Notifications
    • Avoid Infinite Loops
  • Going Further
    • Plans & Billing
    • Notifications
    • Credentials
    • Understanding the Queue
    • Export & Import Workflows
    • Platform Thresholds & Limits
  • Built-in Tools
    • Activity Log
    • AI
    • API
    • Approval
    • MCP
    • Custom Code
      • Libraries
        • MESA SDK
        • Filter
        • Loop
        • Transform
        • oAuth
        • Shopify
        • ShopifyGraphql
      • FAQ
    • Data
    • Delay
    • Email
    • Filter
    • Form
      • Configure
      • Going Further
      • Technical Notes
    • FTP
    • Image
    • Loop
    • Package Tracking
    • Paths
    • Schedule
    • Scraper
    • SMS
    • Transform
    • Virtual Output
    • Weather
    • Web Request
    • Webhook
  • Apps
    • Airtable
    • Amazon S3
    • Asana
    • Blog Studio
    • ChannelApe
    • Claude
    • ChatGPT
    • Dall-E 2
    • Delighted
    • Digital Humani
    • Discord
    • DocuSign
    • Dropbox
    • Etsy
    • Facebook
    • Fera.ai
    • Gatsby
    • Gmail
      • Send Email
    • Google Analytics 4
    • Google Analytics UA
    • Google Calendar
    • Google Drive
    • Google Forms
    • Google Sheets
      • Add Row
      • Query Rows
      • Update Row
      • Row Created
      • Row Updated (Advanced)
      • Creating New Spreadsheets
      • Technical Notes
    • Gorgias
    • Govalo
    • Help Scout
    • Hubspot
    • Infinite Options
    • Intercom
    • IPDetective
    • Judge.me
    • Katana
    • Klaviyo
      • API Deprecation
    • Loop Returns
    • Loyalty Lion
    • Mailchimp
    • Mailgun
    • Mandrill
    • Mantle
    • Notion
    • Odoo
    • Omnisend
    • Page Studio
    • Pinterest
    • Printful
    • PrintNode
    • QuickBooks
    • Rebuy
    • Recharge
    • Remove.bg
    • Returnly
    • Rivo
    • Salesforce
    • Segment
    • Sendlane
    • Shippo
    • ShipStation
    • Shopify
      • Technical Notes
        • Configuring Your Payload
        • Modifying and Filtering Get Lists
        • Parameters
        • Error Codes
        • Accuracy of orders_count Variable
        • Accuracy of Count Products Action
        • Using the Gift Cards API
        • How to Find a Specific Record in the Testing Interface
        • Order, Customer, and Product Updated Trigger Frequency
    • Shopify Flow
    • Shopify Plus
    • Shopify Retail POS
    • Skio Subscriptions
    • Slack
    • Smartrr
    • Smile.io
    • Square
      • Updating Inventory
      • Frequently Asked Questions
    • Stamped.io
    • Stripe
    • Thanks.io
    • TikTok
    • Tracktor
    • Twilio
    • Uploadery
    • Wonderment
    • Xero
    • Yotpo
    • Yotpo Loyalty
  • For developers
    • Admin API
    • Command Line Interface
    • Embedding templates
  • Frequently asked questions
    • Why isn't the log search returning logs with the search I entered?
    • Is it possible to handle errors or retry steps?
    • How do I handle a failed task?
    • Does MESA auto-save workflows?
    • Can I Use Apps That Don't Have a MESA Connector?
    • Why is my workflow action adding the same data each time it occurs?
    • How do I cancel automations that are already in progress?
    • How do I cancel my MESA subscription or 7-day trial?
    • Can you import code from npm in custom code?
    • Do you have a Slack Community?
Powered by GitBook
On this page
  • Shopify()
  • request()
  • Shopify.get(path[, options, connectionInfo])
  • handleImageList(path, options, connectionInfo)
  • handleImage(originalPath, options, connectionInfo)
  • handleProductCount(options, connectionInfo)
  • handlePaginatedGraphQLQuery(queryFunction, options, transformFunction, connectionInfo)
  • handleProductList(path, options, connectionInfo)
  • Shopify.handleProduct(originalPath, options, connectionInfo)
  • Shopify.handleProductPost(data[, connectionInfo])
  • handleVariantList(path, options, connectionInfo)
  • Shopify.handleVariant(originalPath, options, connectionInfo)
  • handleImagePost(data, connectionInfo)
  • send(query, variables, connectionInfo, endpoint)
  • Shopify.post(path, data[, options, connectionInfo])
  • handleVariantPut(productId, variantId, data, connectionInfo)
  • handleProductPut(productId, data, connectionInfo)
  • Shopify.put(path, data[, options, connectionInfo])
  • Shopify.patch(path, data[, options, connectionInfo])
  • Shopify.delete(path[, options, connectionInfo])
  • getMyshopifyDomain(context)
  • getShopifyAdminUrl(context)
  • getShopifyUuid(context)
  • deleteProduct(path, options, connectionInfo)
  • deleteVariant(path, options, connectionInfo)
  • deleteImage(path, options, connectionInfo)
  • getAllProducts([query={}, limit=250])
  • appendToArray([data], The)
  • getVariantInventoryData(variantId)
  • buildVariantInventoryUpdate(variantId, inventoryCount[, adjust=true, fulfillableAlter])
  • {Object} Options()
  • {Object} ConnectionInfo()
  • {Object} FulfillableLocation()
  • {Function} fulfillableAlter(inventoryLevels)
  • {Object} InventoryData()
  • {Object} InventoryUpdateData()

Was this helpful?

  1. Built-in Tools
  2. Custom Code
  3. Libraries

Shopify

vendor/Shopify.js

Shopify()

Interact with the Shopify Admin API.

Returns

  • Void

request()

Make a request to a Shopify site.

This is just a wrapper to Mesa.shopify.request.

Returns

  • Void

Shopify.get(path[, options, connectionInfo])

Make a GET request to a Shopify site.

Parameters

Name
Type
Description

path

string

options

Additional configuration for Shopify calls

Optional

connectionInfo

If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.

Optional

Returns

  • object

handleImageList(path, options, connectionInfo)

Handles listing of images with pagination.

Parameters

Name
Type
Description

path

string

- Shopify REST endpoint path.

options

Object

- Query options.

connectionInfo

Object

- Connection info for external Shopify sites.

Returns

  • Array Array of images in REST format.

handleImage(originalPath, options, connectionInfo)

Handles retrieval of a single image by its ID for a specific product.

Parameters

Name
Type
Description

originalPath

string

- Original API endpoint path.

options

- Query options (not used in this implementation).

connectionInfo

- Connection information for Shopify.

Returns

  • Object Processed image data in REST format.

handleProductCount(options, connectionInfo)

Handles the product count query.

Parameters

Name
Type
Description

options

connectionInfo

Returns

handlePaginatedGraphQLQuery(queryFunction, options, transformFunction, connectionInfo)

Handles paginated GraphQL queries for products or variants.

Parameters

Name
Type
Description

queryFunction

Function

- Function that generates a GraphQL query.

options

Object

- Query options, including filters and limits.

transformFunction

Function

- Function to transform the returned data into the desired REST format.

connectionInfo

Object

- Optional connection info for external Shopify sites.

Returns

  • Array Array of transformed paginated results.

handleProductList(path, options, connectionInfo)

Handles listing of products with pagination.

Parameters

Name
Type
Description

path

string

- Shopify REST endpoint path.

options

Object

- Query options.

connectionInfo

Object

- Connection info for external Shopify sites.

Returns

  • Array Array of products in REST format.

Shopify.handleProduct(originalPath, options, connectionInfo)

Retrieve a single product by ID using GraphQL and convert it to REST format.

Parameters

Name
Type
Description

originalPath

string

- Original API endpoint path.

options

- Options containing query parameters.

connectionInfo

- Connection information for a separate Shopify store.

Returns

  • object Product data in REST format.

Shopify.handleProductPost(data[, connectionInfo])

Handles the creation of a product and its variants, if provided. Converts the REST payload into the appropriate GraphQL format.

Parameters

Name
Type
Description

data

Object

- The product data in REST API format.

connectionInfo

- Connection information for Shopify.

Optional

Returns

  • Object - The product payload in REST API format.

handleVariantList(path, options, connectionInfo)

Handles listing of variants with pagination.

Parameters

Name
Type
Description

path

string

- Shopify REST endpoint path.

options

Object

- Query options.

connectionInfo

Object

- Connection info for external Shopify sites.

Returns

  • Array Array of variants in REST format.

Shopify.handleVariant(originalPath, options, connectionInfo)

Retrieve a specific variant by product ID and variant ID using GraphQL and convert it to REST format.

Parameters

Name
Type
Description

originalPath

string

- Original API endpoint path.

options

- Options containing query parameters.

connectionInfo

- Connection information for a separate Shopify store.

Returns

  • object Variant data in REST format.

handleImagePost(data, connectionInfo)

Handles the creation of a product image. Converts the REST payload to GraphQL format and returns the response in REST format.

Parameters

Name
Type
Description

data

Object

- The REST image payload.

connectionInfo

- Shopify connection info.

Returns

  • Object - The image payload in REST format.

send(query, variables, connectionInfo, endpoint)

Send a GraphQL query to Shopify.

Parameters

Name
Type
Description

query

variables

connectionInfo

endpoint

Returns

  • object

Shopify.post(path, data[, options, connectionInfo])

Make a POST request to a Shopify site.

By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.post('/admin/products.json', data) will result in { "product": { data } } use options.skipJsonWrap=true to override this behavior

Parameters

Name
Type
Description

path

string

data

object

options

Additional configuration for Shopify calls

Optional

connectionInfo

If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.

Optional

Returns

  • object

handleVariantPut(productId, variantId, data, connectionInfo)

Handles updating a single variant for a specific product.

Parameters

Name
Type
Description

productId

string

- The ID of the product.

variantId

string

- The ID of the variant.

data

Object

- The variant data to update.

connectionInfo

- Shopify connection details.

Returns

  • Object - The updated variant in REST format.

handleProductPut(productId, data, connectionInfo)

Handles the updating of a product and its related entities (variants, images, etc.).

Parameters

Name
Type
Description

productId

string

- The ID of the product to update.

data

Object

- The product data to update.

connectionInfo

- Shopify connection details.

Returns

  • Object - The updated product in REST format.

Shopify.put(path, data[, options, connectionInfo])

Make a PUT request to a Shopify site.

By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.put('/admin/products.json', data) will result in { "product": { data } } use options.skipJsonWrap=true to override this behavior

Parameters

Name
Type
Description

path

string

data

object

options

Additional configuration for Shopify calls

Optional

connectionInfo

If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.

Optional

Returns

  • object

Shopify.patch(path, data[, options, connectionInfo])

Make a PATCH request to a Shopify site.

By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.patch('/admin/products.json', data) will result in { "product": { data } } use options.skipJsonWrap=true to override this behavior

Parameters

Name
Type
Description

path

string

data

object

options

Additional configuration for Shopify calls

Optional

connectionInfo

If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.

Optional

Returns

  • object

Shopify.delete(path[, options, connectionInfo])

Make a DELETE request to a Shopify site.

By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.post('/admin/products.json', data) will result in { "product": { data } } use options.skipJsonWrap=true to override this behavior

Parameters

Name
Type
Description

path

string

options

Additional configuration for Shopify calls

Optional

connectionInfo

If you would like to connect to a separate Shopify website that Mesa is not installed on, create a Custom App and include a connectionInfo object.

Optional

Returns

  • object

getMyshopifyDomain(context)

Returns myshopify domain from the credential.

Parameters

Name
Type
Description

context

Returns

  • string The myshopify domain. Ex: mystore.myshopify.com

getShopifyAdminUrl(context)

Returns myshopify domain from the credential.

Parameters

Name
Type
Description

context

Returns

  • string The Shopify admin url, including https://. Ex: https://admin.shopify.com/store/mystore

getShopifyUuid(context)

Returns the subdomain part of the myshopify domain from the credential.

Parameters

Name
Type
Description

context

Returns

  • string The subdomain part of the myshopify domain. Ex: mystore

deleteProduct(path, options, connectionInfo)

Delete a product by ID.

Parameters

Name
Type
Description

path

string

- Shopify REST endpoint path.

options

Object

- Query options.

connectionInfo

Object

- Connection info for external Shopify sites.

Returns

  • Void

deleteVariant(path, options, connectionInfo)

Delete a variant by ID.

Parameters

Name
Type
Description

path

string

- Shopify REST endpoint path.

options

Object

- Query options.

connectionInfo

Object

- Connection info for external Shopify sites.

Returns

  • Void

deleteImage(path, options, connectionInfo)

Delete a product image by ID.

Parameters

Name
Type
Description

path

string

- Shopify REST endpoint path.

options

Object

- Query options.

connectionInfo

Object

- Connection info for external Shopify sites.

Returns

  • Void

getAllProducts([query={}, limit=250])

Make consecutive calls to Shopify in order to retrieve all products. https://help.shopify.com/en/api/reference/products/product

Parameters

Name
Type
Description

query={}

object

Parameters to append to the Shopify querystring.

Optional

limit=250

number

Result count for Shopify query.

Optional

Examples

// returns array of all products
const Shopify = require('vendor/Shopify.js');
Shopify.getAllProducts();

Returns

  • array

appendToArray([data], The)

Update a value if it already exists, or append it to the array if it does not exist. The example routine below should be every time we are updating tags or note_attributes to ensure that multiple Automations will work nicely with each other and not overwrite values set in other Automations.

Parameters

Name
Type
Description

data

array

An array of values that you would like to append a value to

Optional

The

string object

value to append to the array. For tags, this would be a string. For note_attributes, this would be an object.

Examples

Mesa.log.debug('Calling shopify to get the latest order note_attributes');
const order = Shopify.get(`admin/orders/${payload.id}.json`);
let noteAttributes = order.order.note_attributes;
noteAttributes = Shopify.appendToArray(noteAttributes, {
   name: 'dob',
   value: 'Jan 1 2000',
});

Returns

  • array

getVariantInventoryData(variantId)

Get inventory location information for a Shopify variant. https://help.shopify.com/en/api/reference/inventory/inventorylevel

Parameters

Name
Type
Description

variantId

number

Shopify variant id.

Examples

// returns { inventory_item_id: {number}, [ { inventory_levels: { inventory_item_id: {number}, location_id: {number}, available: {number}, updated_at: {string} } ] }
const Shopify = require('vendor/Shopify.js');
Shopify.getVariantInventoryData(123456);

Returns

  • <a href="#object-inventorydata">InventoryData</a>

buildVariantInventoryUpdate(variantId, inventoryCount[, adjust=true, fulfillableAlter])

Build InventoryLevel update information for a Shopify variant. https://help.shopify.com/en/api/reference/inventory/inventorylevel

Parameters

Name
Type
Description

variantId

number

Shopify variant id.

inventoryCount

number

Value to set as inventory.

adjust=true

bool

Switch for available_adjustment vs available.

Optional

fulfillableAlter

Callback function allows fulfillment location to be altered.

Optional

Examples

// note string for location_id, as it is required by Shopify API post
// returns { inventory_item_id: {number}, location_id: {string}, available|available_adjustment: {number} } ] }
const Shopify = require('vendor/Shopify.js');
Shopify.buildVariantInventoryUpdate(123456, 10, true|false);

Returns

  • <a href="#object-inventoryupdatedata">InventoryUpdateData</a>

{Object} Options()

options parameter for Shopify calls

By default Shopify calls will auto-wrap any outgoing JSON data, eg. Shopify.post('/admin/products.json', data) will result in { "product": { data } } use skipJsonWrap=true to override this behavior

Properties

Returns

  • Void

{Object} ConnectionInfo()

connectionInfo parameter for Shopify calls

Properties

Returns

  • Void

{Object} FulfillableLocation()

Fulfillable location shape returned by fulfillableAlter https://help.shopify.com/en/api/reference/inventory/location

Parameters

Name
Type
Description

location_id

number

The ID of the location that the inventory level belongs to.

Returns

  • Void

{Function} fulfillableAlter(inventoryLevels)

Callback allows buildVariantInventoryUpdate fulfillment location to be altered. https://help.shopify.com/en/api/reference/inventory/inventorylevel

Parameters

Name
Type
Description

inventoryLevels

Array.<Object>

Inventory levels for the variant at different locations.

inventoryLevels.inventory_item_id

number

Inventory item id for variant

inventoryLevels.location_id

number

Location id

inventoryLevels.available

number

Inventory count

inventoryLevels.updated_at

string

Last updated

Returns

  • <a href="#object-fulfillablelocation">FulfillableLocation</a> fulfillableLocation

{Object} InventoryData()

Return from getVariantInventoryData.

Properties

Returns

  • Void

{Object} InventoryUpdateData()

Return from buildVariantInventoryUpdate. Will either have available or available_adjustment depending on adjust param. https://help.shopify.com/en/api/reference/inventory/inventorylevel

Properties

Returns

  • Void

PreviousoAuthNextShopifyGraphql

Last updated 2 months ago

Was this helpful?

Options
ConnectionInfo
Options
ConnectionInfo
Options
ConnectionInfo
ConnectionInfo
Options
ConnectionInfo
ConnectionInfo
Options
ConnectionInfo
ConnectionInfo
ConnectionInfo
Options
ConnectionInfo
Options
ConnectionInfo
Options
ConnectionInfo
fulfillableAlter