Auto-Create Katana Sales Orders from Square | Order Automation

Create Katana Sales Orders from Square Orders

13 min setup

No coding required

Runs automatically

Streamline your order management process by automatically generating a sales order in Katana whenever a new order is created in Square. This MESA workflow template eliminates manual data entry, reduces errors, and keeps your inventory updated in real time. Improve operational efficiency and accelerate order fulfillment to enhance the overall customer experience.

How it works

13 steps to start creating Katana sales orders from Square orders automatically

Square Order Created (Trigger)

App connector: [Square](/content/apps/square/integrate "View Square integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: This trigger captures Square orders the instant they're placed through POS or online checkout, enabling immediate workflow initiation that ensures production teams have order visibility without manual entry or delays.

When an order is created in Square (through Square POS, online ordering, or API), Square sends a webhook to MESA triggering this workflow. The webhook captures complete order data including customer ID, line items with catalog object IDs and quantities, total amounts, currency, discounts, and timestamps.

Retrieve Square Customer

App connector: [Square](/content/apps/square/integrate "View Square integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Fetches complete customer information including contact details and shipping address needed for creating comprehensive Katana customer records and sales orders with proper fulfillment data.

This step retrieves the Square customer record using the customer ID from the order webhook. It returns complete customer data including given name, family name, company name, email address, phone number, and complete address with all components. This comprehensive data enables creation of detailed Katana customer and sales order records.

Loop over Square Line Items

App connector: [Loop](/content/apps/loop/integrate "View Loop integration page"/index.html)• Time to complete: 1 minute

Why this matters: Processes each product in the order separately to collect SKUs, ensuring multi-item orders capture all products needed for Katana variant matching and sales order line item creation.

This loop iterates through the order's line items array. For every product, the loop executes catalog object retrieval to fetch SKU information. This per-product processing builds the SKU list needed for Katana product matching in later steps.

Retrieve Catalog Object

App connector: [Square](/content/apps/square/integrate "View Square integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Fetches complete product catalog information including SKU from Square's catalog system, providing the product identifier needed to match Square products with Katana manufacturing variants.

This step retrieves the Square catalog object using the catalog object ID from the line item. It returns catalog data including item variation details with SKU, pricing, and product attributes. The SKU is captured for Katana product matching.

Look Up Customer in Katana

App connector: [Katana](/content/apps/katana/integrate "View Katana integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Searches Katana for an existing customer record using email address to determine whether to create a new customer or use an existing one, preventing duplicate customer records in the manufacturing system.

This step queries Katana's customer database using the Square customer's email address with limit 1 to return only the first match. It searches for customers matching the email and returns customer records including Katana customer ID if found. If no match exists, the array is empty.

Route by Customer Status

App connector: [Paths](/content/apps/paths/integrate "View Paths integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Creates a decision point that routes the workflow down different paths based on whether the customer exists in Katana, enabling conditional processing that handles both new and existing customers appropriately.

This Paths step establishes a branching structure with two possible routes: Path 1 (customer exists) and Path 2 (customer doesn't exist). The workflow evaluates conditions on each path and executes the appropriate branch. This prevents attempting to create duplicate customers or referencing customer IDs that don't exist.

Filter: Customer Already in Katana

App connector: [Katana](/content/apps/katana/integrate "View Katana integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Evaluates whether a Katana customer was found and routes to sales order creation using the existing customer ID, skipping unnecessary customer creation when records already exist.

This path checks if the Katana customer array is not empty. If true (customer found), the workflow follows Path 1 which matches products and creates the sales order. If false (no customer found), this path is skipped and Path 2 executes instead.

Match Square SKUs to Katana Variants

App connector: [Katana](/content/apps/katana/integrate "View Katana integration page"/index.html)• Time to complete: 1 minute

Why this matters: Queries Katana's API with all SKUs from the order to find matching product variants, establishing the connection between Square products and Katana manufacturing items needed for sales order creation.

This custom JavaScript step queries Katana's variants endpoint with the SKU list collected from the loop.

// Gets SKU array from loop
const skusListSquare = vars.loop_1.items;
// Creates query string like "sku=SKU1&sku=SKU2&sku=SKU3"
const skusParameter = skusListSquare.map(sku => `sku=${sku}`).join('&');
// Queries Katana API with OAuth
const oauth = new Oauth('refresh_token', 'katana');
const response = oauth.get(`${baseUrl}?${skusParameter}`);
// Returns matching Katana variants with IDs
Mesa.output.next({skus_list_katana: skusListKatana});

The code sends an authenticated GET request to Katana's API, passing all SKUs as query parameters, and returns matching product variants including Katana variant IDs needed for the sales order line items.

SKU matching requirement: This assumes you use the same SKUs in both Square and Katana. If SKUs differ, you'd need custom mapping logic.

Create Katana Sales Order

App connector: [Katana](/content/apps/katana/integrate "View Katana integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Creates the manufacturing sales order in Katana with all product, customer, pricing, and shipping details, triggering production planning and inventory allocation for fulfillment.

This step creates a Katana sales order using the existing customer ID. The sales order includes:

  1. order_no: "1" (can be customized to use Square order number)
  2. customer_id: Existing Katana customer ID
  3. order_created_date: Square order timestamp
  4. currency: Order currency from Square
  5. sales_order_rows: Array of line items with quantity, variant_id (from Katana product matching), price_per_unit, and total_discount
  6. addresses: Shipping address array with complete customer address from Square

The sales order creation triggers Katana's manufacturing workflow, allocating materials, scheduling production, and updating inventory forecasts.

Filter: New Katana Customer

App connector: [Katana](/content/apps/katana/integrate "View Katana integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Evaluates whether a Katana customer was NOT found and routes to customer creation followed by sales order creation, ensuring new customers get proper manufacturing system records.

This path checks if the Katana customer array is empty. If true (no customer found), the workflow follows Path 2 which creates a new customer then creates the sales order. If false (customer exists), this path is skipped.

Create Katana Customer

App connector: [Katana](/content/apps/katana/integrate "View Katana integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Creates a new Katana customer record with complete contact and shipping information from Square, establishing the customer relationship needed for sales order creation and future orders.

This step creates a Katana customer using Square customer data. It includes:

  1. name: Full name combining given and family names
  2. first_name: Customer's first name
  3. last_name: Customer's last name
  4. company: Company name if provided
  5. email: Email address
  6. phone: Phone number
  7. addresses: Array with shipping address including all address components

The created customer is returned with Katana customer ID used in the subsequent sales order creation.

Match Square SKUs to Katana Variants

App connector: [Katana](/content/apps/katana/integrate "View Katana integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Queries Katana's API with SKUs for new customer orders, identical to the previous SKU match but executed in the new customer path to ensure product matching occurs regardless of customer status.

This step is identical to the SKU matching step in Path 1, using the same custom code to match Square SKUs with Katana product variants. It's duplicated in Path 2 to ensure product matching happens after customer creation.

Create Katana Sales Order

App connector: [Katana](/content/apps/katana/integrate "View Katana integration page"/index.html)• Time to complete: 0 minutes (Auto-configured)

Why this matters: Creates the manufacturing sales order using the newly created customer ID, completing the full workflow of customer creation and order placement for first-time Square customers.

This step is identical to the Create Katana Sales Order step in Path 1 except it uses the newly created Katana customer ID. All other sales order details (line items, pricing, shipping address) remain the same.