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
  • Mesa.log.info(message[, meta])
  • Mesa.log.warn(message[, meta])
  • Mesa.log.error(message[, meta])
  • Mesa.log.debug(message[, meta])
  • Mesa.request.get(path, options)
  • Mesa.request.post(path, data, options)
  • Mesa.request.put(path, data, options)
  • Mesa.request.patch(path, data, options)
  • Mesa.request.delete(path, options)
  • Mesa.request.send(method, path, data, options)
  • Mesa.request.base64_encode(string)
  • Mesa.request.base64_decode(string[, strict])
  • Mesa.request.hash(algorithm, string[, base64encode])
  • Mesa.request.hashHmac(algorithm, string, string[, base64encode])
  • Mesa.request.sleep($seconds)
  • Mesa.credential.get(key[, defaultValue])
  • Mesa.credential.set(key, value[, options])
  • Mesa.database.query(sql)
  • Mesa.storage.get(key[, defaultValue])
  • Mesa.storage.set(key, value)
  • Mesa.liquid.render(template, params)
  • Mesa.input.getWebhookUrl(type, format, automationId, key)
  • Mesa.output.next(payload, params)
  • Mesa.output.send(outputKey, payload, enqueue)
  • Mesa.automation.send(automationKey, payload)
  • Mesa.ftp.deleteFile(filename)
  • Mesa.ftp.moveFile(filename, destinationFilenameAndPath)
  • Mesa.xml.decode(xmlString[, namespaceSep='_'])
  • Mesa.xml.encode(xmlObject[, wrapReplace, namespaceSep='_'])
  • Mesa.xml.valid(xmlString)
  • Mesa.csv.decode(data[, returnObject, options])
  • Mesa.csv.encode(data[, headerRow])
  • Mesa.vo.push(outputKey, payload)
  • Mesa.vo.clear(outputKey)
  • Mesa.vo.clearOne(outputKey, mesaId)
  • Mesa.date.setTimezone(timezone)
  • {Object} RequestOptions()
  • {Object|String} Response()
  • {Object} ResponseRaw()

Was this helpful?

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

MESA SDK

vendor/Mesa.js

Mesa.log.info(message[, meta])

Log info to Mesa Logs.

Parameters

Name
Type
Description

message

string

meta

object

Optional

Mesa.log.warn(message[, meta])

Log a warning to Mesa Logs.

Parameters

Name
Type
Description

message

string

meta

object

Optional

Mesa.log.error(message[, meta])

Log an error to Mesa Logs.

Parameters

Name
Type
Description

message

string

meta

object

Optional

Mesa.log.debug(message[, meta])

Log info to Mesa Logs only if the Automation is in Debug Mode.

Parameters

Name
Type
Description

message

string

meta

object

Optional

Mesa.request.get(path, options)

Make a GET request to an external Rest API.

Parameters

Name
Type
Description

path

string

options

Returns

Mesa.request.post(path, data, options)

Make a POST request to an external Rest API.

Parameters

Name
Type
Description

path

string

data

object

options

Returns

Mesa.request.put(path, data, options)

Make a PUT request to an external Rest API.

Parameters

Name
Type
Description

path

string

data

object

options

Returns

Mesa.request.patch(path, data, options)

Make a PATCH request to an external Rest API.

Parameters

Name
Type
Description

path

string

data

object

options

Returns

Mesa.request.delete(path, options)

Make a DELETE request to an external Rest API.

Parameters

Name
Type
Description

path

string

options

Returns

Mesa.request.send(method, path, data, options)

Make a request to an external Rest API.

Parameters

Name
Type
Description

method

string

One of GET, POST, PUT, PATCH, or DELETE

path

string

data

object

options

Returns

Mesa.request.base64_encode(string)

Base-64 encode a string. This is helpful when building an Authorization header for basic auth requests.

Parameters

Name
Type
Description

string

string

The string to encode

Returns

  • string The base-64 encoded version of the input string parameter.

Mesa.request.base64_decode(string[, strict])

Base64 decode a string. Decodes data encoded with MIME base64

Parameters

Name
Type
Description

string

string

The base-64 encoded version of the input string parameter.

strict

bool

If the strict parameter is set to TRUE then the base64_decode() function will return FALSE if the input contains character from outside the base64 alphabet. Defaults to FALSE.

Optional

Returns

  • string The decoded string.

Mesa.request.hash(algorithm, string[, base64encode])

Generate a hash of a string. This is helpful when creating signed requests.

Parameters

Name
Type
Description

algorithm

string

The algorithm to use. Options: sha1, sha256, md5

string

string

The string to create the hash from

base64encode

string

Should we base64-encode the raw value of the hash?

Optional

Returns

  • string The raw binary data of the hash

Mesa.request.hashHmac(algorithm, string, string[, base64encode])

Generate a keyed hash value using the HMAC method. This is helpful when creating signed requests.

Parameters

Name
Type
Description

algorithm

string

The algorithm to use. Options: sha1, sha256, md5

string

string

The string to create the hash from

string

string

Shared secret key used for generating the HMAC variant of the message digest

base64encode

string

Should we base64-encode the raw value of the hash?

Optional

Returns

  • string The raw binary data of the hash

Mesa.request.sleep($seconds)

Pauses execution

Parameters

Name
Type
Description

$seconds

int

Returns

Mesa.credential.get(key[, defaultValue])

Get a secret.

Parameters

Name
Type
Description

key

string

defaultValue

string

A default value to use if the secret cannot be found. If defaultValue is empty, the script will throw a fatal error if the secret is not found.

Optional

Returns

  • string The secret value.

Mesa.credential.set(key, value[, options])

Save a secret value.

Parameters

Name
Type
Description

key

string

The credential key or id.

value

string

The value to save. This will be encrypted at rest, and can contained a stringified JSON array.

options

object

Optional

options.oauth_provider

bool

Optional

options.oauth_scope

object

Optional

options.trigger_type

object

Optional

Mesa.database.query(sql)

Get a storage item

Parameters

Name
Type
Description

sql

string

The SQL query to run

Returns

  • array The result of the query.

Mesa.storage.get(key[, defaultValue])

Get a storage item

Parameters

Name
Type
Description

key

string

defaultValue

string

A default value to use if the storage key cannot be found. If defaultValue is empty, the script will throw a fatal error if the storage key is not found.

Optional

Returns

  • string The storage value.

Mesa.storage.set(key, value)

Get a storage item

Parameters

Name
Type
Description

key

string

value

string

Mesa.liquid.render(template, params)

Render a liquid template with the params passed.

Parameters

Name
Type
Description

template

string

String representing a liquid template.

params

object

A keyed object of parameters to replace.

Returns

  • string The rendered template code.

Mesa.input.getWebhookUrl(type, format, automationId, key)

Generates the URL for input webhooks

Parameters

Name
Type
Description

type

string

Type of webhook: json, shopify

format

string

Format of the returned data: string or array. If string, a full URL is returned. If array, URL will comprise two fields suffix and prefix

automationId

string

ID of the Automation

key

string

The key of the trigger

Returns

  • string array The rendered template code.

Mesa.output.next(payload, params)

Pass a payload to the service and call the next step in this Automation.

Parameters

Name
Type
Description

payload

object

params

object

Parameters to send to the output, such as tokens to construct a Shopify API url

params.enqueue

bool

Defaults to false. Set to true if you are exploding multiple tasks that can be run in parallel.

Optional

Mesa.output.send(outputKey, payload, enqueue)

Call an arbitrary output from a Mesa Script

Parameters

Name
Type
Description

outputKey

string

payload

object

enqueue

bool

Defaults to false. Set to true if you are exploding multiple tasks that can be run in parallel.

Mesa.automation.send(automationKey, payload)

Call another automation from a Mesa Script

Parameters

Name
Type
Description

automationKey

string

In the form ${automationKey}, this will trigger the first input in the Automation. In the form ${automationKey}/${inputKey}, this will trigger a specific input in the automation.

payload

object

Mesa.ftp.deleteFile(filename)

Delete the file loaded by the Input.

Parameters

Name
Type
Description

filename

string

Typically passed from context.filename.

Mesa.ftp.moveFile(filename, destinationFilenameAndPath)

Move the file loaded by the Input to a new location.

Parameters

Name
Type
Description

filename

string

Typically passed from context.filename.

destinationFilenameAndPath

string

Mesa.xml.decode(xmlString[, namespaceSep='_'])

Parameters

Name
Type
Description

xmlString

string

The xml file to be decoded

namespaceSep='_'

string

Optional

Returns

  • object

Mesa.xml.encode(xmlObject[, wrapReplace, namespaceSep='_'])

Convert an object into an XML string.

Parameters

Name
Type
Description

xmlObject

object

The object to be turned into xml.

wrapReplace

string

Replace the default wrapping provided with another value

Optional

namespaceSep='_'

string

Optional

Examples

// returns <?xml version="1.0" encoding="UTF-8"?><doc>\n  <book>\n ...
Mesa.xml.encode({ book: { ... }});
// returns <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n  <soapenv:Body>\n ...
Mesa.xml.encode({ soapenv_Body: { ... } }, '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">');

Returns

  • string

Mesa.xml.valid(xmlString)

Check if xml is valid

Parameters

Name
Type
Description

xmlString

string

Examples

// returns true
Mesa.xml.valid('<?xml version="1.0" encoding="UTF-8"?><doc><book><Name>My Book</Name></book></doc>');
// throws error about namespace
Mesa.xml.valid('<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope><book><Name>My Book</Name></book></soapenv:Envelope>');

Returns

  • bool

Mesa.csv.decode(data[, returnObject, options])

Convert a CSV file into an object. Keys will be matched from the first header row of the CSV file.

Parameters

Name
Type
Description

data

string

returnObject

bool

Defaults to true, which will return an object keyed by the first row in the CSV content. Set to false to return an array.

Optional

options

object

Optional

options.delimiter=','

string

The delimiter to use when parsing the CSV file. Must be a single character.

Optional

Returns

  • object array

Mesa.csv.encode(data[, headerRow])

Convert an object a CSV string.

Parameters

Name
Type
Description

data

object

headerRow

bool

Defaults to true. Set to false to skip the header row when returning CSV.

Optional

Returns

  • string

Mesa.vo.push(outputKey, payload)

Push to a Virtual Output.

Parameters

Name
Type
Description

outputKey

string

payload

mixed

Mesa.vo.clear(outputKey)

Mark the matching Virtual Output records as cleared by the current Mesa Script.

Parameters

Name
Type
Description

outputKey

string

Mesa.vo.clearOne(outputKey, mesaId)

Mark a single Virtual Output record as cleared by the current Mesa Script.

Parameters

Name
Type
Description

outputKey

string

mesaId

string

The ID of the record to clear (returned as mesa_id in the Virtual Output).

Mesa.date.setTimezone(timezone)

Set the timezone to use to execute all script commands.

Parameters

Name
Type
Description

timezone

string

Returns

  • string The timezone identifier, like UTC or Europe/Lisbon.

{Object} RequestOptions()

Request options

Parameters

Name
Type
Description

json

bool

Automatically add JSON Content-Type headers and decode the response. Defaults to true.

Optional

query

object

Parameters to append to the querystring.

headers

object

Headers to send to the request.

debug

bool

Log request information and response headers. Defaults to context.automation.debug (false).

Optional

skipJsonWrap

bool

Skip the named auto wrapping of outgoing data. Defaults to false.

Optional

include_headers

bool

Optional

options.debug_exclude_headers

array

Exclude headers from debugging information to keep secret keys a secret. An array of header keys (example: Content-Type).

Optional

stringify_large_ints

bool

If JSON response, and response has ints over the JS max int, will traverse entire payload and cast long ints to strings. Defaults to false.

Optional

{Object|String} Response()

Request response:

  • object if options.json is true,

  • string if options.json is false.

{Object} ResponseRaw()

Request response with headers when options.include_headers is true.

Parameters

Name
Type
Description

body

Response from the server

headers

object

Headers to from response.

request_method

string

The method used to create the response: GET, POST, etc.

request_url

string

The URL used to create the response.

PreviousLibrariesNextFilter

Last updated 2 months ago

Was this helpful?

Convert an XML file into an {object}. This function will condense XML namespaces into {namespaceSep = '_'} separated values: becomes { soapenv_Body: {} }

Namespace separator for replacing type values with soapenv_Body

Namespace separator for replacing soapenv_Body: {} values with

The timezone identifier, like UTC or America/Los_Angeles. .

Include headers in the response. The response format will be .

if options.include_headers is true,

soapenv:Body
Response
Response
Response
Response
Response
Response
ResponseRaw
soapenv:Body
soapenv:Body
See a full list of TZ Database names
RequestOptions
RequestOptions
RequestOptions
RequestOptions
RequestOptions
RequestOptions
ResponseRaw
Response