Remove Underscore Line Item Properties from Shipstation

5 min setup
No coding required
Runs automatically

Improve order readability by replacing underscores in line item properties with clean, human-friendly labels. This template triggers when a new order is created in ShipStation. MESA retrieves the order, removes underscores using a custom step, and updates the order with the cleaned-up line item properties—making the data easier to read for both staff and customers.

shipstation logo icon
Order Created
Retrieve Order
Custom Code - Remove Underscore Line Item Properties
code icon
Custom Code - ShipStation Create/Update Order

You're in good company

"MESA has been a game changer for us. And, if you ever get stuck, their support team is always super helpful."

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
PetFriendly

"It's like Zapier but exactly designed for Shopify. I have been able to complete all the workflows that I've needed."

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
Zailys

"The MESA team has been amazing at helping us set up our automations. We would highly recommend this app!"

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
Rothy's

How it works

4 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);
  };
})();

Ready to set this up? It only takes 5 minutes.

Our support team will even help you personalize this workflow for free.

Get started →

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.

Common questions

Why does the workflow need ShipStation API credentials?

Will this affect the original order data in my ecommerce platform?

What happens if the code encounters line items without any properties?

Ready to clean underscore properties from your ShipStation orders?

7-day free trial • 5 min setup • Cancel anytime

Need help? Our automation experts will help you personalize this workflow for free. Contact support