Skip to main content

Manufacturing and Production API Quickstart Guide

Welcome to the StateSet Manufacturing Guide. This document provides developers and technical users with instructions for utilizing the StateSet API to manage core manufacturing processes. Learn how to configure your environment, model production data (Products, BOMs), plan and execute production runs (Work Orders, Manufacturing Orders), and manage associated inventory movements. Following this guide will enable you to integrate StateSet into your manufacturing workflows, enhancing operational efficiency, data accuracy, and cost control.

Table of Contents

  1. Introduction
  2. Prerequisites
  3. Getting Started: SDK Setup
  4. Core Manufacturing Concepts
  5. API Workflow: End-to-End Manufacturing Process
  6. Optimizing Manufacturing Processes with API Data
  7. Real-Time Monitoring and System Integration
  8. Error Handling and Logging Strategies
  9. Troubleshooting Common Manufacturing API Issues
  10. Support Resources
  11. Conclusion

Introduction

StateSet offers a comprehensive API designed to manage the complexities of modern manufacturing operations. This guide focuses on the practical application of the API for common workflows, including defining manufacturable items, planning production schedules, tracking execution progress, and maintaining accurate inventory records. By leveraging the StateSet API, you can automate processes, improve data visibility, and enable data-driven optimization. Key Learning Objectives:
  • Configure the StateSet Node.js SDK for secure API interaction.
  • Understand fundamental manufacturing entities within StateSet (Products, BOMs, WOs, MOs, Inventory).
  • Utilize API endpoints to create, update, and manage manufacturing data throughout the production lifecycle.
  • Identify opportunities to use API data for process optimization (e.g., OEE, waste analysis).
  • Implement robust error handling and logging for reliable integration.

Prerequisites

  • Node.js (version 16 or higher recommended).
  • An active StateSet account and a generated API key with appropriate permissions for manufacturing resources.
  • Basic understanding of JavaScript (async/await), REST APIs, and JSON data structures.
  • Familiarity with core manufacturing concepts (BOMs, Work Orders, Inventory Management).

Getting Started: SDK Setup

Ensure your development environment is configured to interact with the StateSet API.

1. Install the StateSet Node.js SDK

Add the official SDK package to your Node.js project using npm or yarn.

Core Manufacturing Concepts

Understanding these entities within the StateSet context is crucial for effective API usage.
  • Product: Represents a distinct item that can be manufactured or sold (e.g., finished good, subassembly). Identified by attributes like sku, name.
  • Bill of Materials (BOM): Defines the “recipe” for manufacturing a specific Product. Lists required components (other Products or raw materials identified by item_id) and their quantity and unit of measure. Often version-controlled.
  • Work Order (WO): An authorization to produce a specific quantity of a Product by a certain date. References the relevant BOM and specifies production details like priority and target site. Acts as the high-level production plan.
  • Manufacturing Order (MO): Represents the execution of a Work Order or a portion of it. Tracks the actual production run, including start/end times, status (e.g., planned, in_progress, completed), resources used, and materials consumed. It’s the operational record of production. Often linked back to the source Work Order via work_order_id.
  • Picks: The operational task of retrieving specific inventory_item_ids (representing actual stock) from storage locations to fulfill the material requirements of an MO. Tracks requested vs. picked quantities.
  • Inventory (inventory_item_id vs item_id/part_number):
    • item_id or part_number: Represents the type of item (e.g., ‘RESISTOR-10K’). Corresponds to a Product or raw material definition.
    • inventory_item_id (or similar concept): Represents a specific batch/lot/instance of that item in stock, often with its own location, quantity, and cost layer. Picks operate on these specific inventory units. Inventory movements update the quantity of specific inventory_item_ids.
  • Cycle Counts: Periodic verification of physical inventory quantities against system records (inventory resource) to ensure data accuracy.
  • Waste & Scrap: Records materials consumed during production that did not become part of the finished good, enabling analysis of production efficiency.
  • Machines: Represents production equipment. Tracking usage (logRuntime) and Maintenance is vital for OEE and reliability.
  • Kitting: Process of pre-assembling components into a single kit (item_id) for easier consumption during final assembly. Managed via BOMs and Inventory.

API Workflow: End-to-End Manufacturing Process

This section demonstrates using the StateSet API to manage a typical manufacturing flow.

Step 1: Defining Products and Bills of Materials (BOMs)

Establish the foundation by defining what you manufacture and how.

A. Create a Product

Define the item to be manufactured.
Purpose: Records the master data for the manufacturable item. The sku or id will be used to link BOMs and Orders.

B. Create a Bill of Materials (BOM)

Define the components required to make the Product.
Purpose: Defines the structure and material requirements for manufacturing. The item_id for components refers to other Product SKUs or raw material identifiers.

Step 2: Planning Production (Work Orders)

Authorize and schedule production runs.

A. Create a Work Order

Generate an order to produce a specific quantity of a Product.
Purpose: Schedules production, reserves capacity (implicitly), and provides the basis for execution tracking via Manufacturing Orders.

Step 3: Executing Production (Manufacturing Orders & Activities)

Track the actual manufacturing process based on the planned Work Order.

A. Create a Manufacturing Order

Initiate the tracking for the actual production run, linking it to the Work Order.
Purpose: Creates the operational record for tracking progress, resource consumption, and output related to the planned Work Order.

B. Track Production Activities (Machine Time, Waste)

Record resource usage and material losses during the MO execution.
Purpose: Captures critical operational data for performance analysis (OEE, yield) and cost tracking. Note the importance of linking waste records to actual inventory adjustments.

C. Complete the Manufacturing Order

Mark the production run as finished and record the output quantity.
Purpose: Finalizes the production run record, capturing the yield. This event typically triggers the creation of Finished Goods inventory.

Step 4: Managing Inventory Movements (Picks, Consumption, Receipts)

Accurately track materials moving into, through, and out of production.

A. Create and Complete Picks

Manage the process of retrieving components from inventory for the MO.
Purpose: Manages the physical movement of materials from storage to the production floor. Crucially links to inventory deduction. The distinction between inventory_item_id (specific stock) and item_id (general part number) is vital here.

B. Record Finished Goods Receipt (Implied/Separate Step)

Increase inventory for the product manufactured upon MO completion. This might be an automatic side-effect of completeManufacturingOrder or require a separate inventory transaction.
Purpose: Updates inventory levels to reflect newly manufactured stock, making it available for sale or further processes. Calculating the correct unit_cost for these finished goods is a critical accounting step often involving cost roll-ups from the MO.

Step 5: Maintaining Inventory Accuracy (Cycle Counts)

Ensure inventory data remains accurate through regular checks.

A. Schedule and Record Cycle Counts

Initiate and record the results of periodic inventory counts.
Purpose: Provides a mechanism for systematic inventory verification, identifying discrepancies that require adjustments to maintain accurate stock levels crucial for planning and fulfillment.

Optimizing Manufacturing Processes with API Data

The data captured via the StateSet API is invaluable for process improvement. Analyze this data to:
  • Calculate Overall Equipment Effectiveness (OEE): Use machine runtime logs (logMachineRuntime), MO planned vs. actual times, and MO quantity_completed vs. quantity_planned (considering scrap) to measure Availability, Performance, and Quality.
    • Availability = Actual Runtime / Planned Production Time
    • Performance = (Ideal Cycle Time * Total Pieces Produced) / Actual Runtime
    • Quality = Good Pieces (Completed Qty - Scrap Qty) / Total Pieces Produced
    • OEE = Availability * Performance * Quality
  • Analyze Waste and Scrap: Aggregate wasteAndScrap records by reason code, item, machine, or operator to identify root causes of material loss and target areas for process improvement or training.
  • Optimize Production Scheduling: Analyze historical MO completion times, lead times derived from WO/MO dates, and resource (machine/labor) utilization data to improve future scheduling accuracy and resource allocation.
  • Implement Predictive Maintenance: Analyze machine runtime hours, cycle counts, and potentially sensor data (if integrated) to predict maintenance needs before failures occur, reducing unplanned downtime.
  • Refine BOM Accuracy: Compare actual component consumption (derived from completed Picks and adjusted for scrap) against theoretical BOM quantities to identify inaccuracies in the Bill of Materials.
Note: The OEE calculation requires careful data gathering from multiple related records. The example provides the structure but relies on placeholders for data fetching logic.

Real-Time Monitoring and System Integration

Leverage real-time data flow for operational visibility and system synchronization.
  • Webhooks: Configure StateSet Webhooks to receive real-time notifications for critical manufacturing events. Examples:
    • manufacturingorder.completed: Trigger downstream processes like FG inventory receipt, shipping notifications, or ERP updates.
    • inventory.quantity.low: Alert purchasing or planning when component stock drops below a threshold.
    • pick.completed: Update shop floor dashboards or trigger material movement confirmations.
    • machine.status.changed: Monitor equipment state changes for immediate visibility.
  • Dashboarding: Feed API data (MO status, queue lengths, OEE metrics, waste levels) into Business Intelligence (BI) tools or custom dashboards for real-time operational monitoring by supervisors and managers.
  • ERP/MES Integration: Synchronize StateSet data (inventory levels, WO/MO status, costs) with your primary ERP or Manufacturing Execution System (MES) to maintain data consistency across platforms. Use the API for bi-directional updates where appropriate.

Error Handling and Logging Strategies

Implement robust error handling and logging for reliable manufacturing system integration.
  • Specific API Error Handling: Catch errors from SDK calls. Inspect error.response.status (HTTP status code) and error.response.data (API error details) to determine the cause (e.g., 400 Bad Request, 401 Unauthorized, 404 Not Found, 429 Rate Limited, 5xx Server Error).
  • Input Validation: Validate data before making API calls to prevent unnecessary errors (check required fields, data types, formats).
  • Retry Logic: Implement exponential backoff strategies for transient errors (e.g., 429, 503). Do not retry client errors (4xx) without correcting the request.
  • Idempotency: For critical operations like creating orders or inventory movements, utilize idempotency keys if supported by the API, or implement application-level checks to prevent duplicate transactions.
  • Centralized Logging: Log detailed information for both successful operations and errors (timestamp, operation name, input identifiers, outcome, error message, stack trace, API response details) to a dedicated logging service (e.g., Datadog, Splunk, ELK Stack) for monitoring, alerting, and debugging.
  • Transactionality (Application Level): For multi-step workflows (e.g., completing MO -> receiving FG inventory), consider application-level patterns (like sagas or compensating transactions) to handle failures gracefully if the API doesn’t support atomic transactions across multiple calls.

Troubleshooting Common Manufacturing API Issues

Address frequent problems encountered when integrating manufacturing workflows.
  • Authentication Errors (401/403):
    • Solution: Verify API key validity, environment variable loading, and key permissions for manufacturing-related resources (product, workorder, inventory, etc.).
  • Not Found Errors (404):
    • Solution: Double-check IDs used in requests (productId, bomId, woId, moId, inventory_item_id). Ensure the referenced resource exists and hasn’t been deleted. Check for typos.
  • Validation Errors (400):
    • Solution: Examine error.response.data for details. Confirm required fields are present, data types match API expectations (number vs. string), dates are in ISO 8601 format, and enum values (status, type) are valid. Check quantity/unit consistency.
  • Inventory Discrepancies:
    • Solution: Audit the workflow logic: Are picks correctly deducting inventory? Is waste recording linked to an inventory adjustment? Are FG receipts correctly adding inventory? Use Cycle Counts to identify and investigate differences. Ensure correct inventory_item_ids are used.
  • Incorrect Production Costs:
    • Solution: Verify component costs used in calculations. Ensure labor and overhead tracking/allocation logic is correct. Check BOM accuracy. Confirm waste quantities are factored in appropriately.
  • Race Conditions/Concurrency Issues:
    • Solution: If multiple processes might update the same resource (e.g., inventory quantity), use optimistic locking mechanisms (if supported by API via ETags/versions) or structure workflows to minimize concurrent updates on the same item. Ensure idempotency for creation events.

Support Resources

Consult these resources for additional help and information:

Conclusion

This quickstart guide has provided a comprehensive walkthrough of managing manufacturing and production processes using the StateSet API. You have learned how to set up your environment, define products and BOMs, plan and execute production via Work Orders and Manufacturing Orders, track crucial activities like picks and machine usage, manage inventory movements, and leverage the captured data for optimization. By implementing these workflows and adhering to best practices for error handling and monitoring, you can build robust, efficient, and data-driven manufacturing operations powered by StateSet. Remember to adapt the specific costing, inventory adjustment, and optimization logic to your company’s unique requirements and accounting practices. Utilize the available support resources for any further assistance needed.