How it works

Follow these 4 simple steps to clean underscore properties from your ShipStation orders

shipstation logo icon

Order Created

App connector: ShipStation • Time to complete: 0 minutes (Auto-configured)
Why this matters: This trigger monitors your ShipStation account for new orders and kicks off the cleaning process automatically whenever an order arrives.

This step listens for new orders in ShipStation and captures the basic order information needed to retrieve the full order details. The trigger activates whenever ShipStation receives a new order notification, whether from your ecommerce platform, marketplace, or manual entry. It passes the order ID to the next step so the workflow can fetch complete order details including line item properties that need cleaning.

Retrieve Order

App connector: ShipStation • Time to complete: 0 minutes (Auto-configured)
Why this matters: This step fetches the complete order details including all line item properties, giving the workflow access to the underscore properties that need to be removed.

This step uses the order ID from the trigger to pull the full order record from ShipStation's API, including all line items and their associated properties. The system automatically configures the API call using the order ID captured in the previous step. This retrieval is essential because the initial trigger only provides basic order information, but the cleaning process needs access to the detailed line item properties where underscore fields are stored.

Custom Code - Remove Underscore Line Item Properties

App connector: Code • Time to complete: 0 minutes (Auto-configured)
Why this matters: This is where the actual cleaning happens - it identifies and removes any line item properties that start with underscore characters from the order data.

This custom code step processes each line item in the order and filters out properties whose names start with an underscore character. The script loops through all items in the order and removes unwanted properties from the options array. However, there appears to be a bug in the current code - it's checking for a space character instead of an underscore. The corrected version should filter properties where the first character is an underscore rather than a space.

const Mesa = require('vendor/Mesa.js');

module.exports = new (class {
  script = (prevResponse, context) => {
    const vars = context.steps;
    let updatedShipstationOrder = vars.shipstation_1;

    // Remove line item properties starting with underscore
    for (let item of updatedShipstationOrder.items) {
      item.options = item.options.filter(option => 
        option.name.charAt(0) !== "_"  // Fixed: was checking for " " instead of "_"
      );
    }

    Mesa.output.next({updatedShipstationOrder: updatedShipstationOrder});
  };
})();
code icon

Custom Code - ShipStation Create/Update Order

App connector: Code • Time to complete: 2 minutes
Why this matters: This final step saves the cleaned order data back to ShipStation, replacing the original order with the version that has underscore properties removed.

This step takes the cleaned order data and sends it back to ShipStation using their Create/Update Order API endpoint. The code retrieves your ShipStation API credentials, constructs the proper authorization header, and makes a POST request to update the order with the cleaned line item properties. You'll need to create a ShipStation credential in MESA before this step will work - the credential should contain your ShipStation API key and secret. The updated order replaces the original in ShipStation with all underscore properties removed from line items.

const Mesa = require('vendor/Mesa.js');

module.exports = new (class {
  script = (prevResponse, context) => {
    const vars = context.steps;
    let updatedShipstationOrder = vars.custom.updatedShipstationOrder;

    // Get ShipStation credential (needs to be created first)
    let credential = JSON.parse(Mesa.credential.get('shipstation'));
    let authHeader = Mesa.request.base64_encode(`${credential.key}:${credential.secret}`);

    let options = {
      "headers": {
        "Content-Type": "application/json",
        "Authorization": "Basic " + authHeader,
      }
    };

    let url = 'https://ssapi.shipstation.com/orders/createorder';
    let results = Mesa.request.post(url, updatedShipstationOrder, options);   

    Mesa.output.next(prevResponse);
  };
})();

Make it your own

Customize this workflow even further:

Filter specific property patterns
Instead of removing all underscore properties, customize the filter to target specific naming patterns like removing only "_internal" or "_temp" properties while keeping others.
Add logging and notifications
Extend the workflow to log which properties were removed and send email notifications when orders are processed, helping you track the cleaning activity.
Store cleaned data in tables
Save details about removed properties in MESA tables for audit purposes, including order ID, removed property names, and processing timestamps.
Chain with order fulfillment actions
Connect this cleaning workflow to subsequent fulfillment steps like automatically creating shipping labels or updating inventory after the properties are cleaned.

Frequently asked questions

Why does the workflow need ShipStation API credentials?
The final step updates orders in ShipStation using their API, which requires authentication. You'll need to create a credential in MESA with your ShipStation API key and secret, which you can find in your ShipStation account settings under API Settings.
Will this affect the original order data in my ecommerce platform?
No, this workflow only modifies the order copy in ShipStation. The original order in your ecommerce platform (Shopify, WooCommerce, etc.) remains unchanged with all its original properties intact.
What happens if the code encounters line items without any properties?
The workflow handles this gracefully - if a line item has no options/properties, the filter operation simply processes an empty array and moves to the next item without causing errors or stopping the workflow.
What is a template?
Templates are pre-made workflows by our team of experts. Instead of building a workflow from scratch, these have all the steps needed to complete the task.
Can I personalize a template?
Yes! Every step can be customized to meet your exact requirements. Additionally, you can even add more steps and make it more sophisticated.
Are templates free?
Yes! Our entire library containing hundreds of templates are free to use and customize to your exact needs.

Ready to clean underscore properties from your ShipStation orders?

Join thousands who've automated their work and saved an average of 3.5 hours every week.

Start with this template — It's free
7-day free trial • 5 min setup • Cancel anytime